[SciPy-user] Finding complex roots of complex polynomials in newscipy

Fernando Perez Fernando.Perez at colorado.edu
Sun Nov 13 01:48:03 CST 2005

Andrew D wrote:
> Hello,
> I'm using an up-to-date build of newcore and newscipy (newcore
> 1467, newscipy 1431) on Red Hat Enterprise Linux WS release 3 (Taroon
> Update 6) running on a Pentium 4.

> Is this a known problem? The culprit seems to be the lines 103-105 in
> polynomial.py:
> # casting: if incoming array isn't floating point, make it floating
> point.
> if not isinstance(p.dtype, (NX.floating, NX.complexfloating)):
>     p = p.astype(float)
> which force p to be real, if it is complex, even though it appears
> that they should leave things be if they are complex.

I tracked this down to the following behavior in the scipy type hierarchy. 
This looks to me like a bug, unless I'm missing something:

In [14]: zarr = scipy.array([1j,2j])

In [15]: zarr.dtype
Out[15]: <type 'complex128_arrtype'>

In [16]: isinstance(zarr.dtype,scipy.complexfloating)
Out[16]: False

I don't know the type inheritance code at all, and a bit of grepping didn't 
point me quite in the right direction.  I'll keep looking, but I want to 
narrow down the bug so that perhaps someone who knows this code well can fix 
this one quickly.  I should mention that at least the hunt for this problem 
led me to fixing a bug in ipython related to embedding, so the work wasn't in 
vain :)



More information about the SciPy-user mailing list