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

josef.pktd@gmai... josef.pktd@gmai...
Fri Oct 29 12:06:12 CDT 2010


On Fri, Oct 29, 2010 at 12:50 PM, Charles R Harris
<charlesr.harris@gmail.com> wrote:
>
>
> 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?

I'm old,  numpy 1.4.0

empty array is good, it works with the rest so far.

Thanks,

Josef

>
> Chuck
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>


More information about the NumPy-Discussion mailing list