-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
ENH: Add support for np.dtype(ctypes.Union)
#12273
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
Can I work on this @eric-wieser ? Though I would require some guidance on how to work on this since I am begining with Open Source. |
You'll want to change these lines: numpy/numpy/core/_dtype_ctypes.py Lines 59 to 63 in 44810f0
Such that this test passes: numpy/numpy/core/tests/test_dtype.py Lines 810 to 825 in 44810f0
|
@euler16 - are you still working on this? If not I'd like to do it (I am also new to open source contributions). |
yes I am, I will send a PR soon |
Milestoned as 1.16 since the release notes added in #12392 claim this is already done! |
So this indeed is simple, I wrote the code, but then decided to see how it behaves with a Union containing a packed structure.
In my code I constructed the dtype from Union with As we are doing this to support ctypes the sensible choice is to still go with |
8 is correct - the struct has 3 bytes of padding inserted to meet the alignment requirements of uint32 |
I see now that if I also make the Union packed to 1 the size is 5. I assumed the rule to calculate the size was to take |
This ought to be as simple as constructing a dtype with all the fields overlapping.
This will go in
_dtype_ctypes.py
, and there's a test that needs activating intest_dtype.py
.The text was updated successfully, but these errors were encountered: