Numarray, numeric, NumPy, scpy_core ??!!

J

J

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
 
C

Claudio Grondi

J said:
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

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
 
R

Robert Kern

J said:
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 (e-mail address removed) :

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

--
Robert Kern
(e-mail address removed)

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

Robert Kern

Claudio said:
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.

--
Robert Kern
(e-mail address removed)

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

Colin J. Williams

J said:
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
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:
(e-mail address removed)
You can also subscribe to the list.

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

Colin W,
 
J

J

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
 
R

Robert Kern

J said:
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 .

--
Robert Kern
(e-mail address removed)

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

J

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
 
R

Robert Kern

J said:
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

That stuff isn't going to change on you.

--
Robert Kern
(e-mail address removed)

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

Travis E. Oliphant

J said:
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

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
 
T

Tom Anderson

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.

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

tom
 
R

Robert Kern

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

Yes.

--
Robert Kern
(e-mail address removed)

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

Lawrence Oluyede

J said:
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.
 
?

=?iso-8859-1?q?S=E9bastien_Boisg=E9rault?=

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
 
R

Robert Kern

Sébastien Boisgérault said:
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.

--
Robert Kern
(e-mail address removed)

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

Tim Hochberg

Szabolcs said:
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/

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
 
G

greg.landrum

Robert said:
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
 
?

=?iso-8859-1?q?S=E9bastien_Boisg=E9rault?=

Robert said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

numeric/numpy/numarray 10
numarray 0
numpy, numarray, or numeric? 4
ANN: numarray-1.0 released 0
Numpy module 4
Numpy Array of Sets 7
numpy masked_where 0
Numpy: Multiplying arrays of matrices 5

Members online

Forum statistics

Threads
473,763
Messages
2,569,561
Members
45,035
Latest member
HoTaKeDai

Latest Threads

Top