Skip to content

Commit 4ca52a2

Browse files
committed
Relax matmul thread-limit tests for macOS NumPy warnings
1 parent ffccab7 commit 4ca52a2

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

tests/ndarray/test_linalg.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,10 @@ def __exit__(self, exc_type, exc, tb):
285285
warnings.simplefilter("ignore", RuntimeWarning)
286286
c = blosc2.matmul(a, b, chunks=(100, 100), blocks=(50, 50))
287287

288-
np.testing.assert_allclose(c[:], np.matmul(a[:], b[:]), rtol=1e-6, atol=1e-6)
288+
with warnings.catch_warnings():
289+
warnings.simplefilter("ignore", RuntimeWarning)
290+
expected = np.matmul(a[:], b[:])
291+
np.testing.assert_allclose(c[:], expected, rtol=1e-6, atol=1e-6)
289292
assert calls == [("init", 1, "blas"), "enter", ("exit", None)]
290293
finally:
291294
_toggle_miniexpr(old_flag)
@@ -310,7 +313,10 @@ def unexpected_threadpool_limits(*args, **kwargs):
310313
warnings.simplefilter("ignore", RuntimeWarning)
311314
c = blosc2.matmul(a, b, chunks=(400, 400), blocks=(200, 200))
312315

313-
np.testing.assert_allclose(c[:], np.matmul(a[:], b[:]), rtol=1e-6, atol=1e-6)
316+
with warnings.catch_warnings():
317+
warnings.simplefilter("ignore", RuntimeWarning)
318+
expected = np.matmul(a[:], b[:])
319+
np.testing.assert_allclose(c[:], expected, rtol=1e-6, atol=1e-6)
314320
finally:
315321
_toggle_miniexpr(old_flag)
316322

@@ -333,7 +339,10 @@ def unexpected_threadpool_limits(*args, **kwargs):
333339
warnings.simplefilter("ignore", RuntimeWarning)
334340
c = blosc2.matmul(a, b, chunks=(100, 100), blocks=(50, 50))
335341

336-
np.testing.assert_allclose(c[:], np.matmul(a[:], b[:]), rtol=1e-6, atol=1e-6)
342+
with warnings.catch_warnings():
343+
warnings.simplefilter("ignore", RuntimeWarning)
344+
expected = np.matmul(a[:], b[:])
345+
np.testing.assert_allclose(c[:], expected, rtol=1e-6, atol=1e-6)
337346
finally:
338347
_toggle_miniexpr(old_flag)
339348

@@ -355,7 +364,10 @@ def unexpected_threadpool_limits(*args, **kwargs):
355364
warnings.simplefilter("ignore", RuntimeWarning)
356365
c = blosc2.matmul(a, b, chunks=(100, 100), blocks=(50, 50))
357366

358-
np.testing.assert_allclose(c[:], np.matmul(a[:], b[:]), rtol=1e-6, atol=1e-6)
367+
with warnings.catch_warnings():
368+
warnings.simplefilter("ignore", RuntimeWarning)
369+
expected = np.matmul(a[:], b[:])
370+
np.testing.assert_allclose(c[:], expected, rtol=1e-6, atol=1e-6)
359371
finally:
360372
_toggle_miniexpr(old_flag)
361373

@@ -373,7 +385,10 @@ def test_matmul_fast_path_skips_blas_thread_limits_when_threadpoolctl_missing(mo
373385
warnings.simplefilter("ignore", RuntimeWarning)
374386
c = blosc2.matmul(a, b, chunks=(100, 100), blocks=(50, 50))
375387

376-
np.testing.assert_allclose(c[:], np.matmul(a[:], b[:]), rtol=1e-6, atol=1e-6)
388+
with warnings.catch_warnings():
389+
warnings.simplefilter("ignore", RuntimeWarning)
390+
expected = np.matmul(a[:], b[:])
391+
np.testing.assert_allclose(c[:], expected, rtol=1e-6, atol=1e-6)
377392
finally:
378393
_toggle_miniexpr(old_flag)
379394

0 commit comments

Comments
 (0)