Skip to content

Commit 623ecfa

Browse files
committed
TST: Test for inconsistent results in complex squaring (numpy#26940)
The test fails when compiling on clang with "-ffp-contract=off", due to a combination of factors: * Difference between SIMD and non-SIMD loops * nomemoverlap falling back to non-SIMD loop due to off-by-one bug
1 parent c8ed7e9 commit 623ecfa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

numpy/_core/tests/test_regression.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,3 +2622,17 @@ def test_vectorize_fixed_width_string(self):
26222622
f = str.casefold
26232623
res = np.vectorize(f, otypes=[arr.dtype])(arr)
26242624
assert res.dtype == "U30"
2625+
2626+
def test_repeated_square_consistency(self):
2627+
# gh-26940
2628+
buf = np.array([-5.171866611150749e-07 + 2.5618634555957426e-07j,
2629+
0, 0, 0, 0, 0])
2630+
# Test buffer with regular and reverse strides
2631+
for in_vec in [buf[:3], buf[:3][::-1]]:
2632+
expected_res = np.square(in_vec)
2633+
# Output vector immediately follows input vector
2634+
# to reproduce off-by-one in nomemoverlap check.
2635+
for res in [buf[3:], buf[3:][::-1]]:
2636+
res = buf[3:]
2637+
np.square(in_vec, out=res)
2638+
assert_equal(res, expected_res)

0 commit comments

Comments
 (0)