Skip to content

Commit

Permalink
Update DCSF results for changing unit cell
Browse files Browse the repository at this point in the history
  • Loading branch information
MBartkowiakSTFC committed Feb 24, 2025
1 parent 00d07de commit 94956b2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def configure(self, value: tuple[int, int, int, int]):

first, last, step, c_frames = value
super().configure((first, last, step))
self._original_input = value

if c_frames > self["n_frames"]:
self.error_status = (
Expand Down
32 changes: 24 additions & 8 deletions MDANSE/Tests/UnitTests/Analysis/test_scattering.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,18 @@ def test_dcsf(traj_info, qvector_grid):
if any(key.startswith(j) for j in ["f(q,t)", "s(q,f)"])
]
for key in keys:
np.testing.assert_array_almost_equal(
actual[f"/{key}"] * actual[f"/{key}"].attrs["scaling_factor"],
desired[f"/{key}"],
)
try:
scaling_factor = desired[f"/{key}"].attrs["scaling_factor"]
except KeyError:
np.testing.assert_array_almost_equal(
actual[f"/{key}"] * actual[f"/{key}"].attrs["scaling_factor"],
desired[f"/{key}"],
)
else:
np.testing.assert_array_almost_equal(
actual[f"/{key}"] * actual[f"/{key}"].attrs["scaling_factor"],
desired[f"/{key}"] * scaling_factor,
)

os.remove(temp_name + ".mda")
assert path.exists(temp_name + "_text.tar")
Expand Down Expand Up @@ -215,10 +223,18 @@ def test_disf(traj_info, qvector_grid):
i for i in desired.keys() if any([j in i for j in ["f(q,t)", "s(q,f)"]])
]
for key in keys:
np.testing.assert_array_almost_equal(
actual[f"/{key}"] * actual[f"/{key}"].attrs["scaling_factor"],
desired[f"/{key}"],
)
try:
scaling_factor = desired[f"/{key}"].attrs["scaling_factor"]
except KeyError:
np.testing.assert_array_almost_equal(
actual[f"/{key}"] * actual[f"/{key}"].attrs["scaling_factor"],
desired[f"/{key}"],
)
else:
np.testing.assert_array_almost_equal(
actual[f"/{key}"] * actual[f"/{key}"].attrs["scaling_factor"],
desired[f"/{key}"] * scaling_factor,
)

os.remove(temp_name + ".mda")
assert path.exists(temp_name + "_text.tar")
Expand Down
Binary file modified MDANSE/Tests/UnitTests/Results/dcsf_short_traj.mda
Binary file not shown.

0 comments on commit 94956b2

Please sign in to comment.