-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
BUG: Unpickled void scalars should be contiguous #7141
Conversation
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 numpy#7140.
@@ -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; |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NPY_ARRAY_CARRAY
is C-contiguous and behaved: https://github.com/numpy/numpy/blob/master/numpy/core/include/numpy/ndarraytypes.h#L861
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Unpickled void scalars must be both aligned and writeable.
BUG: Unpickled void scalars should be contiguous
thanks! |
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.