MCPcopy Index your code
hub / github.com/numpy/numpy / polyfit

Function polyfit

numpy/ma/extras.py:2231–2263  ·  view source on GitHub ↗

Any masked values in x is propagated in y, and vice-versa.

(x, y, deg, rcond=None, full=False, w=None, cov=False)

Source from the content-addressed store, hash-verified

2229
2230
2231def 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
2266polyfit.__doc__ = ma.doc_note(np.polyfit.__doc__, polyfit.__doc__)

Callers 2

test_polyfitMethod · 0.90

Calls 4

getmaskFunction · 0.85
mask_orFunction · 0.85
mask_rowsFunction · 0.85
asarrayFunction · 0.70

Tested by 2

test_polyfitMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…