Numpy: v1.23.0rc3 Release

Release date:
June 10, 2022
Previous version:
v1.23.0rc2 (released June 10, 2022)
Magnitude:
5,992 Diff Delta
Contributors:
27 total committers
Data confidence:
Commits:

70 Commits in this Release

Ordered by the degree to which they evolved the repo in this version.

Authored July 1, 2021
Authored June 9, 2022
Authored June 10, 2022
Authored June 3, 2022
Authored June 3, 2022
Authored May 26, 2022

Top Contributors in v1.23.0rc3

pearu
seberg
rossbar
seiko2plus
BvB93
jhonatancunha
toslunar
HaoZeke
rjeb
dcaliste

Directory Browser for v1.23.0rc3

We haven't yet finished calculating and confirming the files and directories changed in this release. Please check back soon.

Release Notes Published

NumPy 1.23.0 Release Notes

The NumPy 1.23.0 release continues the ongoing work to improve the handling and promotion of dtypes, increase the execution speed, clarify the documentation, and expire old deprecations. The highlights are:

  • Implementation of loadtxt in C, greatly improving its performance.
  • Exposing DLPack at the Python level for easy data exchange.
  • Changes to the promotion and comparisons of structured dtypes.
  • Improvements to f2py.

See below for the details,

New functions

  • A masked array specialization of ndenumerate is now available as numpy.ma.ndenumerate. It provides an alternative to numpy.ndenumerate and skips masked values by default.

    (gh-20020)

  • numpy.from_dlpack has been added to allow easy exchange of data using the DLPack protocol. It accepts Python objects that implement the __dlpack__ and __dlpack_device__ methods and returns a ndarray object which is generally the view of the data of the input object.

    (gh-21145)

Deprecations

  • Setting __array_finalize__ to None is deprecated. It must now be a method and may wish to call super().__array_finalize__(obj) after checking for None or if the NumPy version is sufficiently new.

    (gh-20766)

  • Using axis=32 (axis=np.MAXDIMS) in many cases had the same meaning as axis=None. This is deprecated and axis=None must be used instead.

    (gh-20920)

  • The hook function PyDataMem_SetEventHook has been deprecated and the demonstration of its use in tool/allocation_tracking has been removed. The ability to track allocations is now built-in to python via tracemalloc.

    (gh-20394)

  • numpy.distutils has been deprecated, as a result of distutils itself being deprecated. It will not be present in NumPy for Python >= 3.12, and will be removed completely 2 years after the release of Python 3.12 For more details, see distutils-status-migration{.interpreted-text role="ref"}.

    (gh-20875)

  • numpy.loadtxt will now give a DeprecationWarning when an integer dtype is requested but the value is formatted as a floating point number.

(gh-21663)

Expired deprecations

  • The NpzFile.iteritems() and NpzFile.iterkeys() methods have been removed as part of the continued removal of Python 2 compatibility. This concludes the deprecation from 1.15.

    (gh-16830)

  • The alen and asscalar functions have been removed.

    (gh-20414)

  • The UPDATEIFCOPY array flag has been removed together with the enum NPY_ARRAY_UPDATEIFCOPY. The associated (and deprecated) PyArray_XDECREF_ERR was also removed. These were all deprecated in 1.14. They are replaced by WRITEBACKIFCOPY, that requires calling PyArray_ResoveWritebackIfCopy before the array is deallocated.

    (gh-20589)

  • Exceptions will be raised during array-like creation. When an object raised an exception during access of the special attributes __array__ or __array_interface__, this exception was usually ignored. This behaviour was deprecated in 1.21, and the exception will now be raised.

    (gh-20835)

  • Multidimensional indexing with non-tuple values is not allowed. Previously, code such as arr[ind] where ind = [[0, 1], [0, 1]] produced a FutureWarning and was interpreted as a multidimensional index (i.e., arr[tuple(ind)]). Now this example is treated like an array index over a single dimension (arr[array(ind)]). Multidimensional indexing with anything but a tuple was deprecated in NumPy 1.15.

    (gh-21029)

  • Changing to a dtype of different size in F-contiguous arrays is no longer permitted. Deprecated since Numpy 1.11.0. See below for an extended explanation of the effects of this change.

    (gh-20722)

New Features

crackfortran has support for operator and assignment overloading

crackfortran parser now understands operator and assignment definitions in a module. They are added in the body list of the module which contains a new key implementedby listing the names of the subroutines or functions implementing the operator or assignment.

(gh-15006)

f2py supports reading access type attributes from derived type statements

As a result, one does not need to use public or private statements to specify derived type access properties.

(gh-15844)

New parameter ndmin added to genfromtxt

This parameter behaves the same as ndmin from numpy.loadtxt.

(gh-20500)

np.loadtxt now supports quote character and single converter function

numpy.loadtxt now supports an additional quotechar keyword argument which is not set by default. Using quotechar='"' will read quoted fields as used by the Excel CSV dialect.

Further, it is now possible to pass a single callable rather than a dictionary for the converters argument.

(gh-20580)

Changing to dtype of a different size now requires contiguity of only the last axis

Previously, viewing an array with a dtype of a different item size required that the entire array be C-contiguous. This limitation would unnecessarily force the user to make contiguous copies of non-contiguous arrays before being able to change the dtype.

This change affects not only ndarray.view, but other construction mechanisms, including the discouraged direct assignment to ndarray.dtype.

This change expires the deprecation regarding the viewing of F-contiguous arrays, described elsewhere in the release notes.

(gh-20722)

Deterministic output files for F2PY

For F77 inputs, f2py will generate modname-f2pywrappers.f unconditionally, though these may be empty. For free-form inputs, modname-f2pywrappers.f, modname-f2pywrappers2.f90 will both be generated unconditionally, and may be empty. This allows writing generic output rules in cmake or meson and other build systems. Older behavior can be restored by passing --skip-empty-wrappers to f2py. f2py-meson{.interpreted-text role="ref"} details usage.

(gh-21187)

keepdims parameter for average

The parameter keepdims was added to the functions numpy.average and numpy.ma.average. The parameter has the same meaning as it does in reduction functions such as numpy.sum or numpy.mean.

(gh-21485)

New parameter equal_nan added to np.unique

np.unique was changed in 1.21 to treat all NaN values as equal and return a single NaN. Setting equal_nan=False will restore pre-1.21 behavior to treat NaNs as unique. Defaults to True.

(gh-21623)

Compatibility notes

1D np.linalg.norm preserves float input types, even for scalar results

Previously, this would promote to float64 when the ord argument was not one of the explicitly listed values, e.g. ord=3:

>>> f32 = np.float32([1, 2])
>>> np.linalg.norm(f32, 2).dtype
dtype('float32')
>>> np.linalg.norm(f32, 3)
dtype('float64')  # numpy 1.22
dtype('float32')  # numpy 1.23

This change affects only float32 and float16 vectors with ord other than -Inf, 0, 1, 2, and Inf.

(gh-17709)

Changes to structured (void) dtype promotion and comparisons

In general, NumPy now defines correct, but slightly limited, promotion for structured dtypes by promoting the subtypes of each field instead of raising an exception:

>>> np.result_type(np.dtype("i,i"), np.dtype("i,d"))
dtype([('f0', '<i4'), ('f1', '<f8')])

For promotion matching field names, order, and titles are enforced, however padding is ignored. Promotion involving structured dtypes now always ensures native byte-order for all fields (which may change the result of np.concatenate) and ensures that the result will be \"packed\", i.e. all fields are ordered contiguously and padding is removed. See structured_dtype_comparison_and_promotion{.interpreted-text role="ref"} for further details.

The repr of aligned structures will now never print the long form including offsets and itemsize unless the structure includes padding not guaranteed by align=True.

In alignment with the above changes to the promotion logic, the casting safety has been updated:

  • "equiv" enforces matching names and titles. The itemsize is allowed to differ due to padding.
  • "safe" allows mismatching field names and titles
  • The cast safety is limited by the cast safety of each included field.
  • The order of fields is used to decide cast safety of each individual field. Previously, the field names were used and only unsafe casts were possible when names mismatched.

The main important change here is that name mismatches are now considered \"safe\" casts.

(gh-19226)

NPY_RELAXED_STRIDES_CHECKING has been removed

NumPy cannot be compiled with NPY_RELAXED_STRIDES_CHECKING=0 anymore. Relaxed strides have been the default for many years and the option was initially introduced to allow a smoother transition.

(gh-20220)

np.loadtxt has recieved several changes

The row counting of numpy.loadtxt was fixed. loadtxt ignores fully empty lines in the file, but counted them towards max_rows. When max_rows is used and the file contains empty lines, these will now not be counted. Previously, it was possible that the result contained fewer than max_rows rows even though more data was available to be read. If the old behaviour is required, itertools.islice may be used:

import itertools
lines = itertools.islice(open("file"), 0, max_rows)
result = np.loadtxt(lines, ...)

While generally much faster and improved, numpy.loadtxt may now fail to converter certain strings to numbers that were previously successfully read. The most important cases for this are:

  • Parsing floating point values such as 1.0 into integers is now deprecated.
  • Parsing hexadecimal floats such as 0x3p3 will fail
  • An _ was previously accepted as a thousands delimiter 100_000. This will now result in an error.

If you experience these limitations, they can all be worked around by passing appropriate converters=. NumPy now supports passing a single converter to be used for all columns to make this more convenient. For example, converters=float.fromhex can read hexadecimal float numbers and converters=int will be able to read 100_000.

Further, the error messages have been generally improved. However, this means that error types may differ. In particularly, a ValueError is now always raised when parsing of a single entry fails.

(gh-20580)

Improvements

ndarray.__array_finalize__ is now callable

This means subclasses can now use super().__array_finalize__(obj) without worrying whether ndarray is their superclass or not. The actual call remains a no-op.

(gh-20766)

Add support for VSX4/Power10

With VSX4/Power10 enablement, the new instructions available in Power ISA 3.1 can be used to accelerate some NumPy operations, e.g., floor_divide, modulo, etc.

(gh-20821)

np.fromiter now accepts objects and subarrays

The numpy.fromiter function now supports object and subarray dtypes. Please see he function documentation for examples.

(gh-20993)

Math C library feature detection now uses correct signatures

Compiling is preceded by a detection phase to determine whether the underlying libc supports certain math operations. Previously this code did not respect the proper signatures. Fixing this enables compilation for the wasm-ld backend (compilation for web assembly) and reduces the number of warnings.

(gh-21154)

np.kron now maintains subclass information

np.kron maintains subclass information now such as masked arrays while computing the Kronecker product of the inputs

>>> x = ma.array([[1, 2], [3, 4]], mask=[[0, 1], [1, 0]])
>>> np.kron(x,x)
masked_array(
  data=[[1, --, --, --],
        [--, 4, --, --],
        [--, --, 4, --],
        [--, --, --, 16]],
  mask=[[False,  True,  True,  True],
        [ True, False,  True,  True],
        [ True,  True, False,  True],
        [ True,  True,  True, False]],
  fill_value=999999)

:warning: Warning, np.kron output now follows ufunc ordering (multiply) to determine the output class type

>>> class myarr(np.ndarray):
>>>    __array_priority__ = -1
>>> a = np.ones([2, 2])
>>> ma = myarray(a.shape, a.dtype, a.data)
>>> type(np.kron(a, ma)) == np.ndarray
False # Before it was True
>>> type(np.kron(a, ma)) == myarr
True

(gh-21262)

String comparisons now supported in ufuncs

The comparison ufuncs [np.equal]{.title-ref}, [np.greater]{.title-ref}, etc. now support unicode and byte string inputs (dtypes S and U). Due to this change a FutureWarning is now given when comparing unicode to byte strings. Such comparisons always returned False and continue to do so at this time.

(gh-21716)

Performance improvements and changes

Faster np.loadtxt

numpy.loadtxt is now generally much faster than previously as most of it is now implemented in C.

(gh-20580)

Faster reduction operators

Reduction operations like numpy.sum, numpy.prod, numpy.add.reduce, numpy.logical_and.reduce on contiguous integer-based arrays are now much faster.

(gh-21001)

Faster np.where

numpy.where is now much faster than previously on unpredictable/random input data.

(gh-21130)

Faster operations on NumPy scalars

Many operations on NumPy scalars are now significantly faster, although rare operations (e.g. with 0-D arrays rather than scalars) may be slower in some cases. However, even with these improvements users who want the best performance for their scalars, may want to convert a known NumPy scalar into a Python one using scalar.item().

(gh-21188)

Faster np.kron

numpy.kron is about 80% faster as the product is now computed using broadcasting.

(gh-21354)

Checksums

MD5

527ffa92c1e964bfcfd09497a319090e  numpy-1.23.0rc3-cp310-cp310-macosx_10_9_x86_64.whl
14538d5c5a9f07c7c54b8f27ffcfcdf8  numpy-1.23.0rc3-cp310-cp310-macosx_11_0_arm64.whl
2914affc99c1d00a1e31689dfe8200c1  numpy-1.23.0rc3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
a72038b74d0fe5d43967fa3c3f44a71a  numpy-1.23.0rc3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
b1c01a974cf10fdefe7c346aa09bc20a  numpy-1.23.0rc3-cp310-cp310-win32.whl
b1ae6d311ad01f15a7cf28dbb906d2a4  numpy-1.23.0rc3-cp310-cp310-win_amd64.whl
ea734f44ae2b10c9cf1530eece6c58d6  numpy-1.23.0rc3-cp38-cp38-macosx_10_9_x86_64.whl
8bc2051b1172627cbb7ca503a75fcdd8  numpy-1.23.0rc3-cp38-cp38-macosx_11_0_arm64.whl
495efaf5566fd119a0f0b4c9339449ed  numpy-1.23.0rc3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
1b93121d0c339b35dc83b92fa67a3545  numpy-1.23.0rc3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
50433ef3beaab89d5485d0fe7cbbaaaa  numpy-1.23.0rc3-cp38-cp38-win32.whl
9014a7e33d01fd4d36298836b3199eac  numpy-1.23.0rc3-cp38-cp38-win_amd64.whl
13661a5d83fd2bb423514681d0d00de4  numpy-1.23.0rc3-cp39-cp39-macosx_10_9_x86_64.whl
11386871be967bcb5331d8289b1186a6  numpy-1.23.0rc3-cp39-cp39-macosx_11_0_arm64.whl
43e6fa27b8ab7cb367103d1b890ca7c5  numpy-1.23.0rc3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
b9aa6e6cb2ad37993ea4c70e7edeec4c  numpy-1.23.0rc3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
030669015597201aca83e8cb2d2f82ed  numpy-1.23.0rc3-cp39-cp39-win32.whl
ffab9ff64e6a08784dfb0eab430d4158  numpy-1.23.0rc3-cp39-cp39-win_amd64.whl
758408262bfc96942193e22cbfdab6dc  numpy-1.23.0rc3-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
27fb60bd1cd54e785aa63b1a29b32fb1  numpy-1.23.0rc3-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
b8819d1885f39a67917faf131e716a16  numpy-1.23.0rc3-pp38-pypy38_pp73-win_amd64.whl
b6e3a4784ce0ab3d1a9d850fde5049a3  numpy-1.23.0rc3.tar.gz

SHA256

5716acbd372407b046d168228217533d48f46b1fb76a788a01ce7b446d85e054  numpy-1.23.0rc3-cp310-cp310-macosx_10_9_x86_64.whl
65ac805918a4793aa50a0f366f0a31aa67e85a3e9a28fbdc49bec076ea9d59dd  numpy-1.23.0rc3-cp310-cp310-macosx_11_0_arm64.whl
3947ff9ea7f50d44a0c278fb9c9b43109e6b2e02273b4b3341f3eea9fe31cc76  numpy-1.23.0rc3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
8635887a615e8d3cf0ce35c401b30ccf7818eb58c9ac282561b2363d85729150  numpy-1.23.0rc3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
68d6f3794c78b37faf015c9d60207aaf156edfaf96b1d8c01a2694953b979b8f  numpy-1.23.0rc3-cp310-cp310-win32.whl
c3237a338d59e271145e9773020b49dfb77314b749bde67783c45d946346a13f  numpy-1.23.0rc3-cp310-cp310-win_amd64.whl
db5a2b42d09cc0661fec75b4e3daabff91a4858e67ee106fb793ebcd02ebd7b6  numpy-1.23.0rc3-cp38-cp38-macosx_10_9_x86_64.whl
fd999d0b503dce88fd97153986c3970154c965cfd1c9835f610e89f0dda3bda3  numpy-1.23.0rc3-cp38-cp38-macosx_11_0_arm64.whl
bc58787ee33ff7828be36b656b08ddaefb7b24339aacd2e21fb28fc49b44008c  numpy-1.23.0rc3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
fae0b80e6b85e3a72a8f7dab8af91199da31b6d0d86fab36529945f23f806d35  numpy-1.23.0rc3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
ca12e7773b4f76addf2f91dad61307426f9c1fdf8da5c00b49080af56a9eeff8  numpy-1.23.0rc3-cp38-cp38-win32.whl
f403bea354d3c892ab1da29ab9d14d51149491a32731b32a94608e3dcd514533  numpy-1.23.0rc3-cp38-cp38-win_amd64.whl
849e7aa12c1df7e9f26d1936029710bb6050bc31c9cc9772d83c30e3fc7cf8e9  numpy-1.23.0rc3-cp39-cp39-macosx_10_9_x86_64.whl
e9ad17a823c106dbed8675f4d831381fe99e9df9945485792d8762c186259dcd  numpy-1.23.0rc3-cp39-cp39-macosx_11_0_arm64.whl
03d5111e85d6371ffc3678824542a8df69ea206f16f83de76ac10231d40c006b  numpy-1.23.0rc3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
b757b22fab2a3ff1f41d0f2cb69bed337eda211db7a2c981b3f93180e4aa68ea  numpy-1.23.0rc3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
87fd874392c7f8ee23829b4ac6737b19a20aeff2418169afc3e6da00c0e23bc1  numpy-1.23.0rc3-cp39-cp39-win32.whl
f159357529470285dff46e69d97e3c9694b0bd75229e4592edb02f8b812c7a4c  numpy-1.23.0rc3-cp39-cp39-win_amd64.whl
a0be42a51fbb6087049dfa9b036568e9674a25fb4615f2bf60f189f435691aa4  numpy-1.23.0rc3-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
da170cde43519e5490a1887898719e881575d0f0924ef35fe66d990246db6f0e  numpy-1.23.0rc3-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
33aa550e001817c8075c56a3b350fb3687cba66ee55dfbb09085d0d0fd63f6e9  numpy-1.23.0rc3-pp38-pypy38_pp73-win_amd64.whl
6a8fc5573cc8cb8108cec555bca5745d2798c54eef107d478b4320c1f6542102  numpy-1.23.0rc3.tar.gz