[SciPy-dev] Advice on numpy/scipy namespace issue (ipython etc.)
Tom Loredo
loredo at astro.cornell.edu
Sun Jan 8 15:18:03 EST 2006
Hi folks,
Okay, as one who complained about the lack of numpy top-level
objects in scipy's top-level namespace, I'm pursuaded by Travis
and Pearu that a separation should be seriously considered, and
that now is the time. I'd like some advice about handling
the namespace split properly.
I know that "from ... import *" is bad behavior, but particularly
for interactive use it's sometimes irresistable. If I do
from numpy import *
from scipy import *
is there any namespace collision I should be aware of? Are
there any scipy modules or top-level functions with the same
name as numpy's (or vice versa)? Both packages have "fft"
at the top level, for example.
"ipython -p scipy" imports top-level scipy into its namespace, but not
top-level numpy. This doesn't seem right to me---surely one will be
using array and zeros more often than fftpack---but the "import *"
issue has to be settled if we want "-p scipy" to have all the
handy numpy stuff at its top level.
As a more specific example, what exactly is the difference
between numpy.fft and scipy.fft?
As a quick exploration of the issue, I ran this:
import numpy, scipy
nall = numpy.__all__
for name in scipy.__all__:
if name in nall: print name
The result was only 3 names: lib, fft, ifft. lib in particular is
quite different in scipy vs. numpy. If the common name is kept,
perhaps some convention should be recommended for * use, as in ipython,
so users can count on lib meaning the same thing at an interactive
prompt. It would probably be better to rename one of the libs (e.g.,
"mlib" for scipy's since it's a matrix library, vs. numpy's more
general-purpose lib), but I suppose it's late for that. I don't know
if the fft name collision is an issue.
Thanks,
Tom
More information about the SciPy-Dev
mailing list