diff options
Diffstat (limited to 'numpy/ma/extras.py')
-rw-r--r-- | numpy/ma/extras.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py index 9adb9d368..b6082180a 100644 --- a/numpy/ma/extras.py +++ b/numpy/ma/extras.py @@ -497,8 +497,9 @@ def average(a, axis=None, weights=None, returned=False): The average along the specified axis. When returned is `True`, return a tuple with the average as the first element and the sum of the weights as the second element. The return type is `np.float64` - if `a` is of integer type, otherwise it is of the same type as `a`. - If returned, `sum_of_weights` is of the same type as `average`. + if `a` is of integer type and floats smaller than `float64`, or the + input data-type, otherwise. If returned, `sum_of_weights` is always + `float64`. Examples -------- @@ -1920,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__) |