Skip to content

Commit 81a825d

Browse files
committed
waltsims#592: added windows guard in tests.
1 parent 1227776 commit 81a825d

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

kwave/options/simulation_execution_options.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,6 @@ def as_list(self, sensor: kSensor) -> list[str]:
188188
options_list.append("--verbose")
189189
options_list.append(str(self.verbose_level))
190190

191-
if self.checkpoint_interval is not None and self.checkpoint_timesteps is not None:
192-
logger.warning("Both checkpoint_interval and checkpoint_timesteps have been set. Kwave defaults to checkpoint_interval")
193-
194191
if (self.checkpoint_interval is not None or self.checkpoint_timesteps is not None) and self.checkpoint_file is not None:
195192
if self.checkpoint_timesteps is not None:
196193
if not isinstance(self.checkpoint_timesteps, int) or self.checkpoint_timesteps < 0:
@@ -205,9 +202,9 @@ def as_list(self, sensor: kSensor) -> list[str]:
205202

206203
p = Path(self.checkpoint_file)
207204
if not p.parent.exists():
208-
raise ValueError(f"Checkpoint directory {p.parent} does not exist." "Please create it before running the simulation.")
205+
raise ValueError(f"Checkpoint directory {p.parent} does not exist. Please create it before running the simulation.")
209206
if p.suffix != ".h5":
210-
raise ValueError(f"Checkpoint file {p.name} must have .h5 " "extension. Please rename it before running the simulation.")
207+
raise ValueError(f"Checkpoint file {p.name} must have .h5 extension. Please rename it before running the simulation.")
211208

212209
options_list.append("--checkpoint_file")
213210
options_list.append(str(self.checkpoint_file))

tests/test_simulation_execution_options.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,12 @@ def test_list_compared_to_string(self):
219219
def test_as_list_with_valid_checkpoint_interval_options(self):
220220
"""Test the checkpoint interval options."""
221221
options = self.default_options
222-
options.num_threads = os.cpu_count()
222+
options.num_threads = 1
223223
options.checkpoint_interval = 10
224224
options.checkpoint_file = "checkpoint.h5"
225225

226226
options_list = options.as_list(self.mock_sensor)
227227
expected_elements = [
228-
"-t",
229-
str(os.cpu_count()),
230228
"--checkpoint_interval",
231229
"10",
232230
"--checkpoint_file",
@@ -236,19 +234,20 @@ def test_as_list_with_valid_checkpoint_interval_options(self):
236234
"-s",
237235
"10",
238236
]
237+
if not PLATFORM == "windows":
238+
expected_elements.insert(0, "-t")
239+
expected_elements.insert(1, f"1")
239240
self.assertListEqual(expected_elements, options_list)
240241

241242
def test_as_list_with_valid_checkpoint_timesteps_options(self):
242243
"""Test the checkpoint interval options."""
243244
options = self.default_options
244-
options.num_threads = os.cpu_count()
245+
options.num_threads = 1
245246
options.checkpoint_timesteps = 10
246247
options.checkpoint_file = "checkpoint.h5"
247248

248249
options_list = options.as_list(self.mock_sensor)
249250
expected_elements = [
250-
"-t",
251-
str(os.cpu_count()),
252251
"--checkpoint_timesteps",
253252
"10",
254253
"--checkpoint_file",
@@ -258,6 +257,9 @@ def test_as_list_with_valid_checkpoint_timesteps_options(self):
258257
"-s",
259258
"10",
260259
]
260+
if not PLATFORM == "windows":
261+
expected_elements.insert(0, "-t")
262+
expected_elements.insert(1, f"1")
261263
self.assertListEqual(expected_elements, options_list)
262264

263265

0 commit comments

Comments
 (0)