summaryrefslogtreecommitdiff
path: root/numpy/core/tests
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2019-09-12 14:29:21 -0700
committerGitHub <noreply@github.com>2019-09-12 14:29:21 -0700
commit00066746f9c388f468f0683003f30948b80443b0 (patch)
tree740b7b5c6d4002125fab2270a40c1200ebf756c9 /numpy/core/tests
parent46621d2ff1b3234bfc8e89497d4ddb82e0aa92f0 (diff)
parent7ff2f96b711c380eb39eaff2d3ac776f4d55c324 (diff)
downloadnumpy-00066746f9c388f468f0683003f30948b80443b0.tar.gz
Merge pull request #14464 from mattip/matmul-bool
BUG: add a specialized loop for boolean matmul
Diffstat (limited to 'numpy/core/tests')
-rw-r--r--numpy/core/tests/test_multiarray.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index 1b698b517..05f01ad82 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -6276,6 +6276,23 @@ class TestMatmul(MatmulCommon):
with assert_raises(TypeError):
b = np.matmul(a, a)
+ def test_matmul_bool(self):
+ # gh-14439
+ a = np.array([[1, 0],[1, 1]], dtype=bool)
+ assert np.max(a.view(np.uint8)) == 1
+ b = np.matmul(a, a)
+ # matmul with boolean output should always be 0, 1
+ assert np.max(b.view(np.uint8)) == 1
+
+ rg = np.random.default_rng(np.random.PCG64(43))
+ d = rg.integers(2, size=4*5, dtype=np.int8)
+ d = d.reshape(4, 5) > 0
+ out1 = np.matmul(d, d.reshape(5, 4))
+ out2 = np.dot(d, d.reshape(5, 4))
+ assert_equal(out1, out2)
+
+ c = np.matmul(np.zeros((2, 0), dtype=bool), np.zeros(0, dtype=bool))
+ assert not np.any(c)
if sys.version_info[:2] >= (3, 5):