-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Indexing multidimensional structured masked array fails to translate fill_value correctly, leading to broadcasting errors ValueError when calling .filled() #6723
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
Would it be sensible to require that a |
A more commonly used method through to which this propagates is |
@charris The reason dimensionality of the |
More compactly put: (Seems dtypes have a |
Fix issue numpy#6723. Given an exotic masked structured array, where one of the fields has a multidimensional dtype, make sure that, when accessing this field, the fill_value still makes sense. As it stands prior to this commit, the fill_value will end up being multidimensional, possibly with a shape incompatible with the mother array, which leads to broadcasting errors in methods such as .filled(). This commit uses the first element of this multidimensional fill value as the new fill value. When more than one unique value existed in fill_value, a warning is issued. Also add a test to verify that fill_value.ndim remains 0 after indexing.
…rray_fillvalue BUG/TST: Fix for #6723 including test: force fill_value.ndim==0
Fix issue numpy#6723. Given an exotic masked structured array, where one of the fields has a multidimensional dtype, make sure that, when accessing this field, the fill_value still makes sense. As it stands prior to this commit, the fill_value will end up being multidimensional, possibly with a shape incompatible with the mother array, which leads to broadcasting errors in methods such as .filled(). This commit uses the first element of this multidimensional fill value as the new fill value. When more than one unique value existed in fill_value, a warning is issued. Also add a test to verify that fill_value.ndim remains 0 after indexing.
Since the above rebases are confusing, the PR for this was #6728 |
This has been fixed (I assume by #6728), so closing. |
When using a structured masked array where one of the structure elements has a multidimensional dtype, indexing does not correctly set the
fill_value
attribute for the new masked array. This leads to afill_value
with a shape that is incompatible with.data
or.mask
, which inevitably leads to broadcasting problems whenfill_value
is used, such as when callingfilled()
:Indeed, the fill value doesn't change upon indexing the masked array — only its dtype does:
The text was updated successfully, but these errors were encountered: