[SciPy-user] Newbie Question about Scipy

Kumar Appaiah akumar@iitm.ac...
Wed Feb 14 10:16:08 CST 2007

On Wed, Feb 14, 2007 at 04:47:58PM +0100, Lorenzo Isella wrote:
> However, statements like the ones in the guide:
> In [12]: from integrate import quad
> ---------------------------------------------------------------------------
> exceptions.ImportError                               Traceback (most
> recent call last)
> /home/iselllo/<ipython console>
> ImportError: No module named integrate
> do not work.
> So I have to use: scipy.integrate. Similarly, the function gamma is
> not recognized, but special.gamma is.

How about

from scipy.integrate import quad
from scipy.special import gamma

That works. But most of us non-experts don't bother importing things
in bits and pieces, so I somehow am used to special.<func>,
signal.<func> etc. But of course, it does make a difference if you
have to use the function over and over again.

And here's another cheap Python trick:

import scipy

g = scipy.special.gamma
print g == scipy.special.gamma # should be True
print g(0.5) # prints sqrt(pi)

So, g is special.gamma.



Kumar Appaiah,
462, Jamuna Hostel,
Indian Institute of Technology Madras,
Chennai - 600 036

More information about the SciPy-user mailing list