Among other things, the new version allows developers to calculate the number of 1 bits in an integer thanks to the new
bit_count function, use comment blocks to generate C/C++ API reference documentation, and keep axis dimensions small when using
argmax in combination with new
interpolation= keyword argument in
percentile has been replaced by a new one
method= one, which is supposed to support 13 methods that align with scientific literature, R language, and previously available approaches. NumPy’s floating point and integer types have been equipped with a
float.is_integer implemented since the last version, and
numpy.number classes are now scriptable for Python 3.9 or newer, which should make it easier to use some expressions.
The latest iteration also addresses some more specific needs, providing things like an option to configure dispatchers for data segments of a
ndarray, which was included to help achieve hardware-specific optimizations. The addition was spurred by teams experiencing performance degradations using the usual memory management strategy, although most regular users will likely continue to accept the bottleneck for simplicity’s sake.
Meanwhile plugin for static type checker mypy has been extended to be able to set the specific platform
c_intp precision which is for example used as a data type for
Developers who want to get started with new additions quickly can take a look at the initial implementation of an enhancement proposal that aims to support the Python array API standard. The still-experimental feature allows users to ensure that their code is portable and works with a variety of other multidimensional array libraries such as TensorFlow and PyTorch. There is also a new header (
experimental_public_dtype_api.h) available to aid in future API investigations for user DType support and universal functions.
Apart from that, NumPy 1.22 marks the full annotation of the main NumPy namespace, a process that started while preparing for version 1.20 last year. Other subpackages that have since been outfitted with annotations include
For NumPy 1.22 to work properly, the library needs Python 3.8 or higher to be installed, as support for Python 3.7 was dropped with the release.
Before updating to the new version, developers should also be aware that passing boolean
kth values to
numpy.argpartition is no longer an option and was previously deprecated
mafromtxt has been deleted for good in v1.22. Other changes mean that the library will raise a TypeError if ground splitting of complex types is attempted and produce the same output class as the base function when
numpy.vectorize is used.