8000 BUG: np.ma.median returns wrong values for even number of elements · Issue #8409 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
BUG: np.ma.median returns wrong values for even number of elements #8409
Closed
@mhvk

Description

@mhvk

Tests in astropy (astropy/astropy#5629) uncovered a bug in np.ma.median for the case where the median should be the mean of the two entries nearest the median:

np.ma.median(np.ma.MaskedArray([1., 1.]))
# 2.0
np.ma.median(np.ma.MaskedArray([1., 1., 1.]))
# 1.0
np.ma.median(np.ma.MaskedArray([0., 1., 1., 5.]))
# 2.0

The bug is not present in 1.11.2.

I have not yet investigated where the problem occurs, as it may be that this immediately rings a bell for @juliantaylor, who last seems to have committed to np.ma.extras

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0