Skip to content

Commit

Permalink
Additional tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
fruchart committed May 13, 2019
1 parent e121691 commit 1bfb470
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion numpy/core/tests/test_multiarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -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):
Expand Down

0 comments on commit 1bfb470

Please sign in to comment.