Skip to content

Commit ecfc3ee

Browse files
committed
Fix tests
1 parent 5844867 commit ecfc3ee

1 file changed

Lines changed: 24 additions & 10 deletions

File tree

tests/test_kspaceFirstOrder3D_state.py

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ def make_simulation_parameters(directory: Path):
3939
# define a binary planar sensor
4040
sensor = kSensor()
4141
sensor_mask_array = np.zeros(N)
42-
sensor_mask_array[0, :, :] = 1 # Corrected to be a plane for 3D
42+
sensor_mask_array[0, :, :] = 1 # Corrected to be a plane for 3D
4343
sensor.mask = sensor_mask_array
4444

4545
input_filename = directory / "kwave_input.h5"
4646
output_filename = directory / "kwave_output.h5"
4747
checkpoint_filename = directory / "kwave_checkpoint.h5"
4848

4949
simulation_options = SimulationOptions(
50-
save_to_disk=True, # Must be true for kspaceFirstOrder3D
50+
save_to_disk=True, # Must be true for kspaceFirstOrder3D
5151
pml_size=PML_size,
5252
pml_inside=False,
53-
smooth_p0=False, # p0 is already smoothed
53+
smooth_p0=False, # p0 is already smoothed
5454
data_cast="single",
5555
input_filename=input_filename,
5656
output_filename=output_filename,
@@ -59,10 +59,10 @@ def make_simulation_parameters(directory: Path):
5959
checkpoint_timesteps = 300
6060

6161
execution_options = SimulationExecutionOptions(
62-
is_gpu_simulation=False, # Assuming CPU for basic test
62+
is_gpu_simulation=False, # Assuming CPU for basic test
6363
checkpoint_file=checkpoint_filename,
6464
checkpoint_timesteps=checkpoint_timesteps,
65-
verbose_level=0 # Keep test output clean
65+
verbose_level=0, # Keep test output clean
6666
)
6767
return kgrid, medium, source, sensor, simulation_options, execution_options
6868

@@ -75,13 +75,20 @@ def test_kspaceFirstOrder3D_input_state_preservation():
7575
# Store original states of critical attributes for comparison
7676
original_source_p0 = deepcopy(source.p0)
7777
original_sensor_mask = deepcopy(sensor.mask)
78-
78+
7979
# If source.p or source.u were time-varying, store their initial states too.
8080
# For this test, p0 is the main source attribute.
8181

8282
# First run
8383
try:
84-
_ = kspaceFirstOrder3D(kgrid, medium, source, sensor, simulation_options, execution_options)
84+
_ = kspaceFirstOrder3D(
85+
kgrid=kgrid,
86+
medium=medium,
87+
source=source,
88+
sensor=sensor,
89+
simulation_options=simulation_options,
90+
execution_options=execution_options,
91+
)
8592
except Exception as e:
8693
pytest.fail(f"First call to kspaceFirstOrder3D failed: {e}")
8794

@@ -95,13 +102,20 @@ def test_kspaceFirstOrder3D_input_state_preservation():
95102
simulation_options_run2 = deepcopy(simulation_options)
96103
simulation_options_run2.input_filename = tmpdir / "kwave_input_run2.h5"
97104
simulation_options_run2.output_filename = tmpdir / "kwave_output_run2.h5"
98-
105+
99106
execution_options_run2 = deepcopy(execution_options)
100-
if execution_options_run2.checkpoint_file: # Only change if it exists
107+
if execution_options_run2.checkpoint_file: # Only change if it exists
101108
execution_options_run2.checkpoint_file = tmpdir / "kwave_checkpoint_run2.h5"
102109

103110
try:
104-
_ = kspaceFirstOrder3D(kgrid, medium, source, sensor, simulation_options_run2, execution_options_run2)
111+
_ = kspaceFirstOrder3D(
112+
kgrid=kgrid,
113+
medium=medium,
114+
source=source,
115+
sensor=sensor,
116+
simulation_options=simulation_options_run2,
117+
execution_options=execution_options_run2,
118+
)
105119
except Exception as e:
106120
pytest.fail(f"Second call to kspaceFirstOrder3D with original objects failed: {e}")
107121

0 commit comments

Comments
 (0)