NumPy 1.22.0 Release Notes


  • the misspelled keyword argument delimitor of has been changed into delimiter, using it will emit a deprecation warning.


Passing boolean kth values to (arg-)partition has been deprecated

partition and argpartition would previously accept boolean values for the kth parameter, which would subsequently be converted into integers. This behavior has now been deprecated.


Expired deprecations

  • Using the strings "Bytes0", "Datetime64", "Str0", "Uint32", and "Uint64" as a dtype will now raise a TypeError.


Expired deprecations for loads, ndfromtxt, and mafromtxt in npyio

numpy.loads was deprecated in v1.15, with the recommendation that users use pickle.loads instead. ndfromtxt and mafromtxt were both deprecated in v1.17 - users should use numpy.genfromtxt instead with the appropriate value for the usemask parameter.


Compatibility notes

Distutils forces strict floating point model on clang

NumPy now sets the -ftrapping-math option on clang to enforce correct floating point error handling for universal functions. Clang defaults to non-IEEE and C99 conform behaviour otherwise. This change (using the equivalent but newer -ffp-exception-behavior=strict) was attempted in NumPy 1.21, but was effectively never used.


C API changes

Masked inner-loops cannot be customized anymore

The masked inner-loop selector is now never used. A warning will be given in the unlikely event that it was customized.

We do not expect that any code uses this. If you do use it, you must unset the selector on newer NumPy version. Please also contact the NumPy developers, we do anticipate providing a new, more specific, mechanism.

The customization was part of a never-implemented feature to allow for faster masked operations.


New Features

Implementation of the NEP 47 (adopting the array API standard)

An initial implementation of NEP 47 (adoption the array API standard) has been added as numpy.array_api. The implementation is experimental and will issue a UserWarning on import, as the array API standard is still in draft state. numpy.array_api is a conforming implementation of the array API standard, which is also minimal, meaning that only those functions and behaviors that are required by the standard are implemented (see the NEP for more info). Libraries wishing to make use of the array API standard are encouraged to use numpy.array_api to check that they are only using functionality that is guaranteed to be present in standard conforming implementations.


Generate C/C++ API reference documentation from comments blocks is now possible

This feature depends on Doxygen in the generation process and on Breathe to integrate it with Sphinx.


Assign the platform-specific c_intp precision via a mypy plugin

The mypy plugin, introduced in numpy/numpy#17843, has again been expanded: the plugin now is now responsible for setting the platform-specific precision of numpy.ctypeslib.c_intp, the latter being used as data type for various numpy.ndarray.ctypes attributes.

Without the plugin, aforementioned type will default to ctypes.c_int64.

To enable the plugin, one must add it to their mypy configuration file:

plugins = numpy.typing.mypy_plugin


keepdims optional argument added to numpy.argmin, numpy.argmax

keepdims argument is added to numpy.argmin, numpy.argmax. If set to True, the axes which are reduced are left in the result as dimensions with size one. The resulting array has the same number of dimensions and will broadcast with the input array.


The ndim and axis attributes have been added to numpy.AxisError

The ndim and axis parameters are now also stored as attributes within each numpy.AxisError instance.


Preliminary support for windows/arm64 target

numpy added support for windows/arm64 target. Please note OpenBLAS support is not yet available for windows/arm64 target.


Added support for LoongArch

LoongArch is a new instruction set, numpy compilation failure on LoongArch architecture, so add the commit.


A .clang-format file has been added

Clang-format is a C/C++ code formatter, together with the added .clang-format file, it produces code close enough to the NumPy C_STYLE_GUIDE for general use. Clang-format version 12+ is required due to the use of several new features, it is available in Fedora 34 and Ubuntu Focal among other distributions.


is_integer is now available to numpy.floating and numpy.integer

Based on its counterpart in float and int, the numpy floating point and integer types now support is_integer. Returns True if the number is finite with integral value, and False otherwise.

>>> np.float32(-2.0).is_integer()
>>> np.float64(3.2).is_integer()
>>> np.int32(-2).is_integer()


Symbolic parser for Fortran dimension specifications

A new symbolic parser has been added to f2py in order to correctly parse dimension specifications. The parser is the basis for future improvements and provides compatibility with Draft Fortran 202x.


ndarray, dtype and number are now runtime-subscriptable

Mimicking PEP 585, the ndarray, dtype and number classes are now subscriptable for python 3.9 and later. Consequently, expressions that were previously only allowed in .pyi stub files or with the help of from __future__ import annotations are now also legal during runtime.

>>> import numpy as np
>>> from typing import Any

>>> np.ndarray[Any, np.dtype[np.float64]]
numpy.ndarray[typing.Any, numpy.dtype[numpy.float64]]



ctypeslib.load_library can now take any path-like object

All parameters in the can now take any path-like object. This includes the likes of strings, bytes and objects implementing the __fspath__ protocol.


Add smallest_normal and smallest_subnormal attributes to finfo

The attributes smallest_normal and smallest_subnormal are available as an extension of finfo class for any floating-point data type. To use these new attributes, write np.finfo(np.float64).smallest_normal or np.finfo(np.float64).smallest_subnormal.


numpy.linalg.qr accepts stacked matrices as inputs

numpy.linalg.qr is able to produce results for stacked matrices as inputs. Moreover, the implementation of QR decomposition has been shifted to C from Python.


numpy.fromregex now accepts os.PathLike implementations

numpy.fromregex now accepts objects implementing the __fspath__ protocol, e.g. pathlib.Path.


Missing parameters have been added to the nan<x> functions

A number of the nan<x> functions previously lacked parameters that were present in their <x>-based counterpart, e.g. the where parameter was present in mean but absent from nanmean.

The following parameters have now been added to the nan<x> functions:

  • nanmin: initial & where

  • nanmax: initial & where

  • nanargmin: keepdims & out

  • nanargmax: keepdims & out

  • nansum: initial & where

  • nanprod: initial & where

  • nanmean: where

  • nanvar: where

  • nanstd: where


Performance improvements and changes

Vectorize umath module using AVX-512

By leveraging Intel Short Vector Math Library (SVML), 18 umath functions (exp2, log2, log10, expm1, log1p, cbrt, sin, cos, tan, arcsin, arccos, arctan, sinh, cosh, tanh, arcsinh, arccosh, arctanh) are vectorized using AVX-512 instruction set for both single and double precision implementations. This change is currently enabled only for Linux users and on processors with AVX-512 instruction set. It provides an average speed up of 32x and 14x for single and double precision functions respectively.



Removed floor division support for complex types

Floor division of complex types will now result in a TypeError

>>> a = np.arange(10) + 1j* np.arange(10)
>>> a // 1
TypeError: ufunc 'floor_divide' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''


numpy.vectorize functions now produce the same output class as the base function

When a function that respects numpy.ndarray subclasses is vectorized using numpy.vectorize, the vectorized function will now be subclass-safe also for cases that a signature is given (i.e., when creating a gufunc): the output class will be the same as that returned by the first call to the underlying function.


OpenBLAS v0.3.17

Update the OpenBLAS used in testing and in wheels to v0.3.17


Python 3.7 is no longer supported

Python support has been dropped. This is rather strict, there are changes that require Python >=3.8.


str/repr of complex dtypes now include space after punctuation

The repr of np.dtype({"names": ["a"], "formats": [int], "offsets": [2]}) is now dtype({'names': ['a'], 'formats': ['<i8'], 'offsets': [2], 'itemsize': 10}), whereas spaces where previously omitted after colons and between fields.

The old behavior can be restored via np.set_printoptions(legacy="1.21").


Corrected advance in PCG64DSXM and PCG64

Fixed a bug in the advance method of PCG64DSXM and PCG64. The bug only affects results when the step was larger than \(2^{64}\) on platforms that do not support 128-bit integers(e.g., Windows and 32-bit Linux).


NumPy 1.22.0 Release Notes


New functions


Future Changes

Expired deprecations

Compatibility notes

C API changes

New Features