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

Method __init__

numpy/polynomial/_polybase.py:304–332  ·  view source on GitHub ↗
(self, coef, domain=None, window=None, symbol='x')

Source from the content-addressed store, hash-verified

302 return other
303
304 def __init__(self, coef, domain=None, window=None, symbol='x'):
305 [coef] = pu.as_series([coef], trim=False)
306 self.coef = coef
307
308 if domain is not None:
309 [domain] = pu.as_series([domain], trim=False)
310 if len(domain) != 2:
311 raise ValueError("Domain has wrong number of elements.")
312 self.domain = domain
313
314 if window is not None:
315 [window] = pu.as_series([window], trim=False)
316 if len(window) != 2:
317 raise ValueError("Window has wrong number of elements.")
318 self.window = window
319
320 # Validation for symbol
321 try:
322 if not symbol.isidentifier():
323 raise ValueError(
324 "Symbol string must be a valid Python identifier"
325 )
326 # If a user passes in something other than a string, the above
327 # results in an AttributeError. Catch this and raise a more
328 # informative exception
329 except AttributeError:
330 raise TypeError("Symbol must be a non-empty string")
331
332 self._symbol = symbol
333
334 def __repr__(self):
335 coef = repr(self.coef)[6:-1]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected