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

Fernando Perez Fernando.Perez at colorado.edu
Sun Nov 13 02:17:13 CST 2005

Robert Kern wrote:
> Fernando Perez wrote:
>>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
> You tested the wrong predicate, I think.
> In [66]: issubclass(zarr.dtype, complexfloating)
> Out[66]: True

OK, in that case the roots() call in scipy.polynomial needs fixing, and 
perhaps a fair bit of code out there that used isinstance is going to break. 
See my other message (which I sent as yours came in) for further details on 
this.  Before we change any code, I'd like to understand (and hopefully this 
should be clearly documented) how types should be handled with the new scipy.

In fact, we're all so used to isinstance that this is probably going to bite a 
lot of people.  A quick look at my install of the old scipy:

abdul[zipy-old]> egrep -r isinstance * | wc -l

While most of those are not using the numeric type hierarchy, a few are.   I 
wonder if we have more broken code like the roots() case due to this, and 
worry about how much _user_ code is going to go poof for the same reason.



More information about the SciPy-user mailing list