-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
BUG: fix for issue#7835 (ma.median of 1d) #7911
Conversation
Looks good to me, will merge in a bit. Thanks @skwbc ! |
@ahaldane Mind if I merge? |
@charris I was just about to, I just wanted to get the backport done first |
I went ahead with it :) Thanks @skwbc |
Great, thanks Allan. |
Backport #7911: BUG: fix for issue#7835 (ma.median of 1d)
return masked_array(np.median(getdata(a, subok=True), axis=axis, | ||
out=out, overwrite_input=overwrite_input, | ||
keepdims=keepdims), copy=False) | ||
if not hasattr(a, 'mask'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why was the count_nonzero removed?
its performance impact is practically zero but the gain on empty mask is huge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to have simplified the if-condition (that is, MaskedArray or others), and I just didn't know that np.median
is much faster than np.ma.extras._median
.
So, we should add or np.count_nonzero(a.mask) == 0
here.
Should I make pull request?
fixed bugs for #7835.
I used ma.extras._median for MaskedArray, because it works properly for 1D and 0D MaskedArray.
And, I added many tests for types of outputs of ma.median.