summaryrefslogtreecommitdiff
path: root/numpy/ma/extras.py
diff options
context:
space:
mode:
authorSimon Gibbons <simongibbons@gmail.com>2015-02-21 18:25:28 +0000
committerSimon Gibbons <simongibbons@gmail.com>2015-02-21 18:25:28 +0000
commit9df514382c0b7c8fdaa979f66054285d69afee4d (patch)
treeb5fe026cb1c7c939883076bb73280ba6d2ff8e38 /numpy/ma/extras.py
parentd770034969e35907e7497d5fe9053df4bdac2fd2 (diff)
downloadnumpy-9df514382c0b7c8fdaa979f66054285d69afee4d.tar.gz
BUG: numpy.ma.polyfit masks NaNs incorrectly
This fixes the incorrect handing of masked NaNs by ``np.ma.polyfit``. Instead of passing the mask into ``np.polyfit`` by setting the weight of the masked points to zero, the subset of elements of which are to be fitted are passed instead. Closes #5591
Diffstat (limited to 'numpy/ma/extras.py')
-rw-r--r--numpy/ma/extras.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py
index 58f3f3067..b6082180a 100644
--- a/numpy/ma/extras.py
+++ b/numpy/ma/extras.py
@@ -1921,12 +1921,12 @@ def polyfit(x, y, deg, rcond=None, full=False, w=None, cov=False):
m = mask_or(m, getmask(w))
if m is not nomask:
+ not_m = ~m
if w is not None:
- w = ~m*w
- else:
- w = ~m
-
- return np.polyfit(x, y, deg, rcond, full, w, cov)
+ w = w[not_m]
+ return np.polyfit(x[not_m], y[not_m], deg, rcond, full, w, cov)
+ else:
+ return np.polyfit(x, y, deg, rcond, full, w, cov)
polyfit.__doc__ = ma.doc_note(np.polyfit.__doc__, polyfit.__doc__)