bug importing numpy with matplotlib.numerix

Hi,

I have a problem when importing numpy from matplotlib.numerix:

             When I do:

import matplotlib
import matplotlib.numerix as num # numpy
from num import median, std

              I get:
exceptions.ImportError Traceback (most
recent call last)
ImportError: No module named num

It seems that it does not import numpy but something else. (for example
num.std does not exist).
How do I solve that? (I saw a thread which seems to indicate that it was
solved recently, but I have recent versions of everything :
    matplotlib version 0.87.5
    platform is linux2
    numerix numpy 1.0rc1.dev3157
    backend GTKAgg version 2.8.2
    Python 2.4.2 (#1, May 2 2006, 08:13:46)
    IPython 0.7.3.svn -- An enhanced Interactive Python.

What could I do there?

Note that in the help of matplotlib.numerix, numpy is only indicated in
Option 0. (see below)

thanks for any help there.

Eric

···

==================================================
when I do:

help num

==> I get:

Help on package matplotlib.numerix in matplotlib:

NAME
    matplotlib.numerix - numerix imports either Numeric or numarray
based on various selectors.

FILE
    /usr/local/lib/python2.4/site/packages/matplotlib/numerix/__init__.py

DESCRIPTION
    0. If the value "--numpy","--numarray" or "--Numeric" is specified
on the
        command line, then numerix imports the specified
        array package.

    1. The value of numerix in matplotlibrc: either Numeric or numarray

    2. If none of the above is done, the default array package is Numeric.
       Because the matplotlibrc always provides *some* value for numerix
       (it has it's own system of default values), this default is most
       likely never used.

    To summarize: the commandline is examined first, the rc file second,
    and the default array package is Numeric.

Hi Eric,

I don't think this is a bug. Your last import doesnt do what you think it is
doing. For example:

In [1]: import matplotlib as d

In [2]: from d import rcParams

···

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

/home/darren/<ipython console>

ImportError: No module named d

You have imported the module to namespace d, you have not renamed the module.
If you want median and std in the main namespace, you could do

median = num.median
std = num.std

that is, you could this if median and std were provided by numerix, which they
are not. They are in matplotlib.numerix.mlab.

Darren

On Tuesday 10 October 2006 08:48, Eric Emsellem wrote:

Hi,

I have a problem when importing numpy from matplotlib.numerix:

             When I do:

import matplotlib
import matplotlib.numerix as num # numpy
from num import median, std

              I get:
exceptions.ImportError Traceback (most
recent call last)
ImportError: No module named num

It seems that it does not import numpy but something else. (for example
num.std does not exist).
How do I solve that? (I saw a thread which seems to indicate that it was
solved recently, but I have recent versions of everything :
    matplotlib version 0.87.5
    platform is linux2
    numerix numpy 1.0rc1.dev3157
    backend GTKAgg version 2.8.2
    Python 2.4.2 (#1, May 2 2006, 08:13:46)
    IPython 0.7.3.svn -- An enhanced Interactive Python.

What could I do there?

Note that in the help of matplotlib.numerix, numpy is only indicated in
Option 0. (see below)

thanks for any help there.

Eric

when I do:

help num

==> I get:

Help on package matplotlib.numerix in matplotlib:

NAME
    matplotlib.numerix - numerix imports either Numeric or numarray
based on various selectors.

FILE
    /usr/local/lib/python2.4/site/packages/matplotlib/numerix/__init__.py

DESCRIPTION
    0. If the value "--numpy","--numarray" or "--Numeric" is specified
on the
        command line, then numerix imports the specified
        array package.

    1. The value of numerix in matplotlibrc: either Numeric or numarray

    2. If none of the above is done, the default array package is Numeric.
       Because the matplotlibrc always provides *some* value for numerix
       (it has it's own system of default values), this default is most
       likely never used.

    To summarize: the commandline is examined first, the rc file second,
    and the default array package is Numeric.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your opinions on IT & business topics through brief surveys -- and earn
cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
Darren S. Dale, Ph.D.
Staff Scientist
Cornell High Energy Synchrotron Source
Cornell University
275 Wilson Lab
Rt. 366 & Pine Tree Road
Ithaca, NY 14853

dd55@...163...
office: (607) 255-3819
fax: (607) 255-9001
http://www.chess.cornell.edu

In order get pylab to work on my Mac I have to do the following (found by some experimenting):

import matplotlib
matplotlib.use("WXAgg")
import pylab

Does this seem right? I mean, it works, but it seems to be a little gymnastics to go through rather than just doing

import pylab

which gives

ImportError: No module named gobject

since it can't seem to find that backend in the "backend" directory when it tries to import backend_gtkagg.py. I guess that doesn't work on the Mac.

My setup: (Tiger 10.4) Al Laptop, Python 2.4, latest pylab from SciPy package.

···

--
Cheers,

Lou Pecora

Code 6362
Naval Research Lab
Washington, DC 20375
USA
Ph: +202-767-6002
email: pecora@...1125...

Edit your "~/.matplotlib/matplotlibrc" file to specify the default.
On OSX WXAgg or TkAgg is the best bet.

···

On 10/12/06, Louis Pecora <pecora@...1125...> wrote:

In order get pylab to work on my Mac I have to do the following (found
by some experimenting):

import matplotlib
matplotlib.use("WXAgg")
import pylab

Does this seem right? I mean, it works, but it seems to be a little
gymnastics to go through rather than just doing

import pylab

which gives

ImportError: No module named gobject

since it can't seem to find that backend in the "backend" directory when
it tries to import backend_gtkagg.py. I guess that doesn't work on the
Mac.

My setup: (Tiger 10.4) Al Laptop, Python 2.4, latest pylab from SciPy
package.

--
Cheers,

Lou Pecora

Code 6362
Naval Research Lab
Washington, DC 20375
USA
Ph: +202-767-6002
email: pecora@...1125...

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options