question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Regression in ma.median handling of nan values, and calculates incorrect value

See original GitHub issue

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 https://github.com/astropy/astropy/pull/5232, the issue continues in 1.12.0b1.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:40 (40 by maintainers)

github_iconTop GitHub Comments

1reaction
charriscommented, Dec 5, 2016

I’m going to do a 11.3 for the file append issue, so If you fix it up for 1.12 I might put it in 1.11.3 also.

1reaction
juliantaylorcommented, Dec 5, 2016

I think it would be good to squeeze it into 1.12, I’ll have a look today.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's the best way to handle NaN values?
KNN and MICE imputations use the whole dataset to replace the NaN value, while median and mean uses only the column of the...
Read more >
How to Handle Missing Data with Python
The simplest strategy for handling missing data is to remove records that contain a missing value. The simplest approach for dealing with ...
Read more >
Handling missing values with R - Julie Josse
To do so we will perform regression to explain maxO3 in function of all the other variables. This data is incomplete (there are...
Read more >
Chapter 8. Regression Basics - BC Open Textbooks
Regression analysis, like most multivariate statistics, allows you to infer ... Understanding that there is a distribution of y (apartment price) values at ......
Read more >
Dealing with Missing Values for Data Science Beginners
Handling missing data is not a simple job in the field of data analysis. Approaches may lead to the Good, the Bad, and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found