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
Closed
@jeanconn

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.

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

      0