-
-
Notifications
You must be signed in to change notification settings - Fork 11k
.view
no longer works on field selections of structured arrays
#10409
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
Yeah, I explicitly mentioned this in the 1.13 and 1.14 release notes. Actually, since we have not provided a |
Fixes numpy#10387 Fixes numpy#10344 Fixes numpy#10409
Fixes numpy#10387 Fixes numpy#10344 Fixes numpy#10409
Fixes numpy#10387 Fixes numpy#10344 Fixes numpy#10409
Fixes numpy#10387 Fixes numpy#10344 Fixes numpy#10409
Should slicing a dtype shrink the itemsize? ie, if a dtype has fields A consequence of this would be that the resulting array would be non-"contiguous" |
You mean like On the other hand sometimes it's better to fail more rather than less often. If people get errors about viewing multifield slices more easily, maybe that's better than hiding it in special cases. Then people are forced to write code that is safe in all situations, for example using |
Even the less objectionable case where the dtypes match
Essentially, I'm proposing a |
Right, but it still bothers me that Also, I'm pretty sure that even with this >>> a = np.ones((10,3), dtype='i4')
>>> a[:,0:2].view('i8')
ValueError: To change to a dtype of a different size, the array must be C-contiguous
>>> a[:,0:2].view(('i4', 2))
ValueError: Changing the dtype to a subarray type is only supported if the total itemsize is unchanged |
@ahaldane Is this now fixed for 1.15? |
Yes, I just checked master. Master now gives the 1.13 behavior, just with an updated futurewarning. I'm not sure we should close, since this issue will pop up again in 1.16. |
Good, I'll just update the milestone :). |
I ran across code in |
Hmm in my opinion #8100 was mistakenly closed, since I accidentally used the word "fix" in a sentence in #10411's description. I am also not sure we've made a decision about structured views. As far as I am aware (I was out for a bit so may have missed it) I think we are still considering turning it into a view. #10411 just pushed off the decision/implementation. |
Uh oh!
There was an error while loading. Please reload this page.
See this SO question:
vs
Since we now return a view rather than a copy from
arr[fields]
, we end up with a dtype with padding. This prevents.view
being called, even though the memory layout is sufficient to allow itThe text was updated successfully, but these errors were encountered: