[SciPy-dev] scipy.pkgload (was Re: Moving random.py)
pearu at scipy.org
Tue Dec 20 05:27:28 CST 2005
I have implemented hooks for scipy.pkgload(..) following the idea of
Fernando's scipy.mod_load(..) functions with few modifications. It's doc
string is given below.
I have renamed mod_load to pkgload because we have packages.
In addition to importing the packages to scipy namespace, scipy.pkgload
fills also scipy.__all__ list. Hooks for filling scipy.__doc__ remains to
be implemented, it's not difficult though.
Currently scipy.pkgload is a bit more verbose than `import scipy` used to
be but all the messages are sent to sys.stderr and some of these messages
indicate that other parts in scipy needs to be fixed, such as overwriting
scipy.test module with ScipyTest instance method etc. Also, `import
scipy` still does the full import but after scipy.pkgload is stabilized,
importing scipy the following will happen in scipy name space (according
to current info.py files):
from test import ScipyTest
from base import *
from basic import fft, ifft, rand, randn, linalg, fftpack, random
I would be interested to know which of these import statements are
important to people and which can be removed. For example, what would be
the recommended way to access array facilities:
from scipy.base import *
from scipy import *
? If the former, then we could remove `from base import *` statement.
To import full scipy, one needs to execute
Base Class: scipy.PackageLoader
String Form: <scipy.PackageLoader instance at 0x403a21ac>
Manages loading SciPy packages.
Call def: scipy.pkgload(self, *packages, **options)
Load one or more packages into scipy's top-level namespace.
This function is intended to shorten the need to import many of
scipy's subpackages constantly with statements such as
import scipy.linalg, scipy.fft, scipy.etc...
Instead, you can say:
to load all of them in one call.
If a name which doesn't exist in scipy's namespace is
given, an exception [[WHAT? ImportError, probably?]] is raised.
- the names (one or more strings) of all the scipy modules one
wishes to load into the top-level namespace.
Optional keyword inputs:
- verbose - integer specifying verbosity level [default: 0].
- force - when True, force reloading loaded packages [default:
If no input arguments are given, then all of scipy's subpackages are
The function returns a tuple with all the names of the modules
which were actually imported. [NotImplemented]
More information about the Scipy-dev