Skip to content

Commit 1e62199

Browse files
author
Bas van Beek
committed
TST: Add a dedicated __imatmul__ test case for large matrices
1 parent 83be62b commit 1e62199

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

numpy/core/tests/test_multiarray.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6896,7 +6896,7 @@ class TestMatmulInplace:
68966896
DTYPES[f"{i}-{j}"] = (np.dtype(i), np.dtype(j))
68976897

68986898
@pytest.mark.parametrize("dtype1,dtype2", DTYPES.values(), ids=DTYPES)
6899-
def test_matmul_inplace(self, dtype1: np.dtype, dtype2: np.dtype) -> None:
6899+
def test_basic(self, dtype1: np.dtype, dtype2: np.dtype) -> None:
69006900
a = np.arange(10).reshape(5, 2).astype(dtype1)
69016901
a_id = id(a)
69026902
b = np.ones((2, 2), dtype=dtype2)
@@ -6912,6 +6912,19 @@ def test_matmul_inplace(self, dtype1: np.dtype, dtype2: np.dtype) -> None:
69126912
else:
69136913
np.testing.assert_array_equal(a, ref)
69146914

6915+
def test_large_matrix(self) -> None:
6916+
a = np.arange(10**6).reshape(-1, 10).astype(np.float64)
6917+
a_id = id(a)
6918+
b = np.arange(10**2).reshape(10, 10)
6919+
6920+
ref = a @ b
6921+
a @= b
6922+
6923+
assert id(a) == a_id
6924+
assert a.dtype.type == np.float64
6925+
assert a.shape == (10**5, 10)
6926+
np.testing.assert_allclose(a, ref)
6927+
69156928

69166929
def test_matmul_axes():
69176930
a = np.arange(3*4*5).reshape(3, 4, 5)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy