Any masked values in x is propagated in y, and vice-versa.
(x, y, deg, rcond=None, full=False, w=None, cov=False)
| 2229 | |
| 2230 | |
| 2231 | def polyfit(x, y, deg, rcond=None, full=False, w=None, cov=False): |
| 2232 | """ |
| 2233 | Any masked values in x is propagated in y, and vice-versa. |
| 2234 | |
| 2235 | """ |
| 2236 | x = asarray(x) |
| 2237 | y = asarray(y) |
| 2238 | |
| 2239 | m = getmask(x) |
| 2240 | if y.ndim == 1: |
| 2241 | m = mask_or(m, getmask(y)) |
| 2242 | elif y.ndim == 2: |
| 2243 | my = getmask(mask_rows(y)) |
| 2244 | if my is not nomask: |
| 2245 | m = mask_or(m, my[:, 0]) |
| 2246 | else: |
| 2247 | raise TypeError("Expected a 1D or 2D array for y!") |
| 2248 | |
| 2249 | if w is not None: |
| 2250 | w = asarray(w) |
| 2251 | if w.ndim != 1: |
| 2252 | raise TypeError("expected a 1-d array for weights") |
| 2253 | if w.shape[0] != y.shape[0]: |
| 2254 | raise TypeError("expected w and y to have the same length") |
| 2255 | m = mask_or(m, getmask(w)) |
| 2256 | |
| 2257 | if m is not nomask: |
| 2258 | not_m = ~m |
| 2259 | if w is not None: |
| 2260 | w = w[not_m] |
| 2261 | return np.polyfit(x[not_m], y[not_m], deg, rcond, full, w, cov) |
| 2262 | else: |
| 2263 | return np.polyfit(x, y, deg, rcond, full, w, cov) |
| 2264 | |
| 2265 | |
| 2266 | polyfit.__doc__ = ma.doc_note(np.polyfit.__doc__, polyfit.__doc__) |
searching dependent graphs…