summaryrefslogtreecommitdiff
path: root/numpy/ma/extras.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/ma/extras.py')
-rw-r--r--numpy/ma/extras.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py
index d2986012b..b3016da5a 100644
--- a/numpy/ma/extras.py
+++ b/numpy/ma/extras.py
@@ -588,8 +588,8 @@ def average(a, axis=None, weights=None, returned=False, *,
>>> avg, sumweights = np.ma.average(x, axis=0, weights=[1, 2, 3],
... returned=True)
>>> avg
- masked_array(data=[2.6666666666666665, 3.6666666666666665],
- mask=[False, False],
+ masked_array(data=[2.66666667, 3.66666667],
+ mask=False,
fill_value=1e+20)
With ``keepdims=True``, the following result has shape (3, 1).
@@ -2016,8 +2016,15 @@ def polyfit(x, y, deg, rcond=None, full=False, w=None, cov=False):
not_m = ~m
if w is not None:
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)
+ x = x[not_m]
+ y = y[not_m]
+
+ # Only pass the ndarray data
+ if w is not None:
+ w = w.view(np.ndarray)
+ x = x.view(np.ndarray)
+ y = y.view(np.ndarray)
+
+ return np.polyfit(x, y, deg, rcond, full, w, cov)
polyfit.__doc__ = ma.doc_note(np.polyfit.__doc__, polyfit.__doc__)