def __init__(self, data=None, zero=None):
    """
    Inits a polynomial from given data, which can be a list or a dict.

    A list :math:`[a_0, a_1, a_2, a_3, ...]` inits a polynomial like

    .. math::

      a_0 + a_1 . x + a_2 . x^2 + a_3 . x^3 + ...

    If data is a dictionary, powers are the keys and the :math:`a_i` factors
    are the values, so negative powers are allowed and you can neglect the
    zeros in between, i.e., a dict with terms like ``{power: value}`` can also
    be used.

    """
    self._zero = 0. if zero is None else zero
    if isinstance(data, list):
      self._data = OrderedDict(enumerate(data))
    elif isinstance(data, dict):
      self._data = OrderedDict(data)
    elif isinstance(data, Poly):
      self._data = OrderedDict(data._data)
      self._zero = data._zero if zero is None else zero
    elif data is None:
      self._data = OrderedDict()
    else:
      self._data = OrderedDict([(0, data)])

    # Compact zeros
    for key, value in list(iteritems(self._data)):
      if isinstance(key, float) and key.is_integer():
        del self._data[key]
        key = rint(key)
        self._data[key] = value
      if (not isinstance(value, Stream)) and value == self.zero:
        del self._data[key]
def __init__ ( self , data = None , zero = None ) : self . _zero = 0. if zero is None else zero if isinstance ( data , list ) : self . _data = OrderedDict ( enumerate ( data ) ) elif isinstance ( data , dict ) : self . _data = OrderedDict ( data ) elif isinstance ( data , Poly ) : self . _data = OrderedDict ( data . _data ) self . _zero = data . _zero if zero is None else zero elif data is None : self . _data = OrderedDict ( ) else : self . _data = OrderedDict ( [ ( 0 , data ) ] ) for key , value in list ( iteritems ( self . _data ) ) : if isinstance ( key , float ) and key . is_integer ( ) : del self . _data [ key ] key = rint ( key ) self . _data [ key ] = value if ( not isinstance ( value , Stream ) ) and value == self . zero : del self . _data [ key ]
Inits a polynomial from given data, which can be a list or a dict.

    A list :math:`[a_0, a_1, a_2, a_3, ...]` inits a polynomial like

    .. math::

      a_0 + a_1 . x + a_2 . x^2 + a_3 . x^3 + ...

    If data is a dictionary, powers are the keys and the :math:`a_i` factors
    are the values, so negative powers are allowed and you can neglect the
    zeros in between, i.e., a dict with terms like ``{power: value}`` can also
    be used.