NumPy 0.9.5 review

Download
by rbytes.net on

NumPy is the fundamental package needed for scientific computing with Python. This package contains a powerful N-dimensional array

License: GPL (GNU General Public License)
File size: 0K
Developer: NumPy Development Team
0 stars award from rbytes.net

NumPy is the fundamental package needed for scientific computing with Python.

This package contains a powerful N-dimensional array object, sophisticated (broadcasting) functions, tools for integrating C/C++ and Fortran code, and useful linear algebra, Fourier transform, and random number capabilities.

It derives from the old Numeric code base and can be used as a replacement for Numeric. It also adds the features introduced by numarray and can be used to replace numarray.

Numeric users should find the transition very easy. There is a module (import numpy.lib.convertcode --- see the convertall and fromfile functions in that module) that can make (most of) the necessary changes to your Python code that used Numeric to make it work with the new NumPy.

Users of numarray currently need to do a bit more work (mostly import changes) to work with the new system because nobody has yet written an equivalent to convertcode.py

Here are some key features of "NumPy":
More data types (all standard C-data types plus complex floats, boolean, string, unicode, and void *).
Flexible data types where each array can have a different itemsize (but all elements of the same array still have the same itemsize).
Data types are Python objects
Data types have a type attribute that is a typeobject placing the data-type in a hierarchy of data-types.
Named fields are supported intrinsically on arrays. Record arrays allow named-field access using attributes.
Many more array methods in addition to functional counterparts.
Attributes more clearly distinguished from methods (attributes are intrinsic parts of an array so that setting them changes the array itself).
Array scalars covering all data types which inherit from Python scalars when appropriate.
Arrays can be misaligned, swapped, and in Fortran order in memory (facilitates memory-mapped arrays).
Arrays can be more easily read from text files and created from buffers.
Arrays can be quickly written to files in text and/or binary mode.
Arrays inherit from big arrays which do not define the sequence, or buffer protocol and can therefore be very large on 64-bit platforms.
Fancy indexing can be done on arrays using integer sequences and boolean masks.
Coercion rules are altered for mixed scalar / array operations so that scalars (anything that produces a 0-dimensional array internally) will not determine the output type in such cases.
When coercion is needed, temporary buffer-memory allocation is limited to a user-adjustable size.
Errors are handled through the IEEE floating point status flags and there is flexibility on a per function / module / builtin level for handling these errors.
One can register an error callback function in Python to handle errors which are set to 'call' for their error handling;
Ufunc reduce, accumulate, and reduceat can take place using a different type then the array type if desired (without copying the entire array);
Ufunc output arrays passed in can be a different type than expected from the calculation.
Arbitrary classes can be passed through ufuncs (using __array_wrap__ and __array_priority__).
Ufuncs can be easily created from Python functions.
Ufuncs have attributes to detail their behavior, including a dynamic doc string that automatically generates the calling signature.
Several new ufuncs (frexp, modf, ldexp, isnan, isfinite, isinf, signbit).
New types can be registered with the system so that specialized ufunc loops can be written for fast support of new type objects.
C-API enhanced so that more of the functionality is available from extension modules.
C-API enhanced so array structure access can take place through macros.
New iterator objects created for easy handling in C of discontiguous arrays.
Types have more functions associated with them (no magic function lists in the C-code). Any function needed is part of the type structure.

What's New in This Release:
The name of the array scalars has been changed from _arrtype to scalar to reflect the fact that they are no longer the sole flag-bearer of the array data-type. The dtype objects do that.
Names containing arrtype in numerictypes.py have been changed to sctype.
The elements of unicode arrays are now always 4-byte UCS4 unencoded full code-point characters. On narrow Python builds (where the unicode strings is 2-byte characters) conversion is done on element access using surrogate pairs.
Masked arrays with non-trivial masks are now supported better in ufuncs
A single axis= argument added to cross.
A .field method was added to recarray subclass for numarray compatibility and easy field-order access.
The dtype objects can now be indexed using field names and have a few new attributes: (shape, base, hasobject)
The coercion rules were fixed so that an integer scalar is not seen as a negative integer unless it is actually negative.
The optimized blas dot function was improved and fixed
The flat iterator object now exposes coords and index attributes
There were several improvements made to numpy.distutils:

- the search for site.cfg now looks in three standard places.
- improvements to compiler detection in numpy.distutils.
- pyrex support added to numpy.distutils
- many more...

NumPy now compiles with Microsoft MSVC compiler.
The -1 entry (field-order entry) of the fields dictionary is now always a tuple.
The .view method of arrays was modified to never return scalars.
The arange function was made more accurate for floating point arrays.
The C-API MACROS PyArray_BYTES(arr) and PyArray_DATA(arr) can both get at the array data: the former returns char * and the latter void *.
More tests were added, especially for nested records and unicode arrays.
Equality and inequality testing with None returns False and True respectively
A long-standing bug in dot (present in Numeric) on multidimensional arrays fixed.
ScipyTest renamed to NumpyTest (ScipyTest still available for compatibility).
Object data-type is not allowed as sub-types of record arrays. An error is now raised.
Coercion rules wer moved to the C-API and used in other array functions such as choose, clip, etc.
Long integers now convert to int64 integers in array if possible.
The string and unicode_ data-types don't print NULL bytes anymore.
Other bug-fixes.

NumPy 0.9.5 search tags