Skip to content

Commit

Permalink
Adapt tests to the new weight scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
MBartkowiakSTFC committed Feb 4, 2025
1 parent e9fe17f commit a8779a0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion MDANSE/Src/MDANSE/Mathematics/Signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ def normalisation_factor(x, axis=0):
s[axis] = slice(0, 1, 1)

s = tuple(s)
scaling_factor = x.scaling_factor

return 1 / x[s]
return 1 / (scaling_factor * x[s])


def differentiate(a, dt=1.0, order=1):
Expand Down
4 changes: 2 additions & 2 deletions MDANSE/Tests/UnitTests/Analysis/test_dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_vacf(interp_order, normalise):
with h5py.File(temp_name + ".mda") as actual, h5py.File(result_file) as desired:
for key in ["vacf_Cu", "vacf_S", "vacf_Sb", "vacf_total"]:
np.testing.assert_array_almost_equal(
actual[f"/{key}"] * actual[f"/{key}"].attrs[f"/{key}"],
actual[f"/{key}"] * actual[f"/{key}"].attrs["scaling_factor"],
desired[f"/{key}"],
)

Expand Down Expand Up @@ -105,7 +105,7 @@ def test_pps():
"pps_total",
]:
np.testing.assert_array_almost_equal(
actual[f"/{key}"] * actual[f"/{key}"].attrs[f"/{key}"],
actual[f"/{key}"] * actual[f"/{key}"].attrs["scaling_factor"],
desired[f"/{key}"],
)

Expand Down
11 changes: 5 additions & 6 deletions MDANSE/Tests/UnitTests/Analysis/test_mock_dynamics.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ def test_vacf(interp_order, normalise):
result_file = os.path.join(result_dir, fname)

with h5py.File(temp_name + ".mda") as actual, h5py.File(result_file) as desired:
np.testing.assert_array_almost_equal(actual["/vacf_H"], desired["/vacf_H"])
np.testing.assert_array_almost_equal(actual["/vacf_O"], desired["/vacf_O"])
np.testing.assert_array_almost_equal(actual["/vacf_Si"], desired["/vacf_Si"])
np.testing.assert_array_almost_equal(
actual["/vacf_total"], desired["/vacf_total"]
)
for key in ["vacf_H", "vacf_O", "vacf_Si", "vacf_total"]:
np.testing.assert_array_almost_equal(
actual[f"/{key}"] * actual[f"/{key}"].attrs["scaling_factor"],
desired[f"/{key}"],
)

os.remove(temp_name + ".mda")
assert path.exists(temp_name + ".log")
Expand Down
Binary file not shown.

0 comments on commit a8779a0

Please sign in to comment.