Update dependency numpy to v2 #1386
Draft
+69
−50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains the following updates:
^1.24.1
->^2.0.0
==1.26.4
->==2.1.3
Release Notes
numpy/numpy (numpy)
v2.1.3
Compare Source
v2.1.2
Compare Source
v2.1.1
: 2.1.1 (Sep 3, 2024)Compare Source
NumPy 2.1.1 Release Notes
NumPy 2.1.1 is a maintenance release that fixes bugs and regressions
discovered after the 2.1.0 release.
The Python versions supported by this release are 3.10-3.13.
Contributors
A total of 7 people contributed to this release. People with a "+" by
their names contributed a patch for the first time.
Pull requests merged
A total of 10 pull requests were merged for this release.
Checksums
MD5
SHA256
v2.1.0
Compare Source
v2.0.2
: NumPy 2.0.2 release (Aug 26, 2024)Compare Source
NumPy 2.0.2 Release Notes
NumPy 2.0.2 is a maintenance release that fixes bugs and regressions
discovered after the 2.0.1 release.
The Python versions supported by this release are 3.9-3.12.
Contributors
A total of 13 people contributed to this release. People with a "+" by
their names contributed a patch for the first time.
Pull requests merged
A total of 19 pull requests were merged for this release.
alltrue
andsometrue
npyv_loadable_stride_
functions for ldexp and...np.save
Checksums
MD5
SHA256
v2.0.1
Compare Source
NumPy 2.0.1 Release Notes
NumPy 2.0.1 is a maintenance release that fixes bugs and regressions
discovered after the 2.0.0 release. NumPy 2.0.1 is the last planned
release in the 2.0.x series, 2.1.0rc1 should be out shortly.
The Python versions supported by this release are 3.9-3.12.
NOTE: Do not use the GitHub generated "Source code" files listed in the "Assets", they are garbage.
Improvements
np.quantile
with methodclosest_observation
chooses nearest even order statisticThis changes the definition of nearest for border cases from the nearest
odd order statistic to nearest even order statistic. The numpy
implementation now matches other reference implementations.
(gh-26656)
Contributors
A total of 15 people contributed to this release. People with a "+" by
their names contributed a patch for the first time.
Pull requests merged
A total of 24 pull requests were merged for this release.
ma/extras.pyi
stubset_printoptions
loadtxt
PyArray_FillWithScalar
Checksums
MD5
SHA256
v2.0.0
Compare Source
NumPy 2.0.0 Release Notes
NumPy 2.0.0 is the first major release since 2006. It is the result of
11 months of development since the last feature release and is the work
of 212 contributors spread over 1078 pull requests. It contains a large
number of exciting new features as well as changes to both the Python
and C APIs.
This major release includes breaking changes that could not happen in a
regular minor (feature) release - including an ABI break, changes to
type promotion rules, and API changes which may not have been emitting
deprecation warnings in 1.26.x. Key documents related to how to adapt to
changes in NumPy 2.0, in addition to these release notes, include:
Highlights
Highlights of this release include:
numpy.dtypes.StringDType
and a newnumpy.strings
namespace with performant ufuncs for string operations,float32
andlongdouble
in allnumpy.fft
functions,numpy
namespace.
sort
,argsort
,partition
,argpartition
have beenaccelerated through the use of the Intel x86-simd-sort and
Google Highway libraries, and may see large (hardware-specific)
speedups,
significant performance improvements for linear algebra
operations on macOS, and wheels that are about 3 times smaller,
numpy.char
fixed-length string operations havebeen accelerated by implementing ufuncs that also support
numpy.dtypes.StringDType
in addition to thefixed-length string dtypes,
numpy.lib.introspect.opt_func_info
, to determinewhich hardware-specific kernels are available and will be
dispatched to.
numpy.save
now uses pickle protocol version 4 for savingarrays with object dtype, which allows for pickle objects larger
than 4GB and improves saving speed by about 5% for large arrays.
structure and each public function now available in a single place.
should make it easier to learn and use NumPy. The number of
objects in the main namespace decreased by ~10% and in
numpy.lib
by ~80%.Canonical dtype names and a new
numpy.isdtype` introspectionfunction,
internals hidden to ease future extensibility,
PyArray_ImportNumPyAPI
and
PyUFunc_ImportUFuncAPI
.This fixes many user surprises about promotions which previously often
depended on data values of input arrays rather than only their dtypes.
Please see the NEP and the numpy-2-migration-guide for details as this
change can lead to changes in output dtypes and lower precision results
for mixed-dtype operations.
int64
rather thanint32
, matching the behavior on other platforms,there is now documentation on NumPy's
module structure,
Furthermore there are many changes to NumPy internals, including
continuing to migrate code from C to C++, that will make it easier to
improve and maintain NumPy in the future.
The "no free lunch" theorem dictates that there is a price to pay for
all these API and behavior improvements and better future extensibility.
This price is:
Backwards compatibility. There are a significant number of breaking
changes to both the Python and C APIs. In the majority of cases,
there are clear error messages that will inform the user how to
adapt their code. However, there are also changes in behavior for
which it was not possible to give such an error message - these
cases are all covered in the Deprecation and Compatibility sections
below, and in the numpy-2-migration-guide.
Note that there is a
ruff
mode to auto-fix many things in Pythoncode.
Breaking changes to the NumPy ABI. As a result, binaries of packages
that use the NumPy C API and were built against a NumPy 1.xx release
will not work with NumPy 2.0. On import, such packages will see an
ImportError
with a message about binary incompatibility.It is possible to build binaries against NumPy 2.0 that will work at
runtime with both NumPy 2.0 and 1.x. See numpy-2-abi-handling for more
details.
All downstream packages that depend on the NumPy ABI are advised
to do a new release built against NumPy 2.0 and verify that that
release works with both 2.0 and 1.26 - ideally in the period between
2.0.0rc1 (which will be ABI-stable) and the final 2.0.0 release to
avoid problems for their users.
The Python versions supported by this release are 3.9-3.12.
NumPy 2.0 Python API removals
np.geterrobj
,np.seterrobj
and the related ufunc keywordargument
extobj=
have been removed. The preferred replacement forall of these is using the context manager
with np.errstate():
.(gh-23922)
np.cast
has been removed. The literal replacement fornp.cast[dtype](arg)
isnp.asarray(arg, dtype=dtype)
.np.source
has been removed. The preferred replacement isinspect.getsource
.np.lookfor
has been removed.(gh-24144)
numpy.who
has been removed. As an alternative for the removedfunctionality, one can use a variable explorer that is available in
IDEs such as Spyder or Jupyter Notebook.
(gh-24321)
Warnings and exceptions present in
numpy.exceptions
,e.g,
numpy.exceptions.ComplexWarning
,numpy.exceptions.VisibleDeprecationWarning
, are nolonger exposed in the main namespace.
Multiple niche enums, expired members and functions have been
removed from the main namespace, such as:
ERR_*
,SHIFT_*
,np.fastCopyAndTranspose
,np.kernel_version
,np.numarray
,np.oldnumeric
andnp.set_numeric_ops
.(gh-24316)
Replaced
from ... import *
in thenumpy/__init__.py
withexplicit imports. As a result, these main namespace members got
removed:
np.FLOATING_POINT_SUPPORT
,np.FPE_*
,np.NINF
,np.PINF
,np.NZERO
,np.PZERO
,np.CLIP
,np.WRAP
,np.WRAP
,np.RAISE
,np.BUFSIZE
,np.UFUNC_BUFSIZE_DEFAULT
,np.UFUNC_PYVALS_NAME
,np.ALLOW_THREADS
,np.MAXDIMS
,np.MAY_SHARE_EXACT
,np.MAY_SHARE_BOUNDS
,add_newdoc
,np.add_docstring
andnp.add_newdoc_ufunc
.(gh-24357)
Alias
np.float_
has been removed. Usenp.float64
instead.Alias
np.complex_
has been removed. Usenp.complex128
instead.Alias
np.longfloat
has been removed. Usenp.longdouble
instead.Alias
np.singlecomplex
has been removed. Usenp.complex64
instead.
Alias
np.cfloat
has been removed. Usenp.complex128
instead.Alias
np.longcomplex
has been removed. Usenp.clongdouble
instead.
Alias
np.clongfloat
has been removed. Usenp.clongdouble
instead.
Alias
np.string_
has been removed. Usenp.bytes_
instead.Alias
np.unicode_
has been removed. Usenp.str_
instead.Alias
np.Inf
has been removed. Usenp.inf
instead.Alias
np.Infinity
has been removed. Usenp.inf
instead.Alias
np.NaN
has been removed. Usenp.nan
instead.Alias
np.infty
has been removed. Usenp.inf
instead.Alias
np.mat
has been removed. Usenp.asmatrix
instead.np.issubclass_
has been removed. Use theissubclass
builtininstead.
np.asfarray
has been removed. Usenp.asarray
with a proper dtypeinstead.
np.set_string_function
has been removed. Usenp.set_printoptions
instead with a formatter for custom printing of NumPy objects.
np.tracemalloc_domain
is now only available fromnp.lib
.np.recfromcsv
andrecfromtxt
are now only available fromnp.lib.npyio
.np.issctype
,np.maximum_sctype
,np.obj2sctype
,np.sctype2char
,np.sctypes
,np.issubsctype
were all removedfrom the main namespace without replacement, as they where niche
members.
Deprecated
np.deprecate
andnp.deprecate_with_doc
has beenremoved from the main namespace. Use
DeprecationWarning
instead.Deprecated
np.safe_eval
has been removed from the main namespace.Use
ast.literal_eval
instead.(gh-24376)
np.find_common_type
has been removed. Usenumpy.promote_types
ornumpy.result_type
instead. To achieve semantics for thescalar_types
argument, usenumpy.result_type
and pass0
,0.0
, or0j
as a Python scalar instead.np.round_
has been removed. Usenp.round
instead.np.nbytes
has been removed. Usenp.dtype(<dtype>).itemsize
instead.
(gh-24477)
np.compare_chararrays
has been removed from the main namespace.Use
np.char.compare_chararrays
instead.The
charrarray
in the main namespace has been deprecated. It canbe imported without a deprecation warning from
np.char.chararray
for now, but we are planning to fully deprecate and remove
chararray
in the future.np.format_parser
has been removed from the main namespace. Usenp.rec.format_parser
instead.(gh-24587)
Support for seven data type string aliases has been removed from
np.dtype
:int0
,uint0
,void0
,object0
,str0
,bytes0
and
bool8
.(gh-24807)
The experimental
numpy.array_api
submodule has been removed. Usethe main
numpy
namespace for regular usage instead, or theseparate
array-api-strict
package for the compliance testing usecase for which
numpy.array_api
was mostly used.(gh-25911)
__array_prepare__
is removedUFuncs called
__array_prepare__
before running computations for normalufunc calls (not generalized ufuncs, reductions, etc.). The function was
also called instead of
__array_wrap__
on the results of some linearalgebra functions.
It is now removed. If you use it, migrate to
__array_ufunc__
or relyon
__array_wrap__
which is called with a context in all cases,although only after the result array is filled. In those code paths,
__array_wrap__
will now be passed a base class, rather than a subclassarray.
(gh-25105)
Deprecations
np.compat
has been deprecated, as Python 2 is no longer supported.numpy.int8
and similar classes will no longer support conversionof out of bounds python integers to integer arrays. For example,
conversion of 255 to int8 will not return -1.
numpy.iinfo(dtype)
can be used to check the machine limits for data types. For example,
np.iinfo(np.uint16)
returns min = 0 and max = 65535.np.array(value).astype(dtype)
will give the desired result.np.safe_eval
has been deprecated.ast.literal_eval
should beused instead.
(gh-23830)
np.recfromcsv
,np.recfromtxt
,np.disp
,np.get_array_wrap
,np.maximum_sctype
,np.deprecate
andnp.deprecate_with_doc
havebeen deprecated.
(gh-24154)
np.trapz
has been deprecated. Usenp.trapezoid
or ascipy.integrate
function instead.np.in1d
has been deprecated. Usenp.isin
instead.Alias
np.row_stack
has been deprecated. Usenp.vstack
directly.(gh-24445)
__array_wrap__
is now passedarr, context, return_scalar
andsupport for implementations not accepting all three are deprecated.
Its signature should be
__array_wrap__(self, arr, context=None, return_scalar=False)
(gh-25409)
Arrays of 2-dimensional vectors for
np.cross
have been deprecated.Use arrays of 3-dimensional vectors instead.
(gh-24818)
np.dtype("a")
alias fornp.dtype(np.bytes_)
was deprecated. Usenp.dtype("S")
alias instead.(gh-24854)
Use of keyword arguments
x
andy
with functionsassert_array_equal
andassert_array_almost_equal
has beendeprecated. Pass the first two arguments as positional arguments
instead.
(gh-24978)
numpy.fft
deprecations for n-D transforms with None values in argumentsUsing
fftn
,ifftn
,rfftn
,irfftn
,fft2
,ifft2
,rfft2
orirfft2
with thes
parameter set to a value that is notNone
andthe
axes
parameter set toNone
has been deprecated, in line with thearray API standard. To retain current behaviour, pass a sequence [0,
..., k-1] to
axes
for an array of dimension k.Furthermore, passing an array to
s
which containsNone
values isdeprecated as the parameter is documented to accept a sequence of
integers in both the NumPy docs and the array API specification. To use
the default behaviour of the corresponding 1-D transform, pass the value
matching the default for its
n
parameter. To use the default behaviourfor every axis, the
s
argument can be omitted.(gh-25495)
np.linalg.lstsq
now defaults to a newrcond
valuenumpy.linalg.lstsq
now uses the new rcond value of themachine precision times
max(M, N)
. Previously, the machine precisionwas used but a FutureWarning was given to notify that this change will
happen eventually. That old behavior can still be achieved by passing
rcond=-1
.(gh-25721)
Expired deprecations
The
np.core.umath_tests
submodule has been removed from the publicAPI. (Deprecated in NumPy 1.15)
(gh-23809)
The
PyDataMem_SetEventHook
deprecation has expired and it isremoved. Use
tracemalloc
and thenp.lib.tracemalloc_domain
domain. (Deprecated in NumPy 1.23)
(gh-23921)
The deprecation of
set_numeric_ops
and the C functionsPyArray_SetNumericOps
andPyArray_GetNumericOps
has been expiredand the functions removed. (Deprecated in NumPy 1.16)
(gh-23998)
The
fasttake
,fastclip
, andfastputmask
ArrFuncs
deprecationis now finalized.
The deprecated function
fastCopyAndTranspose
and its C counterpartare now removed.
The deprecation of
PyArray_ScalarFromObject
is now finalized.(gh-24312)
np.msort
has been removed. For a replacement,np.sort(a, axis=0)
should be used instead.
(gh-24494)
np.dtype(("f8", 1)
will now return a shape 1 subarray dtype ratherthan a non-subarray one.
(gh-25761)
Assigning to the
.data
attribute of an ndarray is disallowed andwill raise.
np.binary_repr(a, width)
will raise if width is too small.Using
NPY_CHAR
inPyArray_DescrFromType()
will raise, useNPY_STRING
NPY_UNICODE
, orNPY_VSTRING
instead.(gh-25794)
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about these updates again.
This PR was generated by Mend Renovate. View the repository job log.