NumPy slithers to v1.16, prepares to shed skin of Python 2.7

NumPy slithers to v1.16, prepares to shed skin of Python 2.7

Scientific computing package for Python NumPy is now available in v1.16 and includes improved interoperability with ctypes, as well as better support for ARM and POWER architectures and the Python implementation PyPy.

One of the most notable changes might be an experimental way of overriding the implementation of NumPy functions on non-NumPy arrays. The idea was officially proposed in 2018 with the goal of establishing NumPy as a “high-level API for efficient multi-dimensional array operations”, to get a chance to use implementations of the ndarray API for different architectures together.

The protocol isn’t enabled by default yet, but lets users define an __array_function__ method to try the concept. The NumPy team plans to have it completely done by the time of the next release, where it is also meant to run faster thanks to a new implementation which is in the works now.

Since the logic to deal with structured dtypes in comparison ufuncs has been properly moved to the comparison operator, they will now error on structured dtypes as the other unfuncs do and not longer return NotImplemented. Also, the factor in the scaling of the covariance matrix in np.polyfit has been changed to chisq/(M-N), with M being the number of data points and N the number of parameters, to make it more compatible with other fitting programs.

NDArrayOperatorsMixin now implements matrix multiplication, since matmul (which calculates the matrix product of two arrays) is now a ufunc which can be overridden. The latter should for example improve the function’s performance.

NumPy 1.16 sees not only new additions but also comes with a couple of deprecations. Type dictionaries numpy.core.typeNA and numpy.core.sctypeNA for example will be removed in an upcoming release in favour of numpy.sctypeDict, and the same goes for numpy.asscalar since numpy.ndarray.item works better anyway.

Passing iterators to stack functions as well as applying the positive operator to non-numerical arrays are also amongst the new deprecations. To facilitate maintenance, np.lib.function_base.unique, np.PackageLoader and np.pkgload have finally been removed from the NumPy package.

NumPy 1.16 is a long term release which is supposed to get bug fixes until 2020. It’s the last to support Python 2.7, since support will be dropped in the upcoming 1.17 release. Python 2.7 was released in 2010 as the last larger update to the 2.x series.

Beside that, v1.17 will, amongst other things, include pocketfft which is supposed to offer a more exact way of calculating discrete Fourier transforms. The release could also see the implementation of a function drawing from a multivariate hypergeometric distribution which has been in the works since 2016 coming to fruition.

NumPy goes as far back as 2005, with roots back to 1995, when the Numeric project, which was part of NumPy’s foundation, was started. It is one of the most used Python packages, being especially beloved amongst data scientists, can be used cross-platform and includes linear algebra, Fourier transform and random number capabilities, as well as a widely-used N-dimensional array object and tools for integrating C/C++ and Fortran code. It is licensed under the BSD license.