-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
structured dtype descr method returns incorrect descriptor when void space is at the end of dtype built through a dict #6359
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
Comments
dtype.descr returns void fields to explain the padding part of the dtype. The last void field for the itemsize itself was however not included. Closes numpygh-6359
Uploaded a PR to fix this, I wonder if the extra void fields are not somewhat annoying in any case and if there is not a better way to do this, though? |
Yes, that is indeed a bug, but I'd also like to warn you that there is a deeper bug here.
It is used in 2 places in numpy: 1. In the Array Interface (for serializing) , 2. In the Now, unfortunately currently numpy cannot reliably convert @ikehall, unfortunately this means numpy probably currently cannot do what you want (though I encourage you to check to be sure). Numpy knows how to serialize your array, but it probably currently cannot deserialize it due to a bug (in addition to the bug you just found) |
Thank you for bringing that to my attention. For my purposes, the fix for this bug fixes my problems completely. The other bugs in dtype.descr seem to all be related to automatic naming of unnamed and invisible fields. As my fields are all either named (with names other than 'f1', 'f2', etc...) or 'invisible', it doesn't really matter to me if they come back on deserialization with automatically generated names, because I am not going to use them, and further, when I ultimately save the array, I discard the dtype information and just save the string of bytes. (Because I am saving to an industry-defined standard, and not np.save) I agree that those are bugs, and could affect me if I relied on automatic field naming, or named my fields badly, but currently this is not the case for me. |
dtype.descr returns void fields to explain the padding part of the dtype. The last void field for the itemsize itself was however not included. Closes numpygh-6359
Using python 2.7.10, numpy 1.9.2
If I define a structured dtype in the following manner:
And I then try to create a new dtype from this dtypes descr:
Then the two dtypes will not have the same itemsize
Examining the descr of my_dtype, we see that it is leaving off the 4 void bytes at the end
What should happen instead:
This has relevance for use of structured arrays with IPython.parallel, as this is how structured arrays are reconstructed when serialized and sent to engines in IPython.parallel. A work-around for the user of course is to define some field that marks the end of the structured data, but it seems that this should not be necessary.
The text was updated successfully, but these errors were encountered: