diff options
-rw-r--r-- | numpy/core/src/multiarray/ctors.c | 15 | ||||
-rw-r--r-- | numpy/core/tests/test_numeric.py | 2 |
2 files changed, 10 insertions, 7 deletions
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c index c4980d6c0..a292a1a82 100644 --- a/numpy/core/src/multiarray/ctors.c +++ b/numpy/core/src/multiarray/ctors.c @@ -1083,6 +1083,14 @@ PyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd, self->data = data; /* + * If the strides were provided to the function, need to + * update the flags to get the right CONTIGUOUS, ALIGN properties + */ + if (strides != NULL) { + PyArray_UpdateFlags(self, UPDATE_ALL); + } + + /* * call the __array_finalize__ * method if a subtype. * If obj is NULL, then call method with Py_None @@ -1092,13 +1100,6 @@ PyArray_NewFromDescr(PyTypeObject *subtype, PyArray_Descr *descr, int nd, func = PyObject_GetAttrString((PyObject *)self, "__array_finalize__"); if (func && func != Py_None) { - if (strides != NULL) { - /* - * did not allocate own data or funny strides - * update flags before finalize function - */ - PyArray_UpdateFlags(self, UPDATE_ALL); - } if (NpyCapsule_Check(func)) { /* A C-function is stored here */ PyArray_FinalizeFunc *cfunc; diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py index 77d174425..945e05001 100644 --- a/numpy/core/tests/test_numeric.py +++ b/numpy/core/tests/test_numeric.py @@ -1201,6 +1201,8 @@ class TestLikeFuncs(TestCase): assert_equal(dz.shape, d.shape) assert_equal(array(dz.strides)*d.dtype.itemsize, array(d.strides)*dz.dtype.itemsize) + assert_equal(d.flags.c_contiguous, dz.flags.c_contiguous) + assert_equal(d.flags.f_contiguous, dz.flags.f_contiguous) if dtype is None: assert_equal(dz.dtype, d.dtype) else: |