8000 Regression in numpy master: np.ma.median with axis returns wrong result when there is only one non-masked value · Issue #8029 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
Regression in numpy master: np.ma.median with axis returns wrong result when there is only one non-masked value #8029
Closed
@lesteve

Description

@lesteve

Snippet:

import numpy as np

masked_arr = np.ma.masked_array([[5.], [0.], [0.]],
                                [[False], [True], [True]])
print('masked_arr\n', masked_arr)
print('median\n', np.ma.median(masked_arr, axis=0))

Output:

numpy 1.11.1

 [[5.0]
 [--]
 [--]]
median
 [ 5.]

The median is 5. as expected since this is the only non-masked value.

numpy master

masked_arr
 [[5.0]
 [--]
 [--]]
median
 [2.5]

The median is 2.5, unexpectedly.

FWIW, the result is fine when not using an axis argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0