This new module numarray was developed for a number of reasons. To
summarize, we regularly deal with large datasets and numarray gives us the
capabilities that we feel are necessary for working with such datasets. In
Avoid promotion of array types in expressions involving Python scalars
(e.g., 2.*<Float32 array> should not result in a Float64
Ability to use memory mapped files.
Ability to access fields in arrays of records as numeric arrays without
copying the data to a new array.
Ability to reference byteswapped data or non-aligned data (as might be
found in record arrays) without producing new temporary arrays.
Reuse temporary arrays in expressions when possible.
Provide more convenient use of index arrays (put and take).
We decided to implement a new module since many of the existing Numeric
developers agree that the existing Numeric implementation is not suitable
for massive changes and enhancements.
This version has nearly the full functionality of the basic Numeric.
Numarray is not fully compatible with Numeric.
(But it is very similar in most respects).
The incompatibilities are listed below.
Coercion rules are different. Expressions involving scalars may not
produce the same type of arrays.
Types are represented by Type Objects rather than character codes (though
the old character codes may still be used as arguments to the functions).
For versions of Python prior to 2.2, arrays have no public attributes.
Accessor functions must be used instead (e.g., to get shape for array x, one
must use x.getshape() instead of x.shape). When using Python 2.2 or later,
however, the attributes of Numarray are in fact available.
A further comment on type is appropriate here. In numarray, types are
represented by type objects and not character codes. As with Numeric there is a
module variable Float32, but now it represents an instance of a FloatingType
class. For example, if x is a Float32 array, x.type() will return a
FloatingType instance associated with 32-bit floats (instead of using
x.typecode() as is done in Numeric). The following will still work in
numarray, to be backward compatible:
>>> if x.typecode() == 'f':
>>> if x.type() == Float32:
(All examples presume ``from numarray import *'' has been used instead
of ``import numarray'', see section 2.3.1.)
The advantage of the new scheme is that other kinds of tests become simpler.
The type classes are hierarchical so one can easily test to see if the array is
an integer array. For example:
>>> if isinstance(x.type(), IntegralType):
>>> if isinstance(x.type(), UnsignedIntegralType):