From 1bfb470031fdbf326c60a27cb4b8032e6c721756 Mon Sep 17 00:00:00 2001 From: Michel Fruchart Date: Sun, 12 May 2019 20:27:44 -0500 Subject: [PATCH] Additional tests. --- numpy/core/tests/test_multiarray.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index 8ebefd396bdc..de97d2ec0bda 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -6028,7 +6028,7 @@ def test_matmul_object(self): f = np.vectorize(fractions.Fraction) def random_ints(): - return np.random.randint(1000, size=(10, 3, 3)) + return np.random.randint(1, 1000, size=(10, 3, 3)) M1 = f(random_ints(), random_ints()) M2 = f(random_ints(), random_ints()) @@ -6044,6 +6044,25 @@ def test_matmul_object_type_scalar(self): res = self.matmul(v, v) assert_(type(res) is F) + def test_matmul_empty(self): + a = np.empty((3, 0), dtype=object) + b = np.empty((0, 3), dtype=object) + c = np.zeros((3, 3)) + assert_array_equal(np.matmul(a, b), c) + + def test_matmul_exception_multiply(self): + with assert_raises(TypeError): + a = np.full((3,3), None) + b = np.matmul(a, a) + + def test_matmul_exception_add(self): + class multiply_not_add(): + def __mul__(self, other): + return self + with assert_raises(TypeError): + a = np.full((3,3), multiply_not_add()) + b = np.matmul(a, a) + if sys.version_info[:2] >= (3, 5):