Skip to content

Commit eec44a2

Browse files
committed
add test for issue 27036
1 parent e125e3c commit eec44a2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

numpy/linalg/tests/test_regression.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,18 @@ def test_matrix_rank_rtol_argument(self, rtol):
161161
x = np.zeros((4, 3, 2))
162162
res = np.linalg.matrix_rank(x, rtol=rtol)
163163
assert res.shape == (4,)
164+
165+
def test_openblas_threading(self):
166+
# gh-27036
167+
# Test whether matrix multiplication involving a large matrix always
168+
# gives the same (correct) answer
169+
x = np.arange(500000, dtype=np.float64)
170+
src = np.vstack((x, -10*x)).T
171+
matrix = np.array([[0, 1], [1, 0]])
172+
expected = np.vstack((-10*x, x)).T # src @ matrix
173+
for i in range(200):
174+
result = src @ matrix
175+
mismatches = (~np.isclose(result, expected)).sum()
176+
if mismatches != 0:
177+
assert False, ("unexpected result from matmul, "
178+
"probably due to OpenBLAS threading issues")

0 commit comments

Comments
 (0)