github numpy/numpy v1.22.0rc1

latest releases: v1.23.0rc1, v1.24.0.dev0, v1.22.4...
pre-release6 months ago

NumPy 1.22.0 Release Notes

NumPy 1.22.0 is a big release featuring the work of 150 contributers
spread over 575 pull requests. There have been many improvements,
highlights are:

  • Annotations of the main namespace are essentially complete. Upstream
    is a moving target, so there will likely be further improvements,
    but the major work is done. This is probably the most user visible
    enhancement in this release.
  • A preliminary version of the proposed Array-API is provided. This is
    a step in creating a standard collection of functions that can be
    used across application such as CuPy and JAX.
  • NumPy now has a DLPack backend. DLPack provides a common interchange
    format for array (tensor) data.
  • New methods for quantile, percentile, and related functions. The
    new methods provide a complete set of the methods commonly found in
    the literature.
  • A new configurable allocator for use by downstream projects.

These are in addition to the ongoing work to provide SIMD support for
commonly used functions, improvements to F2PY, and better documentation.

The Python versions supported in this release are 3.8-3.10, Python 3.7
has been dropped. Note that 32 bit wheels are only provided for Python
3.8 and 3.9 on Windows, all other wheels are 64 bits on account of
Ubuntu, Fedora, and other Linux distributions dropping 32 bit support.
All 64 bit wheels are also linked with 64 bit OpenBLAS, which should fix
the occasional problems encountered by folks using truly huge arrays.

Expired deprecations

Deprecated numeric style dtype strings have been removed

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

(gh-19539)

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.

(gh-19615)

Deprecations

Use delimiter rather than delimitor as kwarg in mrecords

The misspelled keyword argument delimitor of
numpy.ma.mrecords.fromtextfile() has been changed to delimiter,
using it will emit a deprecation warning.

(gh-19921)

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

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

(gh-20000)

The np.MachAr class has been deprecated

The numpy.MachAr class and finfo.machar <numpy.finfo> attribute have
been deprecated. Users are encouraged to access the property if interest
directly from the corresponding numpy.finfo attribute.

(gh-20201)

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.

(gh-19479)

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...

(gh-19135)

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.

(gh-19356)

Python 3.7 is no longer supported

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

(gh-19665)

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").

(gh-19687)

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).

(gh-20049)

Change in generation of random 32 bit floating point variates

There was bug in the generation of 32 bit floating point values from the
uniform distribution that would result in the least significant bit of
the random variate always being 0. This has been fixed.

This change affects the variates produced by the random.Generator
methods random, standard_normal, standard_exponential, and
standard_gamma, but only when the dtype is specified as
numpy.float32.

(gh-20314)

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.

(gh-19259)

New Features

NEP 49 configurable allocators

As detailed in NEP 49, the
function used for allocation of the data segment of a ndarray can be
changed. The policy can be set globally or in a context. For more
information see the NEP and the data_memory{.interpreted-text
role="ref"} reference docs. Also add a NUMPY_WARN_IF_NO_MEM_POLICY
override to warn on dangerous use of transfering ownership by setting
NPY_ARRAY_OWNDATA.

(gh-17582)

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.

(gh-18585)

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.

(gh-18884)

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
:

[mypy]
plugins = numpy.typing.mypy_plugin

(gh-19062)

Add NEP 47-compatible dlpack support

Add a ndarray.__dlpack__() method which returns a dlpack C structure
wrapped in a PyCapsule. Also add a np._from_dlpack(obj) function,
where obj supports __dlpack__(), and returns an ndarray.

(gh-19083)

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.

(gh-19211)

bit_count to compute the number of 1-bits in an integer

Computes the number of 1-bits in the absolute value of the input. This
works on all the numpy integer types. Analogous to the builtin
int.bit_count or popcount in C++.

>>> np.uint32(1023).bit_count()
10
>>> np.int32(-127).bit_count()
7

(gh-19355)

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.

(gh-19459)

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.

(gh-19513)

Added support for LoongArch

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

(gh-19527)

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.

(gh-19754)

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

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

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

(gh-19803)

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.

(gh-19805)

ndarray, dtype and number are now runtime-subscriptable

Mimicking 585{.interpreted-text role="pep"}, the numpy.ndarray,
numpy.dtype and numpy.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]]

(gh-19879)

Improvements

ctypeslib.load_library can now take any path-like object

All parameters in the can now take any
python:path-like object{.interpreted-text role="term"}. This includes
the likes of strings, bytes and objects implementing the
__fspath__<os.PathLike.__fspath__>{.interpreted-text role="meth"}
protocol.

(gh-17530)

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.

(gh-18536)

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.

(gh-19151)

numpy.fromregex now accepts os.PathLike implementations

numpy.fromregex now accepts objects implementing the
__fspath__<os.PathLike> protocol, e.g. pathlib.Path.

(gh-19680)

Add new methods for quantile and percentile

quantile and percentile now have have a method= keyword argument
supporting 13 different methods. This replaces the interpolation=
keyword argument.

The methods are now aligned with nine methods which can be found in
scientific literature and the R language. The remaining methods are the
previous discontinuous variations of the default "linear" one.

Please see the documentation of numpy.percentile for more information.

(gh-19857)

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 numpy.mean but absent from numpy.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

(gh-20027)

Annotating the main Numpy namespace

Starting from the 1.20 release, PEP 484 type annotations have been
included for parts of the NumPy library; annotating the remaining
functions being a work in progress. With the release of 1.22 this
process has been completed for the main NumPy namespace, which is now
fully annotated.

Besides the main namespace, a limited number of sub-packages contain
annotations as well. This includes, among others, numpy.testing,
numpy.linalg and numpy.random (available since 1.21).

(gh-20217)

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.

(gh-19478)

OpenBLAS v0.3.17

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

(gh-19462)

Checksums

MD5

a70dfdbb1e1dab6d5c10c5534c523288  numpy-1.22.0rc1-cp310-cp310-macosx_10_9_universal2.whl
2cccddd30f5ec841d4ce90530f7762b0  numpy-1.22.0rc1-cp310-cp310-macosx_10_9_x86_64.whl
7b46c1b0f8175b03d0197059c1d3a5d3  numpy-1.22.0rc1-cp310-cp310-macosx_11_0_arm64.whl
7adb43de081457fb9733ef4570a314e9  numpy-1.22.0rc1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
517ec9dede8b479ad986a14912fcc912  numpy-1.22.0rc1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
0379b78e387565067489943ca270ba59  numpy-1.22.0rc1-cp310-cp310-win_amd64.whl
f582541b1e4d322519d4f091a859b2bc  numpy-1.22.0rc1-cp38-cp38-macosx_10_9_universal2.whl
5239cc440f1353555c9e0273d4e68c91  numpy-1.22.0rc1-cp38-cp38-macosx_10_9_x86_64.whl
1a12742a23205cae3d2d5fda5cd8f478  numpy-1.22.0rc1-cp38-cp38-macosx_11_0_arm64.whl
4a45e2633361c367372d6c98d4e13010  numpy-1.22.0rc1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
15cf27d4ac60c720aa3f36308d90deb2  numpy-1.22.0rc1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
7cc2ffcfbe0f11234f7ba6a09e32980e  numpy-1.22.0rc1-cp38-cp38-win32.whl
64104bfd50dee174344d02506ab4c621  numpy-1.22.0rc1-cp38-cp38-win_amd64.whl
74b7c7f59058000d8437476ab880d943  numpy-1.22.0rc1-cp39-cp39-macosx_10_9_universal2.whl
7850ed6e906589c53b6e7187220f8dcc  numpy-1.22.0rc1-cp39-cp39-macosx_10_9_x86_64.whl
2a78c0df6943528302b3141e4b9b594b  numpy-1.22.0rc1-cp39-cp39-macosx_11_0_arm64.whl
1e65939095e4e383de6b8e257136a7a9  numpy-1.22.0rc1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
281f3e861afbff12ae9d0b32d95d89bb  numpy-1.22.0rc1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
f8b7d2e3b3b61894051e258b99cbb7b3  numpy-1.22.0rc1-cp39-cp39-win32.whl
5037a963c1486d9ce2eaa3adf84ab560  numpy-1.22.0rc1-cp39-cp39-win_amd64.whl
f82bd053250eee5dd4f35d2e4b8a8e64  numpy-1.22.0rc1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
17c532b2ccddb54595099c76ea4322b4  numpy-1.22.0rc1.tar.gz
f1c8568e6df223541d0c647044008949  numpy-1.22.0rc1.zip

SHA256

b00d9bf43cc8975cf5e0c211d218e75a3f5ce1ae34dc84d8a489c28a0dba7848  numpy-1.22.0rc1-cp310-cp310-macosx_10_9_universal2.whl
eb6dd744a9f94b424bf70d62b7874798ea95b6b58fb63ec651b69a46872e5bd5  numpy-1.22.0rc1-cp310-cp310-macosx_10_9_x86_64.whl
6759e6dafd96454be2d6dd80674293322191639400832688cd234c5f483ce1a9  numpy-1.22.0rc1-cp310-cp310-macosx_11_0_arm64.whl
2242fa31413e40847016234485f228fa5e082b0c555d3db65fe9aa4efcfb8d8d  numpy-1.22.0rc1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
d0be0eb7df39f0e0732d73250de55e1dcc8086c23db970d5eab85dbf0713502d  numpy-1.22.0rc1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
ccf027e3bbcd06b5c26a0196ddfc24c4d09d2001cc5d38738efff9d9ac8dee58  numpy-1.22.0rc1-cp310-cp310-win_amd64.whl
8c5016694b9bda77cda32ebfdde34d2246978ed4c49e9baab26bcf38621b7390  numpy-1.22.0rc1-cp38-cp38-macosx_10_9_universal2.whl
011e4c430f2e2739e0d182cb7e2b5d47adc46a8db49a788e5798805b7878c4ba  numpy-1.22.0rc1-cp38-cp38-macosx_10_9_x86_64.whl
b0ed56b9d7535d654d2a0478333cc08d1b9849767eafd07e1f6a3d8d90a2cad0  numpy-1.22.0rc1-cp38-cp38-macosx_11_0_arm64.whl
6730a1495f1acedd97e82e32cca4d8dbe07b89f01f395ca02ca4a9e110d9519d  numpy-1.22.0rc1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
56109e7e9b205439990e90682163d8155cf5743efe65c30221ef3834621ffd3f  numpy-1.22.0rc1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
7dbfa0abe053afbcb9e61ec1557556e4e30c3e4b5df4ec7849bf245e8c09feec  numpy-1.22.0rc1-cp38-cp38-win32.whl
013fa3500a6e5b3ba51401056aa9c41d83a7e737959d15f288d410f26cc33896  numpy-1.22.0rc1-cp38-cp38-win_amd64.whl
a2dd58beb8a8266d704a76692e8eb76ff20f5b2940db7aeee216c2dbf226e5c6  numpy-1.22.0rc1-cp39-cp39-macosx_10_9_universal2.whl
e48368972e0999af098e0a6e9a3573895fd4c3b0b2d8c5cf215b17910cd6c124  numpy-1.22.0rc1-cp39-cp39-macosx_10_9_x86_64.whl
2934fb435d85341efb40f9db637a203a042300afdaa49f833608df21a5d8ae30  numpy-1.22.0rc1-cp39-cp39-macosx_11_0_arm64.whl
e981667470ae74f06cfd0d54c5fa9cd88661a27eccaac2cba505039f0b29dc2e  numpy-1.22.0rc1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
5e56515f5abb493bd32d2196ecd3ce794792419adfb7d8b4cccd4ddaf74ab924  numpy-1.22.0rc1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
21613822dd597d4645c586ac21910fded5344f843410dace91c129a38c31d8be  numpy-1.22.0rc1-cp39-cp39-win32.whl
91bb1e29d74a90861e878b0c7bc941a1c0ac051cb4b171dc242e66953c95ca1e  numpy-1.22.0rc1-cp39-cp39-win_amd64.whl
0ebb646ef72a2348036ed1692e6bb3f3dd4f8d026681b7168a9ac988d9832c27  numpy-1.22.0rc1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
d54616321316987e69cb49d76cec8750d9d0160a32f5f5e71ff3f94b010ebc5e  numpy-1.22.0rc1.tar.gz
bc991b3f8ea7c0f6703df2bc23c098cfe6f1a3a5e8a3a901eb6a5619275d53ff  numpy-1.22.0rc1.zip

Don't miss a new numpy release

NewReleases is sending notifications on new releases.