summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraham Markall <graham.markall@continuum.io>2016-01-29 11:53:30 +0000
committerGraham Markall <graham.markall@continuum.io>2016-01-29 12:20:49 +0000
commit38fdd765536d868101167474d87e307167e49fb9 (patch)
tree1294f9b60e39194d7332976673946fb8dcada5ec
parent22176f9969b526d696fa905ba74ed6c5e30f43f3 (diff)
downloadnumpy-38fdd765536d868101167474d87e307167e49fb9.tar.gz
BUG: Unpickled void scalars should be contiguous
Void scalars are both C- and Fortran-contiguous, so pickling and unpickling them should result in a new void scalar that also has these flags set. Fixes #7140.
-rw-r--r--numpy/core/src/multiarray/scalarapi.c2
-rw-r--r--numpy/core/tests/test_records.py7
2 files changed, 8 insertions, 1 deletions
diff --git a/numpy/core/src/multiarray/scalarapi.c b/numpy/core/src/multiarray/scalarapi.c
index 71a82d7a0..85824f2ce 100644
--- a/numpy/core/src/multiarray/scalarapi.c
+++ b/numpy/core/src/multiarray/scalarapi.c
@@ -799,7 +799,7 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)
Py_INCREF(descr);
vobj->obval = NULL;
Py_SIZE(vobj) = itemsize;
- vobj->flags = NPY_ARRAY_BEHAVED | NPY_ARRAY_OWNDATA;
+ vobj->flags = NPY_ARRAY_CARRAY | NPY_ARRAY_F_CONTIGUOUS | NPY_ARRAY_OWNDATA;
swap = 0;
if (PyDataType_HASFIELDS(descr)) {
if (base) {
diff --git a/numpy/core/tests/test_records.py b/numpy/core/tests/test_records.py
index 9fbdf51d6..e46cf90e1 100644
--- a/numpy/core/tests/test_records.py
+++ b/numpy/core/tests/test_records.py
@@ -299,6 +299,13 @@ class TestRecord(TestCase):
assert_equal(a, pickle.loads(pickle.dumps(a)))
assert_equal(a[0], pickle.loads(pickle.dumps(a[0])))
+ def test_pickle_3(self):
+ # Issue #7140
+ a = self.data
+ pa = pickle.loads(pickle.dumps(a[0]))
+ assert_(pa.flags.c_contiguous)
+ assert_(pa.flags.f_contiguous)
+
def test_objview_record(self):
# https://github.com/numpy/numpy/issues/2599
dt = np.dtype([('foo', 'i8'), ('bar', 'O')])