Skip to content

Commit 7e05f27

Browse files
committed
Test: compare the normalized gp arrays with a tolerance
gp_Dir normalizes in C++, the result may differ from numpy by a few ulps (FMA contraction on aarch64): the exact comparison failed on the linux-aarch64 wheels.
1 parent 7f8a19b commit 7e05f27

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎test/test_core_numpy.py‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ def test_array1_of_gp(type_, array_types_2d, normalizing_array_types):
100100
np_arr_out = gp_arr.to_numpy_array()
101101

102102
if type_ in normalizing_array_types:
103-
assert np.all(np_arr_out == p / np.linalg.norm(p, axis=-1, keepdims=True))
103+
# gp_Dir normalizes in C++, may differ by a few ulps (FMA on aarch64)
104+
assert np.allclose(
105+
np_arr_out, p / np.linalg.norm(p, axis=-1, keepdims=True), rtol=0, atol=1e-15
106+
)
104107
else:
105108
assert np.all(np_arr_out == p)
106109

@@ -126,7 +129,10 @@ def test_array2_of_gp(type_, array_types_2d, normalizing_array_types):
126129
np_arr_out = arr_occ.to_numpy_array()
127130

128131
if type_ in normalizing_array_types:
129-
assert np.all(np_arr_out == p / np.linalg.norm(p, axis=-1, keepdims=True))
132+
# gp_Dir normalizes in C++, may differ by a few ulps (FMA on aarch64)
133+
assert np.allclose(
134+
np_arr_out, p / np.linalg.norm(p, axis=-1, keepdims=True), rtol=0, atol=1e-15
135+
)
130136
else:
131137
assert np.all(np_arr_out == p)
132138

0 commit comments

Comments
 (0)