[Numpy-discussion] ValueError with np.polynomial.Polynomial([1]).roots()

josef.pktd@gmai... josef.pktd@gmai...
Fri Oct 29 11:41:14 CDT 2010


For the lag polynomials I have cases where the order is zero, but
roots raises a ValueError.

Is this intended?
Then, I need to catch it in my code. I haven't checked yet if my other
parts will go through with empty roots.

>>> np.polynomial.Polynomial([1])
Polynomial([ 1.], [-1.,  1.])
>>> np.polynomial.Polynomial([1]).roots()
Traceback (most recent call last):
  File "<pyshell#140>", line 1, in <module>
    np.polynomial.Polynomial([1]).roots()
  File "<string>", line 485, in roots
  File "C:\Programs\Python25\lib\site-packages\numpy\polynomial\polyutils.py",
line 280, in mapdomain
    [x] = as_series([x], trim=False)
  File "C:\Programs\Python25\lib\site-packages\numpy\polynomial\polyutils.py",
line 137, in as_series
    raise ValueError("Coefficient array is empty")
ValueError: Coefficient array is empty

Josef


More information about the NumPy-Discussion mailing list