Skip to content

Commit 06d0766

Browse files
authored
Merge pull request #67 from SimoneMartino98/num_precision
replaced all the array_equal with all_close to avoid numerical precision issues. Thank you @SimoneMartino98
2 parents 52ee36a + 67ee436 commit 06d0766

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

tests/analysis/rdf/test_rdf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@ def test_compute_rdf(case_data: RDFCaseData) -> None:
4040

4141
exp_bins = np.load(expected_bins)
4242
exp_rdf = np.load(expected_rdf)
43-
assert np.array_equal(exp_rdf, test_rdf)
44-
assert np.array_equal(exp_bins, test_bins)
43+
assert np.allclose(exp_rdf, test_rdf)
44+
assert np.allclose(exp_bins, test_bins)

tests/analysis/test_spatialaverage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ def test_spatialaverage() -> None:
3939

4040
# Load expected results and compare
4141
expected_arr = np.load(expected_results)
42-
assert np.array_equal(test_arr, expected_arr)
42+
assert np.allclose(test_arr, expected_arr)

tests/lens/test_lens.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def test_lens_signals() -> None:
5151
check_lens_nn = check_file[f"LENS_{i}"]
5252

5353
# Check if control and test array are equal
54-
assert np.array_equal(check_lens_nn, test_lens_nn), (
54+
assert np.allclose(check_lens_nn, test_lens_nn), (
5555
f"LENS analyses provided different values "
5656
f"compared to the control system "
5757
f"for r_cut: {lens_cutoffs[i]} (results: {output_file})."

tests/lens/test_special_lens.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import MDAnalysis
22
import numpy as np
3-
from numpy.testing import assert_array_equal
43

54
import dynsight
65

@@ -33,8 +32,8 @@ def test_special_lens(lensfixtures: MDAnalysis.Universe) -> None:
3332
mydentot,
3433
) = dynsight.lens.neighbour_change_in_time(nnlistperframe)
3534

36-
assert_array_equal(mynconttot[:, 0], [0] * mynconttot.shape[0])
37-
assert_array_equal(mynconttot[:, 1], expected)
35+
np.allclose(mynconttot[:, 0], [0] * mynconttot.shape[0])
36+
np.allclose(mynconttot[:, 1], expected)
3837

3938
for frame in [0, 1]:
4039
for atom in universe.atoms:

tests/lens/to_remove_test_count_neigh.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import MDAnalysis
66
import numpy as np
7-
from numpy.testing import assert_array_equal
87

98
import dynsight
109

@@ -61,4 +60,4 @@ def test_count_neigh_for_lens(
6160
for atomgroupnn, myatomsid in zip(nnlistorig, mynnlist):
6261
atomsid = np.sort([at.ix for at in atomgroupnn])
6362
assert is_sorted(myatomsid)
64-
assert_array_equal(atomsid, myatomsid)
63+
np.allclose(atomsid, myatomsid)

0 commit comments

Comments
 (0)