summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_shape_base.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/tests/test_shape_base.py')
-rw-r--r--numpy/lib/tests/test_shape_base.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_shape_base.py b/numpy/lib/tests/test_shape_base.py
index 07960627b..76058cf20 100644
--- a/numpy/lib/tests/test_shape_base.py
+++ b/numpy/lib/tests/test_shape_base.py
@@ -644,6 +644,35 @@ class TestSqueeze:
class TestKron:
+ def test_basic(self):
+ # Using 0-dimensional ndarray
+ a = np.array(1)
+ b = np.array([[1, 2], [3, 4]])
+ k = np.array([[1, 2], [3, 4]])
+ assert_array_equal(np.kron(a, b), k)
+ a = np.array([[1, 2], [3, 4]])
+ b = np.array(1)
+ assert_array_equal(np.kron(a, b), k)
+
+ # Using 1-dimensional ndarray
+ a = np.array([3])
+ b = np.array([[1, 2], [3, 4]])
+ k = np.array([[3, 6], [9, 12]])
+ assert_array_equal(np.kron(a, b), k)
+ a = np.array([[1, 2], [3, 4]])
+ b = np.array([3])
+ assert_array_equal(np.kron(a, b), k)
+
+ # Using 3-dimensional ndarray
+ a = np.array([[[1]], [[2]]])
+ b = np.array([[1, 2], [3, 4]])
+ k = np.array([[[1, 2], [3, 4]], [[2, 4], [6, 8]]])
+ assert_array_equal(np.kron(a, b), k)
+ a = np.array([[1, 2], [3, 4]])
+ b = np.array([[[1]], [[2]]])
+ k = np.array([[[1, 2], [3, 4]], [[2, 4], [6, 8]]])
+ assert_array_equal(np.kron(a, b), k)
+
def test_return_type(self):
class myarray(np.ndarray):
__array_priority__ = 1.0