[SciPy-dev] scipy.pkgload (was Re: Moving random.py)

Pearu Peterson pearu at scipy.org
Tue Dec 20 06:27:28 EST 2005


Hi,

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):

   import test
   from test import ScipyTest
   import base
   from base import *
   import basic
   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 *

or

   from scipy import *

? If the former, then we could remove `from base import *` statement.

To import full scipy, one needs to execute

   import scipy
   scipy.pkgload()

Regards,
Pearu

Type:             instance
Base Class:       scipy.PackageLoader
String Form:   <scipy.PackageLoader instance at 0x403a21ac>
Namespace:        Interactive
Constructor Docstring:
     Manages loading SciPy packages.

Callable: Yes
Call def: scipy.pkgload(self, *packages, **options)
Call docstring:
     Load one or more packages into scipy's top-level namespace.

     Usage:

        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:

          import scipy
          scipy.pkgload('linalg','fft',...)

        or

          scipy.pkgload()

        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.
        [NotImplemented]

      Inputs:

        - 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:
                    False].

      If no input arguments are given, then all of scipy's subpackages are
      imported.



      Outputs:

        The function returns a tuple with all the names of the modules
        which were actually imported. [NotImplemented]

EOM




More information about the SciPy-Dev mailing list