BUG: fix infinite recursion in np.ma.flatten_structured_array#30855
BUG: fix infinite recursion in np.ma.flatten_structured_array#30855seberg merged 2 commits intonumpy:mainfrom
Conversation
|
Thanks! This is always a bit trickier with regressions in masked arrays and not being quite sure how this is used. I actually, think a slightly more maximal approach may be nice, but with a release note and no backporting. The more maximal approach would be to do the following (sorry, it is a bit more complicated, in the sense of changing the pattern!):
This approach will also change the result dtype, e.g. for a struct array of The |
Thanks for replying. |
|
#30872 fixes the test failures seen here, a rebase should fix it. |
numpy/ma/core.py
Outdated
| """ | ||
| for elm in iter(iterable): | ||
| if hasattr(elm, '__iter__'): | ||
| if not np.ndim(elm) == 0: |
There was a problem hiding this comment.
If we do this minimal thing, I am tempted to just add not isinstance(elem, (str, bytes)), TBH.
np.ndim() may be slow and I don't consider this the true fix either way, so I am probably more happy with a practical 98% fix than something that looks like a neat fix but isn't really.
|
Thanks, let's get this minimal approach in then! FWIW, I think the real fix is still to revamp the approach to walk the dtype fields. |
BUG: fix infinite recursion in np.ma.flatten_structured_array (#30855)
Towards resolving #29349
Avoids recursion for both strings and objects.