summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2012-11-09 23:33:55 +0100
committerSebastian Berg <sebastian@sipsolutions.net>2012-11-09 23:33:55 +0100
commit7c90615c9a34c688e7b77986df7b3250501053f3 (patch)
tree590e591d90a68200e489ff5eb783496e5d2268f6 /numpy
parent75b8119f8145ab08a436ecfd7de868c6c6ba8f6d (diff)
downloadnumpy-7c90615c9a34c688e7b77986df7b3250501053f3.tar.gz
BUG: Update aligned flag when setting strides attribute.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/getset.c3
-rw-r--r--numpy/core/tests/test_regression.py7
2 files changed, 9 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/getset.c b/numpy/core/src/multiarray/getset.c
index 32212ebc4..acefa888d 100644
--- a/numpy/core/src/multiarray/getset.c
+++ b/numpy/core/src/multiarray/getset.c
@@ -149,7 +149,8 @@ array_strides_set(PyArrayObject *self, PyObject *obj)
goto fail;
}
memcpy(PyArray_STRIDES(self), newstrides.ptr, sizeof(npy_intp)*newstrides.len);
- PyArray_UpdateFlags(self, NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_F_CONTIGUOUS);
+ PyArray_UpdateFlags(self, NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_F_CONTIGUOUS |
+ NPY_ARRAY_ALIGNED);
PyDimMem_FREE(newstrides.ptr);
return 0;
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index 0f268fce8..38ab56eb6 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -1649,6 +1649,13 @@ class TestRegression(TestCase):
assert_equal(r[0:3:2]['f1'][0][()], r[0:3:2][0]['f1'][()])
assert_equal(r[0:3:2]['f1'][0].strides, r[0:3:2][0]['f1'].strides)
+ def test_alignment_update(self):
+ """Check that alignment flag is updated on stride setting"""
+ a = np.arange(10)
+ assert_(a.flags.aligned)
+ a.strides = 3
+ assert_(not a.flags.aligned)
+
def test_ticket_1770(self):
"Should not segfault on python 3k"
import numpy as np