diff options
| -rw-r--r-- | numpy/core/src/common/cblasfuncs.c | 2 | ||||
| -rw-r--r-- | numpy/core/tests/test_multiarray.py | 20 |
2 files changed, 19 insertions, 3 deletions
diff --git a/numpy/core/src/common/cblasfuncs.c b/numpy/core/src/common/cblasfuncs.c index c46843d63..39572fed4 100644 --- a/numpy/core/src/common/cblasfuncs.c +++ b/numpy/core/src/common/cblasfuncs.c @@ -197,7 +197,7 @@ _bad_strides(PyArrayObject *ap) if ((strides[i] < 0) || (strides[i] % itemsize) != 0) { return 1; } - if ((strides[i] == 0 && dims[i] >1)) { + if ((strides[i] == 0 && dims[i] > 1)) { return 1; } } diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index 703edb190..b64b70a94 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -2714,10 +2714,11 @@ class TestMethods(object): assert_equal(func(edf.T, edf), edtdf) @pytest.mark.parametrize('func', (np.dot, np.matmul)) - def test_no_dgemv(self, func): + @pytest.mark.parametrize('dtype', 'ifdFD') + def test_no_dgemv(self, func, dtype): # check vector arg for contiguous before gemv # gh-12156 - a = np.arange(8.0).reshape(2, 4) + a = np.arange(8.0, dtype=dtype).reshape(2, 4) b = np.broadcast_to(1., (4, 1)) ret1 = func(a, b) ret2 = func(a, b.copy()) @@ -2727,6 +2728,21 @@ class TestMethods(object): ret2 = func(b.T.copy(), a.T) assert_equal(ret1, ret2) + # check for unaligned data + dt = np.dtype(dtype) + a = np.zeros(8 * dt.itemsize // 2 + 1, dtype='int16')[1:].view(dtype) + a = a.reshape(2, 4) + b = a[0] + # make sure it is not aligned + assert_(a.__array_interface__['data'][0] % dt.itemsize != 0) + ret1 = func(a, b) + ret2 = func(a.copy(), b.copy()) + assert_equal(ret1, ret2) + + ret1 = func(b.T, a.T) + ret2 = func(b.T.copy(), a.T.copy()) + assert_equal(ret1, ret2) + def test_dot(self): a = np.array([[1, 0], [0, 1]]) b = np.array([[0, 1], [1, 0]]) |
