power TypeErrors

Fernando Pérez fperez528 at yahoo.com
Thu Nov 7 14:50:46 EST 2002


Michael Hudson wrote:

> What specific problems involve complex input or
> output?

Side post (I'd already replied). A simple, specific example:

In [1]: import scipy

In [2]: scipy.roots?
Type:           function
Base Class:     <type 'function'>
String Form:    <function roots at 0x82fbccc>
Namespace:      Currently not defined in user session.
File:           /usr/lib/python2.2/site-packages/scipy/basic1a.py
Definition:     scipy.roots(p)
Docstring:
     Return the roots of the polynomial coefficients in p.

    The values in the rank-1 array p are coefficients of a polynomial.
    If the length of p is n+1 then the polynomial is
    p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]

In [3]: scipy.roots([1,0,1])
Out[3]: array([-0.+1.j,  0.-1.j])

These are just the roots of the trivial 'x^2+1=0'. Both complex (+/-i, in 
usual notation).

>> but I can tell you that python is gaining very stronng support in
>> scientific computing.

>Given what I hear of IDL, this doesn't surprise me :)

Indeed, hating IDL is one of the things that drove me to python. While IDL has 
admittedly nice graphics libraries, the language _SUCKS_ like nothing I've 
ever seen. It's absolutely, positively horrible. I'm glad I don't use that 
thing anymore.  Pyhton+IPython+(Gnuplot/Grace)+Mayavi is a far more pleasant 
environment.

Cheers,

f.



More information about the Python-list mailing list