summaryrefslogtreecommitdiff
path: root/numpy/linalg/tests
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2013-10-12 22:57:22 +0300
committerPauli Virtanen <pav@iki.fi>2013-10-12 23:07:01 +0300
commit984854aa605b5b4d5afe630e1879aa83845b11fb (patch)
tree324e8b43ae7968caf9a636dc7d88b99f232cc455 /numpy/linalg/tests
parentc9ed04a5a72fa488a203a7c82cc73f390c3afe8b (diff)
downloadnumpy-984854aa605b5b4d5afe630e1879aa83845b11fb.tar.gz
BUG: linalg: don't tell BLAS to use zero strides
At least OSX Accelerate fails for this case.
Diffstat (limited to 'numpy/linalg/tests')
-rw-r--r--numpy/linalg/tests/test_linalg.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/numpy/linalg/tests/test_linalg.py b/numpy/linalg/tests/test_linalg.py
index aefb61b14..d40157904 100644
--- a/numpy/linalg/tests/test_linalg.py
+++ b/numpy/linalg/tests/test_linalg.py
@@ -105,6 +105,9 @@ SQUARE_CASES = [
LinalgCase("8x8",
np.random.rand(8, 8),
np.random.rand(8)),
+ LinalgCase("1x1",
+ np.random.rand(1, 1),
+ np.random.rand(1)),
LinalgCase("nonarray",
[[1, 2], [3, 4]],
[2, 1]),
@@ -150,6 +153,12 @@ NONSQUARE_CASES = [
LinalgCase("8x11",
np.random.rand(8, 11),
np.random.rand(11)),
+ LinalgCase("1x5",
+ np.random.rand(1, 5),
+ np.random.rand(5)),
+ LinalgCase("5x1",
+ np.random.rand(5, 1),
+ np.random.rand(1)),
]
HERMITIAN_CASES = [
@@ -177,7 +186,10 @@ HERMITIAN_CASES = [
None),
LinalgCase("hmatrix_a_and_b",
matrix([[1., 2.], [2., 1.]]),
- None)
+ None),
+ LinalgCase("hmatrix_1x1",
+ np.random.rand(1, 1),
+ None),
]
@@ -247,6 +259,24 @@ def _stride_comb_iter(x):
assert np.all(xi == x)
yield xi, "stride_" + "_".join(["%+d" % j for j in repeats])
+ # generate also zero strides if possible
+ if x.ndim >= 1 and x.shape[-1] == 1:
+ s = list(x.strides)
+ s[-1] = 0
+ xi = np.lib.stride_tricks.as_strided(x, strides=s)
+ yield xi, "stride_xxx_0"
+ if x.ndim >= 2 and x.shape[-2] == 1:
+ s = list(x.strides)
+ s[-2] = 0
+ xi = np.lib.stride_tricks.as_strided(x, strides=s)
+ yield xi, "stride_xxx_0_x"
+ if x.ndim >= 2 and x.shape[:-2] == (1, 1):
+ s = list(x.strides)
+ s[-1] = 0
+ s[-2] = 0
+ xi = np.lib.stride_tricks.as_strided(x, strides=s)
+ yield xi, "stride_xxx_0_0"
+
for src in (SQUARE_CASES,
NONSQUARE_CASES,
HERMITIAN_CASES,