Skip to content

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

Closed

Description

@jeanconn

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.

Activity

  1. rgommers commented on Jun 15, 2015

    @rgommers
    Member

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

  2. taldcroft commented on Jun 20, 2015

    @taldcroft

    I think this was introduced by #4760 @juliantaylor.

  3. AmitAronovitch commented on Apr 30, 2016

    @AmitAronovitch
    Contributor

    please review PR #7592

  4. added a commit that references this issue on May 21, 2016
    bb46a49
  5. added a commit that references this issue on May 22, 2016
    c1153b8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions