Esempio n. 1
0
    def __init__(self, c_or_r, r=False, variable=None):
        if isinstance(c_or_r, poly1d):
            self._variable = c_or_r._variable
            self._coeffs = c_or_r._coeffs

            if set(c_or_r.__dict__) - set(self.__dict__):
                msg = ("In the future extra properties will not be copied "
                       "across when constructing one poly1d from another")
                warnings.warn(msg, FutureWarning, stacklevel=2)
                self.__dict__.update(c_or_r.__dict__)

            if variable is not None:
                self._variable = variable
            return
        if r:
            c_or_r = poly(c_or_r)
        c_or_r = atleast_1d(c_or_r)
        if c_or_r.ndim > 1:
            raise ValueError("Polynomial must be 1d only.")
        c_or_r = trim_zeros(c_or_r, trim='f')
        if len(c_or_r) == 0:
            c_or_r = NX.array([0.])
        self._coeffs = c_or_r
        if variable is None:
            variable = 'x'
        self._variable = variable
Esempio n. 2
0
 def __init__(self, c_or_r, r=0, variable=None):
     if isinstance(c_or_r, poly1d):
         for key in c_or_r.__dict__.keys():
             self.__dict__[key] = c_or_r.__dict__[key]
         if variable is not None:
             self.__dict__['variable'] = variable
         return
     if r:
         c_or_r = poly(c_or_r)
     c_or_r = atleast_1d(c_or_r)
     if len(c_or_r.shape) > 1:
         raise ValueError("Polynomial must be 1d only.")
     c_or_r = trim_zeros(c_or_r, trim='f')
     if len(c_or_r) == 0:
         c_or_r = NX.array([0.])
     self.__dict__['coeffs'] = c_or_r
     self.__dict__['order'] = len(c_or_r) - 1
     if variable is None:
         variable = 'x'
     self.__dict__['variable'] = variable
Esempio n. 3
0
 def __init__(self, c_or_r, r=0, variable=None):
     if isinstance(c_or_r, poly1d):
         for key in c_or_r.__dict__.keys():
             self.__dict__[key] = c_or_r.__dict__[key]
         if variable is not None:
             self.__dict__['variable'] = variable
         return
     if r:
         c_or_r = poly(c_or_r)
     c_or_r = atleast_1d(c_or_r)
     if len(c_or_r.shape) > 1:
         raise ValueError("Polynomial must be 1d only.")
     c_or_r = trim_zeros(c_or_r, trim='f')
     if len(c_or_r) == 0:
         c_or_r = NX.array([0.])
     self.__dict__['coeffs'] = c_or_r
     self.__dict__['order'] = len(c_or_r) - 1
     if variable is None:
         variable = 'x'
     self.__dict__['variable'] = variable