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

Charles R Harris charlesr.harris@gmail....
Fri Oct 29 11:50:37 CDT 2010


On Fri, Oct 29, 2010 at 10:41 AM, <josef.pktd@gmail.com> wrote:

> 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
>
>
This has been fixed in trunk to return an empty array:

In [2]: import numpy.polynomial as poly

In [3]: p = poly.Polynomial([1])

In [4]: p
Out[4]: Polynomial([ 1.], [-1.,  1.])

In [5]: p.roots()
Out[5]: array([], dtype=float64)

What version are you seeing this in?

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20101029/6bc73396/attachment.html 


More information about the NumPy-Discussion mailing list