DEP,BUG: Coercion/cast of array to a subarray dtype will be fixed#17596
Conversation
760be52 to
81b8611
Compare
There was a problem hiding this comment.
To be clear, the first case here previously returned [3, uninitialized, uninitialized], while the second case actually did the right thing. So I considered that a simple bugfix here.
|
@seberg - this looks quite good. With this change, will |
This currently appends the subarray dtype dimensions first and then tries to assign to the result array which uses incorrect broadcasting (broadcasting against the subarray dimensions instead of repeating each element according to the subarray dimensions). This also fixes the python scalar pathway `np.array(2, dtype="(2)f4,")` which previously only filled the first value. I consider that a clear bug fix. Closes numpygh-17511
22a10b1 to
fcc3940
Compare
|
Thanks for taking a look! I am scanning the full input for array(-like) objects in the code, it is a bit annoying, but feel this is fringe enough that it is OK. Since I look for array likes, it will not trigger for empty sequences. There are cases where a warning will be given even though nothing will change, e.g. |
|
OK, that sounds good! And I can see that you cannot do everything... But perhaps good to add a test for the empty list case, just in case? |
|
Oh, seems I accidentally deleted that sentence snippet: I had just added the test. |
|
Thanks @seberg |
This currently appends the subarray dtype dimensions first and then
tries to assign to the result array which uses incorrect broadcasting
(broadcasting against the subarray dimensions instead of repeating
each element according to the subarray dimensions).
This also fixes the python scalar pathway
np.array(2, dtype="(2)f4,")which previously only filled the first value. I consider that a clear
bug fix.
Closes gh-17511