Repository navigation
DOC: Document ma.filled behavior with non-scalar fill_value. - #10504
Closed
patricknaughton01 wants to merge 1 commit into
Closed
patricknaughton01 wants to merge 1 commit into
patricknaughton01 wants to merge 1 commit into
Conversation
Add documentation to numpy.ma.filled to indicate that `fill_value` can take on any type that can be broadcast to the same type as `a`.
charris
reviewed
Feb 3, 2018
| a : MaskedArray or array_like | ||
| An input object. | ||
| fill_value : scalar, optional | ||
| fill_value : scalar or shape that can be broadcast to same shape as `a`, optional |
Member
There was a problem hiding this comment.
This isn't very clear. Maybe something like
fill_value : {None, array_like}, optional
If array_like, the resulting ndarray must be broadcastable
over `a`. The default is None.
Member
|
I'm wary of documenting this if it's not deliberate or well-supported behavior. Arrays with non-scalar fill values also behave poorly upon slicing: >>> m = np.ma.array(np.zeros((3, 5)), mask=True, fill_value=np.arange(5))
>>> m.filled()
array([[0., 1., 2., 3., 4.],
[0., 1., 2., 3., 4.],
[0., 1., 2., 3., 4.]])
>>> m[:, :2].filled()
ValueError: could not broadcast input array from shape (5) into shape (3,2)Fixing this requires copying parts of xarray, which seems super out of scope. I think it would be better to just advise using possibly even in a deprecation warning. |
Member
|
@eric-wieser Hmm, the handling of scalars and |
Member
|
Closing, this has been fixed in gh-13698. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add documentation to numpy.ma.filled to indicate that
fill_valuecantake on any type that can be broadcast to the same type as
a.Closes #4363