Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Numarray, numeric, NumPy, scpy_core ??!!

9 views
Skip to first unread message

J

unread,
Jan 20, 2006, 7:29:20 PM1/20/06
to
Hi

I hope the title of this message indicates my question. I am looking
for basic
array functionality in Python and it turns out that there are all these
packages which
are somehow related. Some are allegedly discontinued but still seem to
get updated. Could we start a discussion about which package will or
may or should survive ?

I started to use numarray, but I have a bug that I just cannot find a
solution for, so I started
to look around again. Basically I want to provide scripting support to
a graphics engine. All the
matrices and vectors are in C++ and all I want to do is provide an
interface to python. As a matter of fact, all of the matrix
multiplication etc, could remain in the native C++ code, but I need a
way to extend the python language with the array data type and somehow
intercept operator calls such as *,+,- ....

How is that done in the current libraries... Thx for any help.


Cheers
Jochen

Claudio Grondi

unread,
Jan 20, 2006, 7:42:08 PM1/20/06
to

I know the pain having similar trouble to understand the dependencies
and what is what and why, so any enlightenment towards getting rid of my
confusion to distinguish what is what and why is highly welcome.

I decided to use numarray, so maybe you can report what your problem/bug
is before I run into it myself? The reason why I decided to use numarray
was, that the whole scpy_core story seems to get more or less commercial
and its free version comes because of this with no documentation of
newest features.

Claudio

Robert Kern

unread,
Jan 20, 2006, 7:49:16 PM1/20/06
to pytho...@python.org
J wrote:
> Hi
>
> I hope the title of this message indicates my question. I am looking
> for basic
> array functionality in Python and it turns out that there are all these
> packages which
> are somehow related. Some are allegedly discontinued but still seem to
> get updated. Could we start a discussion about which package will or
> may or should survive ?

You missed the discussion. The answer is numpy.

http://numeric.scipy.org/

The mailing list is numpy-di...@lists.sourceforge.net :

http://sourceforge.net/mail/?group_id=1369

--
Robert Kern
rober...@gmail.com

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

Robert Kern

unread,
Jan 20, 2006, 8:02:05 PM1/20/06
to pytho...@python.org
Claudio Grondi wrote:

> I decided to use numarray, so maybe you can report what your problem/bug
> is before I run into it myself? The reason why I decided to use numarray
> was, that the whole scpy_core story seems to get more or less commercial
> and its free version comes because of this with no documentation of
> newest features.

No, numpy (which used to be scipy_core) is completely free. It will never turn
into a proprietary package.

The complete documentation, however, is currently available only as a PDF for
purchase, but only until a certain number of copies have been sold, or enough
time passes. Believe me, the old manuals for Numeric and numarray were never as
complete. No one could ever commit the time to thoroughly document them for
free. Charging for the documentation (for a limited time) was the only way
Travis Oliphant could afford to spend the time to write the full documentation
and write the code. I think the quality of the book speaks well for that choice.

Of course, the docstring coverage is quite good, and we have explicitly welcomed
efforts to produce free documentation. So far, those who have volunteered
haven't produced anything. And as incomplete as the old Numeric manual was *for
Numeric*, it and the free documentation that is actually distributed with numpy
and describes the differences between the two goes a long way.

Colin J. Williams

unread,
Jan 21, 2006, 11:18:29 AM1/21/06
to
numarray was intended to replace Numeric.

numarray is stable and performs reaonably well.
If you have a specific problem, you might post a problem report to:
numpy-di...@lists.sourceforge.net
You can also subscribe to the list.

numpy is intended to perform better and is close to a production release.

Colin W,

J

unread,
Jan 21, 2006, 2:06:50 PM1/21/06
to
Ok, I will look at NumPy ...

I have another question about performance. Are the array operations
such as matrix multiplication implemented in
python or in C ? I was under the impression that the function calls in
numarray are only wrappers to C code, but now I suspect that matrix
multiplicaiton is implemented in python and executed in the
interpreter. Is that true ?

Can someone also please point me to examples of how I could make my own
array classes. Basically all I need is vectors and 3x3 matrices. I
already have all of the multiplication code in my C++ classes and only
need wrappers. But how can I create an array class and intercept
operators calls like * + -. This is not neccessarily a solution that I
want to follow, but it may be what
I have to do for now.

BTW, here is also the problem I have with a numarray. I have created a
vector like so...

mPyObject = PyArray_FromDimsAndData(GeoVec4f::sD,GeoVec4f::sDim,
PyArray_FLOAT,(char*)mValue.mValues);
Py_INCREF(mPyObject);

The PyObject is then used as a member called "gradient" in another
embedded class. When I execute the following
script

x.gradient*3

my app just crashes. But when I execute

print (x.gradient)
x.gradient*3

everything works fine... I assum there must be some kind of reference
count problem...


Cheers
Jochen

Robert Kern

unread,
Jan 21, 2006, 2:27:59 PM1/21/06
to pytho...@python.org
J wrote:
> Ok, I will look at NumPy ...
>
> I have another question about performance. Are the array operations
> such as matrix multiplication implemented in
> python or in C ? I was under the impression that the function calls in
> numarray are only wrappers to C code, but now I suspect that matrix
> multiplicaiton is implemented in python and executed in the
> interpreter. Is that true ?

No, not at all. In fact, if an optimized BLAS is available on your system, you
can make numpy (or numarray or Numeric) use that to do your matrix
multiplications much faster.

> Can someone also please point me to examples of how I could make my own
> array classes. Basically all I need is vectors and 3x3 matrices. I
> already have all of the multiplication code in my C++ classes and only
> need wrappers. But how can I create an array class and intercept
> operators calls like * + -. This is not neccessarily a solution that I
> want to follow, but it may be what
> I have to do for now.

It's a difficult problem, since you have to overload nearly every operation in
order to return arrays of your subclass, not the basic array class. numpy has a
new mechanism to try to alleviate this. You should look at the matrix subclass
in numpy/core/defmatrix.py .

J

unread,
Jan 21, 2006, 2:53:48 PM1/21/06
to

I will just jump in an use NumPy. I hope this one will stick and evolve
into the mother of array packages.
How stable is it ? For now I really just need basic linear algebra.
i.e. matrix multiplication, dot, cross etc

Cheers

Robert Kern

unread,
Jan 21, 2006, 3:17:00 PM1/21/06
to pytho...@python.org

That stuff isn't going to change on you.

Travis E. Oliphant

unread,
Jan 21, 2006, 3:26:36 PM1/21/06
to pytho...@python.org

There is a new release coming out this weekend. It's closer to 1.0 and
so should be more stable. It also has some speed improvements in
matrix-vector operations (if you have ATLAS BLAS --- or if you download
a binary version with ATLAS BLAS compiled in). I would wait for it.

-Travis

Tom Anderson

unread,
Jan 21, 2006, 3:48:40 PM1/21/06
to

Pardon my failure to RTFM, but does NumPy pick up the vecLib BLAS on Macs?

tom

--
It's the 21st century, man - we rue _minutes_. -- Benjamin Rosenbaum

Robert Kern

unread,
Jan 21, 2006, 4:05:59 PM1/21/06
to pytho...@python.org
Tom Anderson wrote:

> Pardon my failure to RTFM, but does NumPy pick up the vecLib BLAS on Macs?

Yes.

Lawrence Oluyede

unread,
Jan 22, 2006, 6:11:11 AM1/22/06
to
"J" <jst...@cs.uvic.ca> writes:

> I hope the title of this message indicates my question. I am looking
> for basic
> array functionality in Python and it turns out that there are all these
> packages which
> are somehow related. Some are allegedly discontinued but still seem to
> get updated.

It's well explained in the homepage: numpy.scipy.org
AFAIK you should use numpy for future use.

--
Lawrence - http://www.oluyede.org/blog
"Anyone can freely use whatever he wants but the light at the end
of the tunnel for most of his problems is Python"

Tom Anderson

unread,
Jan 22, 2006, 8:09:26 AM1/22/06
to
On Sat, 21 Jan 2006, Robert Kern wrote:

> Tom Anderson wrote:
>
>> Pardon my failure to RTFM, but does NumPy pick up the vecLib BLAS on Macs?
>
> Yes.

Excellent, thanks.

tom

--
forget everything from school -- you are programmer

Sébastien Boisgérault

unread,
Jan 22, 2006, 9:25:30 AM1/22/06
to

Robert Kern wrote:
> J wrote:
> > I will just jump in an use NumPy. I hope this one will stick and evolve
> > into the mother of array packages.
> > How stable is it ? For now I really just need basic linear algebra.
> > i.e. matrix multiplication, dot, cross etc

Same concern for me.

I discovered recently that I could not rely on numeric anymore
because 'eigenvalue' is now broken on my platform. This bug
has been referenced but not corrected AFAIK. Too bad that
numeric is not actively maintained anymore. Easy-to-install,
good doc, well-thought interface, really good stuff !

Bye-bye Numeric !

By the way, I tried numpy 0.9.4 10 minutes ago and guess
what ? 'eigenvalue' is broken too ... (hangs forever)

I do really hope the numpy will become the robust, best-of-breed
Python Array/Matrix lib that many people are waiting for. But in
the meantime, it's back to Matlab :(

SB

Robert Kern

unread,
Jan 22, 2006, 2:59:23 PM1/22/06
to pytho...@python.org
Sébastien Boisgérault wrote:

> By the way, I tried numpy 0.9.4 10 minutes ago and guess
> what ? 'eigenvalue' is broken too ... (hangs forever)

On what platform? Are you linking against an optimized BLAS? We can't fix
anything without details. I'll be happy to work with you on this bug over on the
numpy-discussion list.

Szabolcs Nagy

unread,
Jan 22, 2006, 3:55:24 PM1/22/06
to

> Basically all I need is vectors and 3x3 matrices.

hmm
is numpy really efficient for 3x3 (or 4x4) matrices and vectors?

IMHO an optimized matrix4x4 class can be much faster (i'm just guessing
here)

eg cgtypes is a simple c++ implementation with boost-python wrapper:
http://cgkit.sourceforge.net/

Tim Hochberg

unread,
Jan 22, 2006, 5:27:27 PM1/22/06
to pytho...@python.org

If you're operating on a single 3x3 or 4x4 matrix, nothing you do in
Python will be "efficient", by which I assume you mean not all that far
from C speed; the interpreter overhead is simply too high. If you can
operate on large blocks of small arrays and vectors at the same time,
which one can usually do after consuming sufficient coffee, then yes
numpy can be fast if you're careful.

-tim

greg.l...@gmail.com

unread,
Jan 23, 2006, 1:43:47 PM1/23/06
to

Robert Kern wrote:
> Sébastien Boisgérault wrote:
>
> > By the way, I tried numpy 0.9.4 10 minutes ago and guess
> > what ? 'eigenvalue' is broken too ... (hangs forever)
>
> On what platform? Are you linking against an optimized BLAS? We can't fix
> anything without details. I'll be happy to work with you on this bug over on the
> numpy-discussion list.

This is a guess, but the original poster is probably using one of the
newer (3.4.x or 4.0.x) versions of gcc. This is a known problem:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=138791
(that's one of the applicable bug reports).

A workaround to this problem is to add the option '-ffloat-store' to
your CFLAGS.

<insert "gcc 4.0 is such a disaster" rant here>

-greg

Sébastien Boisgérault

unread,
Jan 23, 2006, 1:45:02 PM1/23/06
to
Robert Kern wrote:
> Sébastien Boisgérault wrote:
>
> > By the way, I tried numpy 0.9.4 10 minutes ago and guess
> > what ? 'eigenvalue' is broken too ... (hangs forever)
>
> On what platform?
Linux, Mandriva 2006 (gcc 4.0.1, etc.)

> Are you linking against an optimized BLAS?
Nope -- I tried the basic install.

> We can't fix
> anything without details.

Obviously, sorry. I was not really expecting a fix,
just wanted to point out that Numpy (or Numeric)
may well not work "out of the box" today on some
platforms.

The (similar) problem has been reported (2005-07-11)
is not assigned to anybody and is still open
See: http://sourceforge.net/tracker/?group_id=1369&atid=101369

> I'll be happy to work with you on this bug over on the
> numpy-discussion list.

Great Robert, I will follow your advice then. Thanks
for the proposal.


> --
> Robert Kern
> rober...@gmail.com
>
> "In the fields of hell where the grass grows high
> Are the graves of dreams allowed to die."

> -- Richard Harter.

Robert Kern

unread,
Jan 23, 2006, 2:22:51 PM1/23/06
to pytho...@python.org
Sébastien Boisgérault wrote:
> Robert Kern wrote:
>
>>Sébastien Boisgérault wrote:
>>
>>>By the way, I tried numpy 0.9.4 10 minutes ago and guess
>>>what ? 'eigenvalue' is broken too ... (hangs forever)
>>
>>On what platform?
>
> Linux, Mandriva 2006 (gcc 4.0.1, etc.)

Okay, my answer then is, "Don't use gcc 4." gcc 4 broke enough other projects
that I don't feel too bad about saying that. In the meantime, can you try the
workaround that Greg Landrum suggested?

Also, we are using Trac now to manage numpy, so please submit tickets here:

http://projects.scipy.org/scipy/numpy/

Thanks!

Sébastien Boisgérault

unread,
Jan 23, 2006, 3:21:08 PM1/23/06
to

Great ! It works :)
Thank you greg !

SB

Sébastien Boisgérault

unread,
Jan 23, 2006, 3:27:33 PM1/23/06
to

Robert Kern wrote:
> Sébastien Boisgérault wrote:
> > Robert Kern wrote:
> >
> >>Sébastien Boisgérault wrote:
> >>
> >>>By the way, I tried numpy 0.9.4 10 minutes ago and guess
> >>>what ? 'eigenvalue' is broken too ... (hangs forever)
> >>
> >>On what platform?
> >
> > Linux, Mandriva 2006 (gcc 4.0.1, etc.)
>
> Okay, my answer then is, "Don't use gcc 4." gcc 4 broke enough other projects
> that I don't feel too bad about saying that.

You certainly should not feel bad about that. Matlab does not support
anything
more recent than gcc 3.3 -- and specifically Simulink S-Functions do
not work
when compiled with gcc 3.4.x or 4.0.x.

> In the meantime, can you try the
> workaround that Greg Landrum suggested?

I tried it, it works :)

> Also, we are using Trac now to manage numpy, so please submit tickets here:

ok.

0 new messages