diff options
author | njsmith <njs@pobox.com> | 2012-11-12 00:21:55 -0800 |
---|---|---|
committer | njsmith <njs@pobox.com> | 2012-11-12 00:21:55 -0800 |
commit | cb41689b6150b0d325755b469fba975ce105361f (patch) | |
tree | b64dba7553dd099380884527085d4161612bd351 | |
parent | c479200918f034f587d24ba59c0550d2241ddf9a (diff) | |
parent | 7c90615c9a34c688e7b77986df7b3250501053f3 (diff) | |
download | numpy-cb41689b6150b0d325755b469fba975ce105361f.tar.gz |
Merge pull request #2722 from seberg/stride_set
BUG: Update aligned flag when setting strides attribute.
-rw-r--r-- | numpy/core/src/multiarray/getset.c | 3 | ||||
-rw-r--r-- | numpy/core/tests/test_regression.py | 7 |
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 |