NumPy 1.5.0 Release Notes β€” NumPy v2.3.dev0 Manual (original) (raw)

Highlights#

Python 3 compatibility#

This is the first NumPy release which is compatible with Python 3. Support for Python 3 and Python 2 is done from a single code base. Extensive notes on changes can be found athttps://web.archive.org/web/20100814160313/http://projects.scipy.org/numpy/browser/trunk/doc/Py3K.txt.

Note that the Numpy testing framework relies on nose, which does not have a Python 3 compatible release yet. A working Python 3 branch of nose can be found at https://web.archive.org/web/20100817112505/http://bitbucket.org/jpellerin/nose3/ however.

Porting of SciPy to Python 3 is expected to be completed soon.

PEP 3118 compatibility#

The new buffer protocol described by PEP 3118 is fully supported in this version of Numpy. On Python versions >= 2.6 Numpy arrays expose the buffer interface, and array(), asarray() and other functions accept new-style buffers as input.

New features#

Warning on casting complex to real#

Numpy now emits a numpy.ComplexWarning when a complex number is cast into a real number. For example:

x = np.array([1,2,3]) x[:2] = np.array([1+2j, 1-2j]) ComplexWarning: Casting complex values to real discards the imaginary part

The cast indeed discards the imaginary part, and this may not be the intended behavior in all cases, hence the warning. This warning can be turned off in the standard way:

import warnings warnings.simplefilter("ignore", np.ComplexWarning)

Dot method for ndarrays#

Ndarrays now have the dot product also as a method, which allows writing chains of matrix products as

instead of the longer alternative

np.dot(a, np.dot(b, c))

linalg.slogdet function#

The slogdet function returns the sign and logarithm of the determinant of a matrix. Because the determinant may involve the product of many small/large values, the result is often more accurate than that obtained by simple multiplication.

Changes#

polynomial.polynomial#

polynomial.chebyshev#

histogram#

After a two years transition period, the old behavior of the histogram function has been phased out, and the β€œnew” keyword has been removed.

correlate#

The old behavior of correlate was deprecated in 1.4.0, the new behavior (the usual definition for cross-correlation) is now the default.