8000 numpy.average and numpy.mean give different results for masked arrays · Issue #8332 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

numpy.average and numpy.mean give different results for masked arrays #8332

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

Closed
quantology opened this issue Nov 29, 2016 · 2 comments
Closed

Comments

@quantology
Copy link
a = np.ma.array([10, 20, 30, 40, 50, 60, 70, 80, 90, -1])
log_a = np.log(a)
np.average(log_a), np.mean(log_a) # returns (3.452509331702788, 3.7250103685586535)

This can be fixed by changing https://github.com/numpy/numpy/blob/v1.11.0/numpy/lib/function_base.py#L921 from "np.asarray" to "np.asanyarray", but I didn't want to make a whole dev env just for that little fix.

@mhvk
Copy link
Contributor
mhvk commented Nov 29, 2016

Thanks for the report. This was a known annoyance that should be fixed in recent numpy (and will be available in numpy 1.13); see #8290.

@quantology
Copy link
Author

Oh thanks, didn't see that when I searched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0