Skip to content

Commit

Permalink
Merge branch 'master' into bump-version-0.3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
waltsims authored Nov 22, 2024
2 parents 626f3fc + 16d23c1 commit 97e4684
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion kwave/options/simulation_execution_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def get_options_string(self, sensor: kSensor) -> str:
if self.device_num is not None:
options_list.append(f" -g {self.device_num}")

if self.num_threads is not None:
if self.num_threads is not None and PLATFORM != "windows":
options_list.append(f" -t {self.num_threads}")

if self.verbose_level > 0:
Expand Down
30 changes: 29 additions & 1 deletion tests/test_simulation_execution_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,35 @@ def test_binary_name_extension_on_windows(self):
options = SimulationExecutionOptions()
self.assertTrue(options.binary_name.endswith(".exe"))

def test_get_options_string(self):
@patch("kwave.options.simulation_execution_options.PLATFORM", "darwin")
def test_get_options_string_darwin(self):
"""Test the get_options_string method with a mock sensor."""
options = self.default_options
options.device_num = 1
options.num_threads = os.cpu_count()
options.verbose_level = 2

options_string = options.get_options_string(self.mock_sensor)
expected_substrings = [" -g 1", f" -t {os.cpu_count()}", " --verbose 2", " --p_raw", " --u_max", " -s 10"]
for substring in expected_substrings:
self.assertIn(substring, options_string)

@patch("kwave.options.simulation_execution_options.PLATFORM", "windows")
def test_get_options_string_windows(self):
"""Test the get_options_string method with a mock sensor."""
options = self.default_options
options.device_num = 1
options.num_threads = os.cpu_count()
options.verbose_level = 2

options_string = options.get_options_string(self.mock_sensor)
expected_substrings = [" -g 1", " --verbose 2", " --p_raw", " --u_max", " -s 10"]
for substring in expected_substrings:
self.assertIn(substring, options_string)
self.assertNotIn(f" -t {os.cpu_count()}", expected_substrings)

@patch("kwave.options.simulation_execution_options.PLATFORM", "linux")
def test_get_options_string_linux(self):
"""Test the get_options_string method with a mock sensor."""
options = self.default_options
options.device_num = 1
Expand Down

0 comments on commit 97e4684

Please sign in to comment.