summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authornjsmith <njs@pobox.com>2012-09-21 07:46:37 -0700
committernjsmith <njs@pobox.com>2012-09-21 07:46:37 -0700
commitfd63e8f7dcbab6b7c66bd4be400153592319e7b3 (patch)
tree9991b532db98c26031d2e12bf3e9527c76d02249 /numpy
parentc8ed8baac1921be53d31d014760f9b278d4b9c2e (diff)
parent380ce9436c3c94de60ef9ada40f3917990ed1472 (diff)
downloadnumpy-fd63e8f7dcbab6b7c66bd4be400153592319e7b3.tar.gz
Merge pull request #420 from seberg/contig
Reset flags when Axes are removed. Array might now be 1D, or removed axe...
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/src/multiarray/shape.c3
-rw-r--r--numpy/core/tests/test_regression.py16
2 files changed, 19 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/shape.c b/numpy/core/src/multiarray/shape.c
index 067232632..684d42713 100644
--- a/numpy/core/src/multiarray/shape.c
+++ b/numpy/core/src/multiarray/shape.c
@@ -1186,4 +1186,7 @@ PyArray_RemoveAxesInPlace(PyArrayObject *arr, npy_bool *flags)
/* The final number of dimensions */
fa->nd = idim_out;
+
+ /* Update contiguous flags */
+ PyArray_UpdateFlags(arr, NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_F_CONTIGUOUS);
}
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index 53471b2c2..696bae622 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -1528,6 +1528,22 @@ class TestRegression(TestCase):
assert_(np.array(np.float32(1.0)).flags.c_contiguous)
assert_(np.array(np.float32(1.0)).flags.f_contiguous)
+ def test_squeeze_contiguous(self):
+ """Similar to GitHub issue #387"""
+ a = np.zeros((1,2)).squeeze()
+ b = np.zeros((2,2,2), order='F')[:,:,::2].squeeze()
+ assert_(a.flags.c_contiguous)
+ assert_(a.flags.f_contiguous)
+ assert_(b.flags.f_contiguous)
+
+ def test_reduce_contiguous(self):
+ """GitHub issue #387"""
+ a = np.add.reduce(np.zeros((2,1,2)), (0,1))
+ b = np.add.reduce(np.zeros((2,1,2)), 1)
+ assert_(a.flags.c_contiguous)
+ assert_(a.flags.f_contiguous)
+ assert_(b.flags.c_contiguous)
+
def test_object_array_self_reference(self):
# Object arrays with references to themselves can cause problems
a = np.array(0, dtype=object)