summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2018-12-06 21:53:08 -0800
committermattip <matti.picus@gmail.com>2018-12-07 10:10:25 +0200
commit7e048696892ee72384858b20f7804326e66b7a0d (patch)
treef249482bbe4049fb1c3d6bddcab790e36a41d9ac
parentf7a9fac9031a4e6f2f6ec5c5093c9f754bcd7128 (diff)
downloadnumpy-7e048696892ee72384858b20f7804326e66b7a0d.tar.gz
STY, TST: fix formatting and add tests for other dtypes, unaligned data
-rw-r--r--numpy/core/src/common/cblasfuncs.c2
-rw-r--r--numpy/core/tests/test_multiarray.py20
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]])