Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork11.9k
ENH: add mean keyword to std and var#24126
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
ENH: add mean keyword to std and var#24126
Conversation
mhvk left a comment
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.
This seems a good solution! I also like that now one can put in something else than the mean from the same data (which is often useful). But see the important comment about subclasses, plus a lot of more nitpicky ones.
Note that I'm surprisedMaskedArray does not work. Did you try again? Could you explain the problem? And is this a new problem, or did the functions not work even before? If they worked before, it would be much nicer to getMaskedArray right too.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
RonaldAJ commentedJul 6, 2023
I now added support for "mean" keyword on MaskedArrays. |
(numpy#24126 (comment)) The dispatcher returns all arguments that can, in principle, contain something that is an array and hence that, if not a regular ndarray, can allow the function to be dealt with another package (say, dask). Since mean can be an array, it should be added (most similar to where).
RonaldAJ commentedJul 6, 2023
@charris The cygwin test failed, but from the reported error I guess it has little to do with my change. Will it run again automagically? |
mattip commentedJul 6, 2023
I re-ran it manually. If it fails again we can ignore the failure. |
mattip left a comment
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.
Looks good,@mhvk already did all the review. Just a few nits about the release note and docstrings.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
RonaldAJ commentedJul 6, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
The output of the examples depends on platform and circumstances. Therefore testing based on example code gives errors:
Is there a method for handling this? |
RonaldAJ commentedJul 6, 2023
Added: #doctest: +SKIP |
mattip commentedJul 6, 2023
You could do something like |
RonaldAJ commentedJul 7, 2023
#doctest: +SKIP did the trick |
mattip commentedJul 7, 2023
RonaldAJ commentedJul 7, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I think that issue#23741 can be closed. |
Replaces previous pull request#23889 (ENH: Introduce new functions mean_std and mean_var.) after triage review.
Often when the standard deviation is needed the mean is also needed; the same holds for the variance and the mean. With the current code the mean is then calculated twice, this can be prevented if the functions calculating the variance or the standard deviation can use a precalculated mean. See ticket#23741.
These changes can be largely independent from those for ticket#13199, which suggests reducing memory usage by avoiding storing data-mean in a separate intermediate array.
See also:discussion on the mailing list