8000 BUG: Unpickled void scalars should be contiguous by gmarkall · Pull Request #7141 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Unpickled void scalars should be contiguous #7141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion numpy/core/src/multiarray/scalarapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reason you removed NPY_ARRAY_BEHAVED? (aligned and writeable)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, can you please make sure there is a test for this as well though, or add one if there is not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can - I will look at this now.

Copy link
Contributor Author

Removing the aligned and writeable flags didn't cause any test failures, so I've added checks for both of them to the test_pickle_3 test as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some alignment features only matter on Sun hardware. I don't know if that affects this or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have access to any Sun hardware (I presume SPARC machines?) but I think I've avoided changing the aligned flag here - is there anything else I can look into related to this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that should't be necessary, alignment should be handled correctly and if not well deal with it when it causes a problem
most platforms don't care about alignment anyway, at worst you have software handling on those and some slowdown which is irrelevant for scalars.

swap = 0;
if (PyDataType_HASFIELDS(descr)) {
if (base) {
Expand Down
9 changes: 9 additions & 0 deletions numpy/core/tests/test_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ def test_pickle_2(self):
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)
assert_(pa.flags.writeable)
assert_(pa.flags.aligned)

def test_objview_record(self):
# https://github.com/numpy/numpy/issues/2599
dt = np.dtype([('foo', 'i8'), ('bar', 'O')])
Expand Down
0