[SciPy-user] How to get sqrt(-1) = 1j per default?

Pauli Virtanen pav+sp@iki...
Sun Jul 12 12:12:25 CDT 2009

On 2009-07-12, Martin Kirsch <xyz.account@arcor.de> wrote:
> But why it makes a difference doing "from scipy import *"
> (1) per ipy_profile_scipy.py (ipython -pylab -p scipy) => sqrt(-1)= NaN
> (2) per console input => sqrt(-1)= 1j
> Originally I guessed that in both cases sqrt comes from scipy because of the
> preceding "from scipy import *" in both cases, but case (1) references
> numpy.sqrt despite "from scipy import *" in ipy_profile_scipy.py and I don't
> know the reason.

Perhaps the -pylab switch makes Ipython to run "from numpy import *",
or something similar, *after* ipy_profile_scipy.py? I'd suppose that
if you do "from scipy import *" in the Ipython console, you'd get
Scipy's version of sqrt.

Also, does the order of the -pylab and -p switches on the Ipython 
command line make a difference?

Pauli Virtanen

More information about the SciPy-user mailing list