[SciPy-user] Finding complex roots of complex polynomials in newscipy
Fernando Perez
Fernando.Perez at colorado.edu
Sun Nov 13 03:09:27 EST 2005
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
OK, a bit more info. I found that:
In [17]: isinstance(zarr.dtype(),scipy.complexfloating)
Out[17]: True
[Note the call on dtype]
This is in fact how regular python works:
In [26]: isinstance(int,int)
Out[26]: False
In [27]: isinstance(int(),int)
Out[27]: True
However, where scipy differs from python is here:
In [28]: iarr = scipy.arange(2)
In [29]: isinstance(iarr,scipy.integer)
Out[29]: False
So in order to do typechecking via isinstance(), we seem to be forced to make
a function call (expensive):
In [30]: isinstance(iarr.dtype,scipy.integer)
Out[30]: False
In [31]: isinstance(iarr.dtype(),scipy.integer)
Out[31]: True
I'm not exactly sure what Travis' intent was in here. But it would seem to me
that [29] above should have come out True, if arrays are to be as similar to
standard python objects as possible in terms of type handling. But as I said,
I don't know the structure of the type hierarchy code well enough to say
whether this is feasible or not.
Cheers,
f
More information about the SciPy-User
mailing list