[SciPy-dev] Scipy for Numarray

Pearu Peterson pearu at cens.ioc.ee
Wed Sep 22 16:57:28 EDT 2004


On Wed, 22 Sep 2004, Charles Harris wrote:

> Pearu Peterson wrote:
> 
> First, there have been some off-list discussion about numarray integration
> with scipy among developers of both projects and at the moment the plan
> seems to be to provide scipy installation that has two versions of
> extension modules that are built against Numeric and numarray,
> respectively. When importing scipy then only one version of extension
> modules will be imported based on the state of some external flag,
> e.g. environment variable (imho, using env. variable is reasonable under
> unix system but how this sounds for Windows users? Alternative ideas?).
>
> Chuck responded:
> 
> I don't much like the idea of an external variable, since at this
> point I use both Numeric and numarray, and don't want to mess with my
> environment variables to switch between them. Perhaps we could put a
> skeleton directory under numarray that would import the proper modules
> if they are available, or even install the whole numarray version of
> scipy there. This does mean programs have to be modified, but then
> numarray itself is not completely backward compatible with Numeric. I
> rather like doing the numarray.random_array sort of thing.

I must agree that it makes sense to use both numarray and Numeric versions
of scipy (or any other package) in the same Python applications whichever
is more suitable for some specific task.

However, I am not sure that numarray installation directory would be the
proper place for scipy.

Here is another idea: we could install numarray or Numeric versions of
scipy under scipy installation directory so that

  scipy.na.linalg - scipy.linalg package built against numarray
  scipy.np.linalg - scipy.linalg package built against Numeric
  scipy.linalg    - scipy.linalg package built against default
                    target, be it Numeric or numarray.

for example.
Any thoughts?

>  On the implementation of the plan:
> 
> 1) An extension module, say foo, will be built into three files:
>    _foo_na.so - foo built against numarray
>    _foo_np.so - foo built against Numeric
>    foo.py     - Python module that imports one of the above modules
> This task should be doable on the top level of the scipy sources
> (in setup.py and scipy_distutils) without touching scipy subpackages
> at all. And f2py already supports numarray.
> 
> Chuck responded:
> 
> We will have to change packages to conform to this notation.

Not necessarily. This can be accomplished by hacking scipy_distutils
alone. Now I think of introducing --targets flag to build_ext command so
that scipy could be build using either

  python setup.py build_ext --targets=Numeric,numarray build
  python setup.py build_ext --targets=Numeric build
  python setup.py build_ext --targets=numarray build

Btw, note that when the target is numarray then only -DNUMARRAY will be
specified to compile an extension module. At least, this convention is
used in f2py numarray support, the same convention could be used also
in handwritten or swig generated extension modules.

Pearu





More information about the SciPy-Dev mailing list