Skip to content

masked-array median of array should be scalar #7835

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

Activity

  1. changed the title [-]masked-array median of 1d array should be scalar[/-] [+]masked-array median of array should be scalar[/+] on Jul 14, 2016
  2. added this to the milestone on Jul 20, 2016
  3. ahaldane commented on Aug 8, 2016

    @ahaldane
    Member

    Fixed by #7911

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