diff options
| author | Ganesh Kathiresan <ganesh3597@gmail.com> | 2022-03-26 10:25:51 +0530 |
|---|---|---|
| committer | Ganesh Kathiresan <ganesh3597@gmail.com> | 2022-03-26 10:25:55 +0530 |
| commit | 7916d567f2057b2d1e4d8d10f031c9b260c4df7f (patch) | |
| tree | 43db26211f7af216e1a0f0bb0df6765bb068db23 /numpy | |
| parent | 2d2e7b592326f61ee78fb9b420d550a3a789cc4c (diff) | |
| download | numpy-7916d567f2057b2d1e4d8d10f031c9b260c4df7f.tar.gz | |
BUG: Convert other inputs to array
Input such as matrix will cause a `ValueError` due to dim restrictions
Diffstat (limited to 'numpy')
| -rw-r--r-- | numpy/lib/shape_base.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py index b973afb0e..581da0598 100644 --- a/numpy/lib/shape_base.py +++ b/numpy/lib/shape_base.py @@ -1159,11 +1159,13 @@ def kron(a, b): bs = (1,)*max(0, nda-ndb) + bs # Compute the product - result = a.reshape(a.size, 1) * b.reshape(1, b.size) + a_arr = _nx.asarray(a).reshape(a.size, 1) + b_arr = _nx.asarray(b).reshape(1, b.size) + result = a_arr * b_arr # Reshape back result = result.reshape(as_+bs) - transposer = _nx.arange(nd*2).reshape([2, nd]).transpose().reshape(nd*2) + transposer = _nx.arange(nd*2).reshape([2, nd]).ravel(order='f') result = result.transpose(transposer) result = result.reshape(_nx.multiply(as_, bs)) |
