8000 np.ma.median returns masked_array; doesn't match example in docs · Issue #5969 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

np.ma.median returns masked_array; doesn't match example in docs #5969

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
jeanconn opened this issue Jun 15, 2015 · 3 comments
Closed

np.ma.median returns masked_array; doesn't match example in docs #5969

jeanconn opened this issue Jun 15, 2015 · 3 comments

Comments

@jeanconn
Copy link

From the examples

    Examples
    --------
    >>> x = np.ma.array(np.arange(8), mask=[0]*4 + [1]*4)
    >>> np.ma.extras.median(x)
    1.5

On CentOS 6 64 with a conda python and numpy 1.9.2

# python
Python 2.7.9 |Continuum Analytics, Inc.| (default, Mar  9 2015, 16:20:48) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
>>> import numpy as np
>>> np.__version__
'1.9.2'
>>> x = np.ma.array(np.arange(8), mask=[0]*4 + [1]*4)
>>> np.ma.extras.median(x)
masked_array(data = [1.5],
             mask = [False],
       fill_value = 1e+20)

In addition to not matching the Example, I think this is also inconsistent with the return type text and with the behavior of other masked aggregate functions (np.ma.mean) which seems to just return a np.float64 on the same x.

@rgommers
Copy link
Member

That indeed looks inconsistent, would be good to make the behavior match the example again.

@taldcroft
Copy link

I think this was introduced by #4760 @juliantaylor.

@AmitAronovitch
Copy link
Contributor

please review PR #7592

charris pushed a commit to charris/numpy that referenced this issue May 22, 2016
Fixes numpy#5969.
Performance fix numpy#4760 had caused wrong shaped results in the 1D case.
This fix restores the original 1D behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0