numpy is intended to replace numarray and Numeric. It comes with a script to convert most adjustments for numarray (except for strings and records).
To have an overview of (some) changes needed to convert a numarray based program, this page will document the list of necessary changes that must be made to your code .
Python Changes
Numarray
NumPy
import numarray
import numpy
numarray.array(shape=s,type=t)
numpy.empty(shape=s,dtype=t)
numarray.abs(x)
numpy.absolute(x)
.type()
.dtype.type or .dtype or .dtype.name or ...
.rank
.ndim
.itemsize()
.itemsize
._byteorder == sys.byteorder
.dtype.byteorder == '='
NumArray
ndarray
ComplexType
complexfloating
NumericType
number
type=
dtype=
UInt16 (etc)
uint16 (etc)
Complex32
complex64 (!)
Complex64
complex128 (!)
.iscontiguous()
.flags.contiguous
.linear_algebra.inverse
.linalg.inv
.linear_algebra.generalized_inverse
.linalg.pinv
Some module functions and/or array methods have changed bahaviour
in numpy: arr.transpose() method returns a transposed view of arr - i.e. it shares the memory with the original
in numarray: array.transpose() returns nothing
the transpose() function in numarray is different from the method - but in numpy they are the same.
Extension module Changes
Numarray provided two separate APIs to write C extensions. One was inherently "new" (numarray specific) while the other was intended for easier transition from Numeric. (note/check: if I'm not mistaken, this second one was more feature limited)
- 1) The numarray-specific C-API is supported by numpy. Use
#include "numpy/libnumarray.h" instead of #include "numarray/libnumarray.h"
- 2) If you used the Numeric-compatible C-API, then it is also easy. Full
backward-compatible support is available using #include "numpy/oldnumeric.h" instead of "include "numarray/libnumeric.h"