import error with numpy

Using matplotlib from cvs with numpy still gives an fft import error:

In [1]: import pylab

···

---------------------------------------------------------------------------
exceptions.ImportError Traceback (most recent call last)

/Users/chris/<ipython console>

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib-0.86.1-py2.4-macosx-10.4-ppc.egg/pylab.py
----> 1 from matplotlib.pylab import *
         global matplotlib.pylab = undefined

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib-0.86.1-py2.4-macosx-10.4-ppc.egg/matplotlib/pylab.py
     194 import cm
     195 import _pylab_helpers
--> 196 import mlab #so I can override hist, psd, etc...
         mlab = undefined
     197
     198 from axes import Axes, PolarAxes

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib-0.86.1-py2.4-macosx-10.4-ppc.egg/matplotlib/mlab.py
      72
      73 from numerix.mlab import hanning, cov, diff, svd, rand, std
---> 74 from numerix.fft import fft, inverse_fft
         numerix.fft = undefined
         fft = None
         inverse_fft = undefined
      75
      76 from cbook import iterable

ImportError: cannot import name inverse_fft

It turns out that the __init__.py file is not importing inverse_fft (which is now ifft in numpy):

from matplotlib.numerix import which

if which[0] == "numarray":
     from numarray.fft import *
elif which[0] == "numeric":
     from FFT import *
elif which[0] == "numpy":
     from numpy import fft
else:
     raise RuntimeError("invalid numerix selector")

You need to add:

     from numpy import ifft as inverse_fft

C.

--
Christopher J. Fonnesbeck

Population Ecologist, Marine Mammal Section
Fish & Wildlife Research Institute (FWC)
St. Petersburg, FL

Adjunct Assistant Professor
Warnell School of Forest Resources
University of Georgia
Athens, GA

T: 727.235.5570
E: chris at trichech.us

Chris,

On my machine, with latest svn numpy and cvs mpl, I don't get an import error. My numerix/fft/__init__.py looks like this:

from matplotlib.numerix import which

if which[0] == "numarray":
     from numarray.fft import *
elif which[0] == "numeric":
     from FFT import *
elif which[0] == "numpy":
     from numpy.dft import *
else:
     raise RuntimeError("invalid numerix selector")

This is quite different from what you describe, so I think your mpl, and maybe numpy, are not quite up-to-date. Numpy and its mpl support are still evolving rapidly in tandem.

Eric

Christopher Fonnesbeck wrote:

···

Using matplotlib from cvs with numpy still gives an fft import error:

In [1]: import pylab
------------------------------------------------------------------------ ---
exceptions.ImportError Traceback (most recent call last)

/Users/chris/<ipython console>

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/matplotlib-0.86.1-py2.4-macosx-10.4-ppc.egg/pylab.py
----> 1 from matplotlib.pylab import *
        global matplotlib.pylab = undefined

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/matplotlib-0.86.1-py2.4-macosx-10.4-ppc.egg/matplotlib/pylab.py
    194 import cm
    195 import _pylab_helpers
--> 196 import mlab #so I can override hist, psd, etc...
        mlab = undefined
    197
    198 from axes import Axes, PolarAxes

/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- packages/matplotlib-0.86.1-py2.4-macosx-10.4-ppc.egg/matplotlib/mlab.py
     72
     73 from numerix.mlab import hanning, cov, diff, svd, rand, std
---> 74 from numerix.fft import fft, inverse_fft
        numerix.fft = undefined
        fft = None
        inverse_fft = undefined
     75
     76 from cbook import iterable

ImportError: cannot import name inverse_fft

It turns out that the __init__.py file is not importing inverse_fft (which is now ifft in numpy):

from matplotlib.numerix import which

if which[0] == "numarray":
    from numarray.fft import *
elif which[0] == "numeric":
    from FFT import *
elif which[0] == "numpy":
    from numpy import fft
else:
    raise RuntimeError("invalid numerix selector")

You need to add:

    from numpy import ifft as inverse_fft

C.

--
Christopher J. Fonnesbeck

Population Ecologist, Marine Mammal Section
Fish & Wildlife Research Institute (FWC)
St. Petersburg, FL

Adjunct Assistant Professor
Warnell School of Forest Resources
University of Georgia
Athens, GA

T: 727.235.5570
E: chris at trichech.us

Hmm ... I just did a CVS update this morning. I will try again.

C.

···

On Jan 16, 2006, at 2:14 PM, Eric Firing wrote:

On my machine, with latest svn numpy and cvs mpl, I don't get an import error. My numerix/fft/__init__.py looks like this:

from matplotlib.numerix import which

if which[0] == "numarray":
    from numarray.fft import *
elif which[0] == "numeric":
    from FFT import *
elif which[0] == "numpy":
    from numpy.dft import *
else:
    raise RuntimeError("invalid numerix selector")

This is quite different from what you describe, so I think your mpl, and maybe numpy, are not quite up-to-date. Numpy and its mpl support are still evolving rapidly in tandem.

--
Christopher J. Fonnesbeck

Population Ecologist, Marine Mammal Section
Fish & Wildlife Research Institute (FWC)
St. Petersburg, FL

Adjunct Assistant Professor
Warnell School of Forest Resources
University of Georgia
Athens, GA

T: 727.235.5570
E: chris at trichech.us