MCPcopy Create free account
hub / github.com/numpy/numpy / _get_coefficients

Method _get_coefficients

numpy/polynomial/_polybase.py:266–302  ·  view source on GitHub ↗

Interpret other as polynomial coefficients. The `other` argument is checked to see if it is of the same class as self with identical domain and window. If so, return its coefficients, otherwise return `other`. .. versionadded:: 1.9.0 Parameters ----

(self, other)

Source from the content-addressed store, hash-verified

264 return isinstance(other, self.__class__)
265
266 def _get_coefficients(self, other):
267 """Interpret other as polynomial coefficients.
268
269 The `other` argument is checked to see if it is of the same
270 class as self with identical domain and window. If so,
271 return its coefficients, otherwise return `other`.
272
273 .. versionadded:: 1.9.0
274
275 Parameters
276 ----------
277 other : anything
278 Object to be checked.
279
280 Returns
281 -------
282 coef
283 The coefficients of`other` if it is a compatible instance,
284 of ABCPolyBase, otherwise `other`.
285
286 Raises
287 ------
288 TypeError
289 When `other` is an incompatible instance of ABCPolyBase.
290
291 """
292 if isinstance(other, ABCPolyBase):
293 if not isinstance(other, self.__class__):
294 raise TypeError("Polynomial types differ")
295 elif not np.all(self.domain == other.domain):
296 raise TypeError("Domains differ")
297 elif not np.all(self.window == other.window):
298 raise TypeError("Windows differ")
299 elif self.symbol != other.symbol:
300 raise ValueError("Polynomial symbols differ")
301 return other.coef
302 return other
303
304 def __init__(self, coef, domain=None, window=None, symbol='x'):
305 [coef] = pu.as_series([coef], trim=False)

Callers 4

__add__Method · 0.95
__sub__Method · 0.95
__mul__Method · 0.95
__divmod__Method · 0.95

Calls 1

allMethod · 0.45

Tested by

no test coverage detected