-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
BUG: Incorrect assignment to recarray items #3561
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
Raising an error for non supported operations. Also adapting related statement in test. Resolves numpy#3126 and numpy#3561.
Looks to be a duplicate of #3126. |
This is a bug in ndarray, nor recarray. For example:
In particular, I think it is a bug in ndarray.setfield bwing too permissive. Maybe this is what the user should be writing:?
I think ndarray.getfield and ndarray.setfield are buggy (eg, see the segfauly I cause in #3256 (comment)). I think it might be possible to make them simply call np.view in the right way to solve all these problems. But it may need to wait until some other issues with views are solved (see #5508 #3256 #3286 #2599) |
Oh, I missed that link to your pull request above. I took at your pull request and it seems like a good fix for now. I tested it and it worked, and the code looks OK (though I am a numpy code novice). What I mentioned about waiting is that I think this problem (plus others) might be solved by making getfield and setfield go through the 'view' machinery. This way all the checks that happen for views would automatically happen for get/setfield. In #4556 you gave this example:
I imagine setfield could do something like:
Taking a view would also solve the following problem:
Now I admit I have not looked deeply into the assignment machinery yet so maybe this isn't possible... In my opinion your pull should be merged for now. I mentioned "waiting" only with repsect to trying out these additional ideas about views. |
This commit modifiesvoidtype_get/setfield to that they call the ndarray get/setfield. This solves bugs related to void-scalar assignment. This fixes issues numpy#3126, numpy#3561.
Assigning to field of recarray is not working correctly. Example script is below.
The text was updated successfully, but these errors were encountered: