why does matplotlib require numarray?

I was under the impression that you could use matplotlib with either
Numeric or numarray. I do not have numarray anywhere on my system, yet
after installing Numeric and matplotlib, I get the following:

import pylab

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/pylab.py",
line 1, in ?
    from matplotlib.pylab import *
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/pylab.py",
line 194, in ?
    import cm
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/cm.py",
line 5, in ?
    import colors
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/colors.py",
line 33, in ?
    from numerix import array, arange, take, put, Float, Int, where, \
  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/numerix/__init__.py",
line 48, in ?
    from numarray import *
ImportError: No module named numarray

I'm not sure why it should be looking for numarray when it doesnt
exist. Doesnt the setup.py file set this up?

···

--
Chris Fonnesbeck
Atlanta, GA

Chris Fonnesbeck wrote:

I was under the impression that you could use matplotlib with either
Numeric or numarray. I do not have numarray anywhere on my system, yet
after installing Numeric and matplotlib, I get the following:

  File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/matplotlib/numerix/__init__.py",
line 48, in ?
    from numarray import *
ImportError: No module named numarray

I'm not sure why it should be looking for numarray when it doesnt
exist. Doesnt the setup.py file set this up?

What's the value of the option "numerix" in your matplotlibrc? If you
want to use Numeric, then it should look like this:

numerix : Numeric # Numeric or numarray

For the most part, this is a run-time setting rather than a build-time
setting, so it shouldn't be set by setup.py.

···

--
Robert Kern
rkern@...376...

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
  -- Richard Harter

Please ignore. I discovered .matplotlibrc ...

···

On 11/3/05, Chris Fonnesbeck <fonnesbeck@...287...> wrote:

I'm not sure why it should be looking for numarray when it doesnt
exist. Doesnt the setup.py file set this up?

--
Chris Fonnesbeck
Atlanta, GA

Robert Kern wrote:

What's the value of the option "numerix" in your matplotlibrc? If you
want to use Numeric, then it should look like this:

numerix : Numeric # Numeric or numarray

For the most part, this is a run-time setting rather than a build-time
setting, so it shouldn't be set by setup.py.

Well, yes and no. setup.py does a nice job of figuring out what is on the system, and building an MPL that works with the components that are installed. After that, however, it installs a generic .matplotlibrc file. Is is just too much of a PITA to have setup.py build a custom .matplotlibrc that reflects the just-built matplotlib?

Numeric-numarray is one issue, default back end is the other, and I'm sure there are others.

For that matter, it would be nice if some of the defaults were better tuned for platform: gtk is not the best choice for OS-X for example. speaking of which, how is the Cocoa back-end doing?

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...

Chris Barker wrote:

Robert Kern wrote:

What's the value of the option "numerix" in your matplotlibrc? If you
want to use Numeric, then it should look like this:

numerix : Numeric # Numeric or numarray

For the most part, this is a run-time setting rather than a build-time
setting, so it shouldn't be set by setup.py.

Well, yes and no. setup.py does a nice job of figuring out what is on
the system, and building an MPL that works with the components that are
installed. After that, however, it installs a generic .matplotlibrc
file. Is is just too much of a PITA to have setup.py build a custom
.matplotlibrc that reflects the just-built matplotlib?

It can be. Customizing the distutils build process is always a very
fragile thing and should be avoided whenever possible.

Numeric-numarray is one issue, default back end is the other, and I'm
sure there are others.

Since one can have both Numeric and numarray enabled for numerix and
certainly more than one backend built, the user still has to edit the
matplotlibrc to specify their choice. It think that it's a clearer
procedure to:

1) Edit matplotlibrc to set the intended defaults for the
installation-wide matplotlibrc.
2) python setup.py build install
3) Possibly customize a ~/.matplotlib/matplotlibrc for a given user.

It's clear. It works in every environment. It works for every
customization one might want to do (i.e. for things that can't be
determined at build-time, like the fonts one wants as default).

···

--
Robert Kern
rkern@...376...

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
  -- Richard Harter

Robert Kern wrote:

Since one can have both Numeric and numarray enabled for numerix and
certainly more than one backend built, the user still has to edit the
matplotlibrc to specify their choice.

Yes, but I always like the concept of "sensible defaults", which in this case, at least something that will work on the users system!

That being said:

It think that it's a clearer procedure to:

1) Edit matplotlibrc to set the intended defaults for the
installation-wide matplotlibrc.
2) python setup.py build install
3) Possibly customize a ~/.matplotlib/matplotlibrc for a given user.

Fair enough, let's just make sure that this procedure is well outlined in the docs. There are enough questions here making it clear that it's not clear from the docs that EVERYONE should at least examine their .matplotlibrc when installing.

Another couple thoughts:

1) I'm wondering if there's a way to pre-define different defaults for different platforms. For example, I built an OS-X installer that doesn't support GTK, but the .matplotlibrc still had GtkAgg as the default. Yes, I could have edited the .matplotlib rc in my installer, but I'd have to do that each time I built a new one. It would be nice to have something in CVS that just worked.

2) Perhaps we could make the processing of matplotlibrc smarter. For example: if numarray is specified, but not installed, and Numeric is, it could roll over to Numeric. Same thing with back-ends. Of course, this kind of breaks the "explicit is better than implicit" rule, but it would greatly improve the "It just works" qualities of MPL.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@...259...