summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBas van Beek <b.f.van.beek@vu.nl>2022-02-25 18:50:51 +0100
committerSebastian Berg <sebastianb@nvidia.com>2022-12-02 00:29:32 +0100
commitdb54e1d1451c2fa91dc74bd7e6e137e9d999d0eb (patch)
tree2554d42e00e7ee2c4bd92720fe290f13880cd151
parentde0521fc22e641be5e819a2fec785c6f89ebca8c (diff)
downloadnumpy-db54e1d1451c2fa91dc74bd7e6e137e9d999d0eb.tar.gz
TST: Add a dedicated `__imatmul__` test case for large matrices
-rw-r--r--numpy/core/tests/test_multiarray.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index 87a947313..775c06bac 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -7166,7 +7166,7 @@ class TestMatmulInplace:
DTYPES[f"{i}-{j}"] = (np.dtype(i), np.dtype(j))
@pytest.mark.parametrize("dtype1,dtype2", DTYPES.values(), ids=DTYPES)
- def test_matmul_inplace(self, dtype1: np.dtype, dtype2: np.dtype) -> None:
+ def test_basic(self, dtype1: np.dtype, dtype2: np.dtype) -> None:
a = np.arange(10).reshape(5, 2).astype(dtype1)
a_id = id(a)
b = np.ones((2, 2), dtype=dtype2)
@@ -7182,6 +7182,19 @@ class TestMatmulInplace:
else:
np.testing.assert_array_equal(a, ref)
+ def test_large_matrix(self) -> None:
+ a = np.arange(10**6).reshape(-1, 10).astype(np.float64)
+ a_id = id(a)
+ b = np.arange(10**2).reshape(10, 10)
+
+ ref = a @ b
+ a @= b
+
+ assert id(a) == a_id
+ assert a.dtype.type == np.float64
+ assert a.shape == (10**5, 10)
+ np.testing.assert_allclose(a, ref)
+
def test_matmul_axes():
a = np.arange(3*4*5).reshape(3, 4, 5)