diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2022-09-22 14:04:13 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-22 14:04:13 -0500 |
commit | 88c1a4fefa0687193e3944416fea7c311caceb39 (patch) | |
tree | 49ca36298271dee17ac70dfe6b78e120699adc18 /numpy/lib | |
parent | d23050a12984c3d881356f0aea166f579b755de9 (diff) | |
parent | 0815a8c8a31d0d16e3011db8f72cfdc750161c76 (diff) | |
download | numpy-88c1a4fefa0687193e3944416fea7c311caceb39.tar.gz |
Merge pull request #22319 from sjtechdev/21257/add_kron_functional_tests
TST: add functional tests for kron
Diffstat (limited to 'numpy/lib')
-rw-r--r-- | numpy/lib/tests/test_shape_base.py | 29 |
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 |