8000 masked-array median of array should be scalar · Issue #7835 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
masked-array median of array should be scalar #7835
@larrybradley

Description

@larrybradley

Related to #5969, #7592, #7635, #7654, I still find inconsistent behavior in numpy 1.11.1.
np.ma.median (with axis=None) returns a masked array instead of a scalar for all cases except when the input is a masked array that has a least one masked value. It's only for that case where a scalar is returned.

>>> data = np.arange(10)
>>> mask = np.zeros(10).astype(bool)
>>> np.ma.median(data)
masked_array(data = 4.5,
             mask = False,
       fill_value = 1e+20)

>>> np.ma.median(np.ma.masked_array(data, mask=False))
masked_array(data = 4.5,
             mask = False,
       fill_value = 1e+20)

>>> np.ma.median(np.ma.masked_array(data, mask=mask))
masked_array(data = 4.5,
             mask = False,
       fill_value = 1e+20)

>>> mask[0] = True
>>> np.ma.median(np.ma.masked_array(data, mask=mask))
5.0

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