8000 Regression in ma.median handling of nan values, and calculates incorrect value · Issue #8340 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
Regression in ma.median handling of nan values, and calculates incorrect value #8340
Closed
@mwcraig

Description

@mwcraig

The handling of nan values in masked arrays passed in to ma.median changed some time between 1.10.2 and 1.11.2, and the value returned in 1.11.2 is incorrect. In 1.10.2 nan was returned in this case. In 1.11.2 an (incorrect) numerical result is returned.

This example demonstrates both problems:

import numpy as np
dm = np.ma.array([1, np.nan, 3])
np.ma.median(dm)

In numpy 1.10.2 the output is as expected: nan

In numpy 1.11.2 the output is incorrect (not nan and not the correct numerical value ignoring the nan):

masked_array(data = 3.0,
             mask = False,
       fill_value = 1e+20)

Based on test failures we are seeing in astropy/astropy#5232, the issue continues in 1.12.0b1.

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