[SciPy-User] [SciPy-user] Convention and preferred practice when importing scipy

Robert Kern robert.kern@gmail....
Mon Oct 11 14:02:19 CDT 2010


On Mon, Oct 11, 2010 at 13:54, omnyx <ognjen.i@gmail.com> wrote:
>
> You're right - I see that some of the functions are actually numpy functions.
> So, is there a difference between just importing scipy (import scipy) or
> just numpy (import numpy), except for the scipy.special subpackage package
> that also come with scipy (that you mentioned).
> And which is preferred?

The scipy/__init__.py file exposes almost everything that
numpy/__init__.py does, but it replaces some of the math functions
with some alternate versions from numpy.lib.scimath. The reasons for
this are historical and shouldn't concern you. If you want those
versions, import them from numpy.lib.scimath yourself.

If you need stuff from numpy, import it from numpy. If you need stuff
from a scipy subpackage (e.g. from scipy.special), import it from that
subpackage. Never just do "import scipy".

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco


More information about the SciPy-User mailing list