fix(deps): update dependency numpy to <=2.5.0#287
Open
dreadnode-renovate-bot[bot] wants to merge 1 commit into
Open
fix(deps): update dependency numpy to <=2.5.0#287dreadnode-renovate-bot[bot] wants to merge 1 commit into
dreadnode-renovate-bot[bot] wants to merge 1 commit into
Conversation
ecba02d to
bdc82ef
Compare
bdc82ef to
addf371
Compare
addf371 to
5143549
Compare
5143549 to
035fc3d
Compare
035fc3d to
10c2400
Compare
10c2400 to
392efe1
Compare
392efe1 to
e157786
Compare
| datasource | package | from | to | | ---------- | ------- | ----- | ----- | | pypi | numpy | 2.3.5 | 2.5.0 |
e157786 to
24ba710
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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:
<=2.3.5→<=2.5.0Release Notes
numpy/numpy (numpy)
v2.5.0: (June 21, 2026)Compare Source
NumPy 2.5.0 Release Notes
Numpy 2.5.0 is a transitional release. It drops support for Python 3.11,
marking the end of distutils, and expires a large number of deprecations made
in the 2.0.x release. It also improves free threading and brings sorting into
compliance with the array-api standard with the addition of descending sorts.
There is also a fair amount of preparation for Python 3.15, which will be
supported starting with the first rc.
This release supports Python versions 3.12-3.14.
Highlights
See New Features below for other additions.
Deprecations
numpy.char.chararrayis deprecated. Use anndarraywith a string or bytes dtype instead.(gh-30605)
numpy.takenow correctly checks if the result can be cast to the providedout=outunder the same-kind rule. ADeprecationWarningis given nowwhen this check fails. Previously,
takeincorrectly checked ifoutcould be cast to the result (the wrong direction). This deprecation also
affects
compressand possibly other functions. (Future versions of NumPymay tighten the casting check further.)
(gh-30615)
The
numpy.char.[as]arrayfunctions are deprecated. Use annumpy.[as]arraywith a string or bytes dtype instead.(gh-30802)
Setting the dtype attribute is deprecated because mutating an array is unsafe
if an array is shared, especially by multiple threads. As an alternative,
you can create a view with a new dtype via
array.view(dtype=new_dtype).(gh-29244)
Setting the
shapeattribute is deprecated because mutating an array isunsafe if an array is shared, especially by multiple threads. As an
alternative, you can create a new view via
np.reshapeornp.ndarray.reshape. For example:x = np.arange(15); x = np.reshape(x, (3, 5)).To ensure no copy is made from the data, one can use
np.reshape(..., copy=False).While setting the shape on an array is discouraged, for cases where it is
difficult to work around, e.g., in
__array_finalize__, it is possiblewith the private method
np.ndarray._set_shape.(gh-29536)
Using the
genericunit innumpy.timedelta64is deprecated since thiscan lead to unexpected behavior such as non-transitive comparison, see
gh-28287 for details. As
an alternative, specify an explicit unit such as
's'(seconds) or'D'(days) when constructing
numpy.timedelta64. Due to this change, operationsthat implicitly rely on the
genericunit are also deprecated. Forexample:
1is implicitly converted to generic timedelta64(gh-29619)
Resizing a Numpy array in place is deprecated since mutating an array is
unsafe if an array is shared, especially by multiple threads. As an
alternative, you can create a resized array via
np.resize.(gh-30181)
numpy.fixis deprecated, usenumpy.truncinstead. It is faster andfollows the Array API standard. Both functions provide identical
functionality: rounding array elements towards zero.
(gh-30644)
numpy.ma.round_is deprecated.numpy.ma.roundcan be used as areplacement.
(gh-30738)
numpy.typenameis deprecated because the names returned by it wereoutdated and inconsistent.
numpy.dtype.namecan be used as areplacement.
(gh-30774)
Inputs other than integers are deprecated for
numpy.triu_indicesandnumpy.tril_indices. Non-integer values for theM,kandNparameters of
numpy.triare deprecated. Non-integer values for thekparameter of both
numpy.tril_indices_fromandnumpy.triu_indices_fromare deprecated.
(gh-30869)
Deprecations in custom
dtypeproperty and__array_finalize__.Previously
arr.view(dtype=new_dtype)calledarr.dtype = new_dtypealso for subclasses, i.e., the attribute setting. That path is now
deprecated and refined, meaning that even subclasses that do not see this
DeprecationWarningmay wish to update their code.A subclass that does any
dtypespecific logic (i.e. verifying the dtypein
__array_finalize__or has adtypeproperty) should now:_set_dtype = Nonein which casearr.view(dtype=new_dtype)will call
__array_finalize__with the new dtype, ensuring thatany validation
__array_finalize__will run is done._set_dtypeas a function (callingndarray._set_dtype()to avoidDeprecationWarnings.(Future versions might migrate towards the
_set_dtype = Nonepath.)Ideally, follow NumPy's deprecation to prevent
dtypemutation by users.The use of
ndarray._set_dtype()may be necessary for some subclassfinalization patterns, but should otherwise be avoided.
(gh-31293)
Expired deprecations
numpy.distutilshas been removed(gh-30340)
Passing
Noneas dtype tonp.finfowill now raise aTypeError(deprecated since 1.25)
(gh-30460)
numpy.crossno longer supports 2-dimensional vectors.(Deprecated since 2.0)
(gh-30461)
numpy._core.numerictypes.maximum_sctypehas been removed.(deprecated since 2.0)
(gh-30462)
numpy.row_stackhas been removed in favor ofnumpy.vstack.(deprecated since 2.0)
(gh-30463)
get_array_wraphas been removed.(deprecated since 2.0)
(gh-30463)
recfromtxtandrecfromcsvhave been removed fromnumpy.lib._npyioin favor of
numpy.genfromtxt.(deprecated since 2.0)
(gh-30467)
The
numpy.chararrayre-export ofnumpy.char.chararrayhas been removed.(deprecated since 2.0)
(gh-30604)
bincountnow raises aTypeErrorfor non-integer inputs.(deprecated since 2.1)
(gh-30610)
The
numpy.lib.mathalias for the standard librarymathmodule hasbeen removed.
(deprecated since 1.25)
(gh-30612)
Data type alias
'a'was removed in favor of'S'.(deprecated since 2.0)
(gh-30613)
_add_newdoc_ufunc(ufunc, newdoc)has been removed in favor ofufunc.__doc__ = newdoc.(deprecated since 2.2)
(gh-30614)
Compatibility notes
linalg.eigandlinalg.eigvalsnow always return complex arraysPreviously, the return values depended on whether the eigenvalues happen to lie
on the real line (which, for a general, non-symmetric matrix, is not
guaranteed).
This change makes consistent what was a value-dependent result. To retain the
previous behavior, do:
If your matrix is symmetrix/hermitian, use
eighandeigvalshinstead ofeigandeigvals. These are guaranteed to return real values. A commoncase is covariance matrices, which are symmetric and positive definite by
construction.
(gh-30411)
MSVC support
NumPy now requires minimum MSVC 19.35 toolchain version on Windows platforms.
This corresponds to Visual Studio 2022 version 17.5 Preview 2 or newer.
(gh-30489)
Cython support
NumPy's Cython headers (accessed via
cimport numpy) now require Cython 3.0or newer to build. If you try to compile a project that depends on NumPy's
Cython headers using Cython 0.29 or older, you will see a message like this:
versions.
See init.cython-30.pxd for the real Cython header
Note that the invalid integer is not a bug in NumPy - we are intentionally
generating this error to avoid triggering a more obscure error later in the
build when an older Cython version tries to use a Cython feature that was not
available in the old Cython version.
(gh-30770)
numpy.whereno longer truncates Python integersPreviously, if the
xoryargument ofnumpy.wherewas a Pythoninteger that was out of range of the output type, it would be silently
truncated. Now, an
OverflowErrorwill be raised instead.This change also applies to the underlying C API function
PyArray_Where.(gh-30803)
Default memory allocator change
NumPy now uses
PyMem_RawMallocandPyMem_RawFreeas the default memoryallocator, instead of system's
mallocandfreedirectly.(gh-30846)
from_dlpackraisesBufferErrorinstead ofRuntimeErrornp.from_dlpacknow raisesBufferErrorinstead ofRuntimeErrorwhenthe incoming DLPack tensor has an unsupported device, dtype, or exceeds the
maximum number of dimensions. This aligns with the DLPack and Array API
specifications, which recommend
BufferErrorfor data that cannot beimported.
(gh-30937)
Corrections to the BTPE binomial sampler
Two independent errors in the Stirling series of the acceptance/rejection step
of the BTPE algorithm used by
numpy.random.Generator.binomialhave beencorrected:
error was inherited from section 5.3 of the original 1988 paper by
Kachitvichyanukul & Schmeiser, which incorrectly adds all four terms.
13680instead of13860) that was introduced in the initial implementation.As a result,
Generator.binomialandGenerator.multinomial, which usesbinomial internally, may now return different samples for the same seed.
The legacy
numpy.random.RandomState.binomialandnumpy.random.RandomState.multinomialare not affected: they preserve theoriginal (incorrect) behavior, so existing streams remain reproducible.
(gh-31238)
datetime64/timedelta64arithmetic raises on overflowAddition, subtraction, and integer multiplication of
datetime64andtimedelta64values now raiseOverflowErrorwhen the result wouldoverflow
int64or land on theNaTsentinel value. Previously theseoperations silently wrapped, often producing a value that was indistinguishable
from
NaT. This matches the overflow checking already performed byunit-conversion casts.
(gh-31378)
C API changes
It is now possible to register
"real"and"imag"ArrayMethods viaPyUFunc_AddLoopsFromSpecs. These will be used forimagandrealand should normally set
*view_offsetin theirresolve_descriptorsfunction to allow the array attributes to return views.
(gh-30984)
New
PyDataType_TYPE,PyDataType_KIND,PyDataType_BYTEORDERandPyDataType_TYPEOBJaccessor macros to the C API. Together with the otheraccessor macros added for the NumPy 2.0 transition, these allow accessing the
fields of
PyArray_Descrstructs without any direct field accesses.(gh-30994)
NumPy now supports the stable ABI for free-threaded Python as described in
803{.interpreted-text role="pep"}.(gh-31091)
PyArray_DescrFromScalarnow returns the full dtype descriptor for scalarsof user-defined parametric data types, including any dtype parameters.
Parameters were previously silently discarded, which could cause incorrect
results in operations like
astypeon scalar objects. Internally, thefunction now delegates to
discover_descr_from_pyobject, which handlesparametric dtypes correctly.
(gh-31067)
New Features
It is now possible to register user-dtypes for dlpack export and import
via
numpy.dtypes.register_dlpack_dtype. This functionality is meant tobe used with care by user-dtype authors.
(gh-31256)
Pixi package definitions
Pixi package definitions have been added for different kinds
of from-source builds of NumPy. These can be used in
downstream Pixi workspaces via the
pixi-buildfeature.Definitions for both
defaultand AddressSanitizer-instrumented(
asan) builds are available in the source code under thepixi-packages/directory.linux-64andosx-arm64platforms are supported.(gh-30381)
numpy.ndarraynow supports structural pattern matchingnumpy.ndarrayand its subclasses now have thePy_TPFLAGS_SEQUENCEflagset, enabling structural pattern matching (PEP 634) with
match/casestatements. This also enables Cython to optimize integer indexing operations.
See
`arrays.ndarray.pattern-matching{.interpreted-text role="ref"}` for details.(gh-30653)
Added N-D evaluation functions to the polynomial package
New functions
polyvalnd,chebvalnd,legvalnd,hermvalnd,hermevalnd, andlagvalndhave been added to evaluate polynomialsin arbitrary dimensions, analogous to the existing 2D and 3D evaluators.
(gh-30857)
New "descending" keyword argument for
numpy.sortandnumpy.argsortUsers can now pass the
descending=Truekeyword argument tonumpy.sortand
numpy.argsortto sort and argsort arrays in descending order. NaNvalues, if present, are sorted to the end of the array in both ascending and
descending sorts. This feature is available for all built-in dtypes except
void,object, andgeneric. Note that SIMD optimizations for sortingare currently not available for descending sorts, so performance may be slower.
(gh-31345)
Improvements
For
f2py, the behaviour ofintent(inplace)has improved. Previously,if an input array did not have the right dtype or order, the input array was
modified in-place, changing its dtype and replacing its data by a corrected
copy. Now, instead, the corrected copy is kept a separate array, which, after
being passed and presumably modified by the fortran routine, is copied back to
the input routine. The above means one no longer has the risk that
pre-existing views or slices of the input array start pointing to unallocated
memory (at the price of increased overhead for the write-back copy at the end
of the call).
A potential problem would be that one might get very different results if one,
e.g., previously passed in an integer array where a double array was expected:
the writeback to integer would likely give wrong results. To avoid such
situations,
intent(inplace)will now only allow arrays that have equivalenttype to that used in the fortran routine, i.e.,
dtype.kindis the same. Forinstance, a routine expecting double would be able to receive float, but would
raise on integer input.
(gh-29929)
f2pymodules now show allocatable arrays indir()Allocatable module variables wrapped by
f2pynow appear indir()output, matching their accessibility by name.
(gh-30965)
StringDTypecomparisons now correctly handle embedded NULL bytes.(gh-31662)
Performance improvements and changes
Improved performance of
numpy.searchsortedThe C++ binary search implementation used by
numpy.searchsortednow has amuch better performance when searching for multiple keys. The new
implementation batches binary search steps across all keys to leverage cache
locality and out-of-order execution. Benchmarks show the new implementation can
be up to 20 times faster for hundreds of thousands keys while single-key
performance remains comparable to previous versions.
(gh-30517)
Improved scaling of ufuncs on free-threading
NumPy's ufuncs now scale significantly better on free-threading builds
of CPython due to the following optimizations:
a lock-free concurrent hash map, allowing multiple threads to call ufuncs
without contention.
handlers, have been made immortal. This effectively reduces reference
counting contention across threads.
PyMem_RawMallocandPyMem_RawFreefor memory allocation. On Python 3.15 and newer, thisleverages
mimallocand significantly reduces memory allocation overheadin multi-threaded workloads.
(gh-30846)
Faster reductions on small/medium contiguous arrays
numpy.sum,numpy.prod,numpy.any,numpy.all, and otherreductions with an identity value now use a fast path when the input is a
contiguous, aligned, non-object array and the reduction covers all axes
(
axis=None) with no special arguments. Typical speedup is ~1.3x on smallarrays;
numpy.any/numpy.allon contiguous boolean arrays can seespeedup up to 1.9x.
(gh-31274)
Typing improvements and changes
numpy.linalgtyping improvements and preliminary shape-typing supportInput and output dtypes for
numpy.linalgfunctions are now more precise.Several of these functions also gain preliminary shape-typing support while
remaining backward compatible. For example, the return type of
numpy.linalg.matmulnow depends on the shape-type of its inputs, or fallback to the backward-compatible return type if the shape-types are unknown at
type-checking time. Because of limitations in Python's type system and current
type-checkers, shape-typing cannot cover every situation and is often only
implemented for the most common lower-rank cases.
(gh-30480)
numpy.matyping annotationsThe
numpy.mamodule is now fully covered by typing annotations. Thisincludes annotations for masked arrays, masks, and various functions and
methods. With this, NumPy has achieved 100% typing coverage across all its
submodules.
(gh-30566)
Shape-typing support for many functions and methods
Many functions and methods now have shape-aware return type annotations.
Type-checkers can now infer the number of dimensions of the returned array
through common operations. For example,
np.linspace(0, 1)is now typed as a1-d
float64array, andnp.sum(x, keepdims=True)has the same number ofdimensions as
x.This covers
numpy.linalgfunctions, array creation functions (likeasarray,from{buffer,string,file,iter,regex}), range functions(
linspace,logspace,geomspace), aggregation functions and methods(
sum,mean,std,var,min,max,all,any,etc.), sorting (
sort,argsort,argpartition), cumulative operations(
cumsum,cumprod, etc.), set operations (unique_values,intersect1d,union1d, etc.), and various other functions includingnonzero,transpose,diagonal,atleast_{1,2,3}d,clip,round,inner,bincount, andfft.fftfreq. Several of these alsogained more precise return dtype annotations as part of this work.
Shape-typing is still a work-in-progress, so coverage is not yet complete.
Because of limitations in Python's type system and current type-checkers,
shape-typing is often only implemented for the most common lower-rank cases.
(gh-31172)
numpy.ffttyping improvements and preliminary shape-typing supportThe
numpy.fftfunctions now support non-float64/complex128dtypesand gain preliminary shape-typing support. For example, the return type of
numpy.fft.fftnow depends on the shape-type of its inputs, falling back tothe backward-compatible return type when the shape-types are unknown at
type-checking time.
(gh-31226)
Changes
Structured array copies now use
memcpyfor contiguous dtypesCopying structured arrays with identical dtypes now uses
memcpyinstead offield-by-field transfer when the dtype has a contiguous layout (no gaps between
fields). A new
NPY_NOT_TRIVIALLY_COPYABLEdtype flag is set on structureddtypes that have gaps in their memory layout, such as those created with
explicit
offsetsor via multi-field indexing. Only these dtypes continue touse the slower field-by-field copy.
This means that padding bytes in contiguous structured dtypes (e.g. those
created without explicit
offsets) may now be copied as part of thememcpy, whereas previously they were left untouched. Code that relies onpadding bytes being preserved during structured array copies may be affected.
(gh-29270)
numpy.ctypeslib.as_ctypesnow does not support scalar typesThe function
numpy.ctypeslib.as_ctypeshas been updated to only acceptnumpy.ndarray. Passing a scalar type (e.g.,numpy.int32(5)) will nowraise a
TypeError. This change was made to avoid the issuegh-30354 and to enforce the
readonly nature of scalar types in NumPy. The previous behavior relied on
undocumented implicit temporary arrays and was not well-defined. Users who
need to convert scalar types to ctypes should first convert them to an array
(e.g.,
numpy.asarray) before passing them tonumpy.ctypeslib.as_ctypes.(gh-30538)
__array_interface__changes on scalarsScalars now export the
__array_interface__directly rather than includingan array copy as a
__refentry. This means that scalars are now exported asread-only while they previously exported as writeable. The path via
__refwas undocumented and not consistently used even within NumPy itself.
(gh-30538)
meshgridnow always returns a tuplenp.meshgridpreviously used to return a list whensparsewas true andcopywas false. Now, it always returns a tuple regardless of thearguments.
(gh-30707)
numpy.triu_indicesnow acceptsunsigned integersnumpy.triu_indicespreviously used to error in some cases whenunsigned integerswere given as arguments. Now, it accepts them in all cases.
(gh-30869)
objectdtype in.realand.imagand related functionsThe array attributes
.realand.imagnow behave differently for objectarrays and return
getattr(element, "real", element)orgetattr(element, "imag", 0)elementwise. Additionally, the return for both is now read-only to avoid possible
in-place changes having no effect.
This change also affects
np.isreal()which usesarr.imag.Previously,
.imagalways returned0while.realreturned theoriginal array unmodified. The new behavior now returnes the correct values
for complex Python objects but may also lead to surprises for example if
element.real()is a method and not a property.(gh-30984)
NumPy's internal memory allocations now use
PyMem_RawMallocNumPy's internal memory allocations now use
PyMem_RawMallocinstead ofmallocand can be tracked bytracemalloc.(gh-31503)
v2.4.6: (May 18, 2026)Compare Source
NumPy 2.4.6 Release Notes
NumPy 2.4.6 is a quick release that fixes a regression discovered in the 2.4.5
release.
This release supports Python versions 3.11-3.14
Contributors
A total of 4 people contributed to this release. People with a "+" by their
names contributed a patch for the first time.
Pull requests merged
A total of 4 pull requests were merged for this release.
arr.conj()np.linalg.svd(..., hermitian=True)returns non-unitary...v2.4.5: (May 15, 2026)Compare Source
NumPy 2.4.5 Release Notes
NumPy 2.4.5 is a patch release that fixes bugs discovered after the 2.4.4
release, has some typing improvements, and maintains infrastructure.
This release supports Python versions 3.11-3.14
Contributors
A total of 17 people contributed to this release. People with a "+" by their
names contributed a patch for the first time.
Pull requests merged
A total of 28 pull requests were merged for this release.
np.shapeassignability issue for python lists (#31171)pack_inner...tile: accept numpy scalars and arrays as second argument...ix_fix for boolean and non-1d input (#31218)_NestedSequencetype parameter default to work around...DTypeLikeruntime type-checker support (#31425)v2.4.4: 2.4.4 (Mar 29, 2026)Compare Source
NumPy 2.4.4 Release Notes
The NumPy 2.4.4 is a patch release that fixes bugs discovered after the 2.4.3
release. It should finally close issue #30816, the OpenBLAS threading problem
on ARM.
This release supports Python versions 3.11-3.14
Contributors
A total of 8 people contributed to this release. People with a "+" by their
names contributed a patch for the first time.
Pull requests merged
A total of 7 pull requests were merged for this release.
sprintfwithsnprintf...v2.4.3: 2.4.3 (Mar 9, 2026)Compare Source
NumPy 2.4.3 Release Notes
The NumPy 2.4.3 is a patch release that fixes bugs discovered after the
2.4.2 release. The most user visible fix may be a threading fix for
OpenBLAS on ARM, closing issue #30816.
This release supports Python versions 3.11-3.14
Contributors
A total of 11 people contributed to this release. People with a "+" by their
names contributed a patch for the first time.
Pull requests merged
A total of 14 pull requests were merged for this release.
matlib: missing extended precision importsv2.4.2: 2.4.2 (Feb 1, 2026)Compare Source
NumPy 2.4.2 Release Notes
The NumPy 2.4.2 is a patch release that fixes bugs discovered after the
2.4.1 release. Highlights are:
This release supports Python versions 3.11-3.14
Contributors
A total of 9 people contributed to this release. People with a "+" by their
names contributed a patch for the first time.
Pull requests merged
A total of 12 pull requests were merged for this release.
arange: accept datetime stringsos.environ...array_getbuffer(#30667)v2.4.1: 2.4.1 (Jan 10, 2026)Compare Source
NumPy 2.4.1 Release Notes
The NumPy 2.4.1 is a patch release that fixes bugs discoved after the
2.4.0 release. In particular, the typo
SeedlessSequenceis preserved toenable wheels using the random Cython API and built against NumPy < 2.4.0
to run without errors.
This release supports Python versions 3.11-3.14
Contributors
A total of 9 people contributed to this release. People with a "+" by their
names contributed a patch for the first time.
Pull requests merged
A total of 15 pull requests were merged for this release.
numpy.select: fixdefaultparameter docstring...numpy.select: allow passing array-likedefault...v2.4.0: 2.4.0 (Dec 20, 2025)Compare Source
NumPy 2.4.0 Release Notes
The NumPy 2.4.0 release continues the work to improve free threaded Python
support, user dtypes implementation, and annotations. There are many expired
deprecations and bug fixes as well.
This release supports Python versions 3.11-3.14
Highlights
Apart from annotations and
same_valuekwarg, the 2.4 highlights are mostlyof interest to downstream developers. They should help in implementing new user
dtypes.
castingkwarg'same_value'for casting by value.PyUFunc_AddLoopsFromSpecfunction that can be used to add user sortloops using the
ArrayMethodAPI.__numpy_dtype__protocol.Deprecations
Setting the
stridesattribute is deprecatedSetting the strides attribute is now deprecated since mutating
an array is unsafe if an array is shared, especially by multiple
threads. As an alternative, you can create a new view (no copy) via:
np.lib.stride_tricks.strided_window_viewif applicable,np.lib.stride_tricks.as_stridedfor the general case,np.ndarrayconstructor (bufferis the original array) for alight-weight version.
(gh-28925)
Positional
outargument tonp.maximum,np.minimumis deprecatedPassing the output array
outpositionally tonumpy.maximumandnumpy.minimumis deprecated. For example,np.maximum(a, b, c)will emita deprecation warning, since
cis treated as the output buffer rather thana third input.
Always pass the output with the keyword form, e.g.
np.maximum(a, b, out=c).This makes intent clear and simplifies type annotations.
(gh-29052)
align=must be passed as boolean tonp.dtype()When creating a new
dtypeaVisibleDeprecationWarningwill be given ifalign=is not a boolean. This is mainly to prevent accidentally passing asubarray align flag where it has no effect, such as
np.dtype("f8", 3)instead of
np.dtype(("f8", 3)). We strongly suggest to always passalign=as a keyword argument.(gh-29301)
Assertion and warning control utilities are deprecated
np.testing.assert_warnsandnp.testing.suppress_warningsaredeprecated. Use
warnings.catch_warnings,warnings.filterwarnings,pytest.warns, orpytest.filterwarningsinstead.(gh-29550)
np.fixis pending deprecationThe
numpy.fixfunction will be deprecated in a future release. It isrecommended to use
numpy.truncinstead, as it provides the samefunctionality of truncating decimal values to their integer parts. Static type
checkers might already report a warning for the use of
numpy.fix.(gh-30168)
in-place modification of
ndarray.shapeis pending deprecationSetting the
ndarray.shapeattribute directly will be deprecated in a futurerelease. Instead of modifying the shape in place, it is recommended to use the
numpy.reshapefunction. Static type checkers might already report awarning for assignments to
ndarray.shape.(gh-30282)
Deprecation of
numpy.lib.user_array.containerThe
numpy.lib.user_array.containerclass is deprecated and will be removedin a future version.
(gh-30284)
Expired deprecations
Removed deprecated
MachArruntime discovery mechanism.(gh-29836)
Raise
TypeErroron attempt to convert array withndim > 0to scalarConversion of an array with
ndim > 0to a scalar was deprecated in NumPy1.25. Now, attempting to do so raises
TypeError. Ensure you extract asingle element from your array before performing this operation.
(gh-29841)
Removed numpy.linalg.linalg and numpy.fft.helper
The following were deprecated in NumPy 2.0 and have been moved to private
modules:
numpy.linalg.linalgUse
numpy.linalginstead.numpy.fft.helperUse
numpy.fftinstead.(gh-29909)
Removed
interpolationparameter from quantile and percentile functionsThe
interpolationparameter was deprecated in NumPy 1.22.0 and has beenremoved from the following functions:
numpy.percentilenumpy.nanpercentilenumpy.quantilenumpy.nanquantileUse the
methodparameter instead.(gh-29973)
Removed
numpy.in1dnumpy.in1dhas been deprecated since NumPy 2.0 and is now removed in favor ofnumpy.isin.(gh-29978)
Removed
numpy.ndindex.ndincr()The
ndindex.ndincr()method has been deprecated since NumPy 1.20 and is nowremoved; use
next(ndindex)instead.(gh-29980)
Removed
fix_importsparameter fromnumpy.saveThe
fix_importsparameter was deprecated in NumPy 2.1.0 and is now removed.This flag has been ignored since NumPy 1.17 and was only needed to support
loading files in Python 2 that were written in Python 3.
(gh-29984)
Removal of four undocumented
ndarray.ctypesmethodsFour undocumented methods of the
ndarray.ctypesobject have been removed:_ctypes.get_data()(use_ctypes.datainstead)_ctypes.get_shape()(use_ctypes.shapeinstead)_ctypes.get_strides()(use_ctypes.stridesinstead)_ctypes.get_as_parameter()(use_ctypes._as_parameter_instead)These methods have been deprecated since NumPy 1.21.
(gh-29986)
Removed
newshapeparameter fromnumpy.reshapeThe
newshapeparameter was deprecated in NumPy 2.1.0 and has beenremoved from
numpy.reshape. Pass it positionally or useshape=on newer NumPy versions.
(gh-29994)
Removal of deprecated functions and arguments
The following long-deprecated APIs have been removed:
numpy.trapz--- deprecated since NumPy 2.0 (2023-08-18). Usenumpy.trapezoidorscipy.integratefunctions instead.dispfunction --- deprecated from 2.0 release and no longer functional. Useyour own printing function instead.
biasandddofarguments innumpy.corrcoef--- these had no effectsince NumPy 1.10.
(gh-29997)
Removed
delimitorparameter fromnumpy.ma.mrecords.fromtextfile()The
delimitorparameter was deprecated in NumPy 1.22.0 and has beenremoved from
numpy.ma.mrecords.fromtextfile(). Usedelimiterinstead.(gh-30021)
numpy.array2stringandnumpy.sumdeprecations finalizedThe following long-deprecated APIs have been removed or converted to errors:
styleparameter has been removed fromnumpy.array2string.This argument had no effect since Numpy 1.14.0. Any arguments following
it, such as
formatterhave now been made keyword-only.np.sum(generator)directly on a generator object now raises aTypeError. This behavior was deprecated in NumPy 1.15.0. Usenp.sum(np.fromiter(generator))or the pythonsumbuiltin instead.(gh-30068)
Compatibility notes
NumPy's C extension modules have begun to use multi-phase initialisation, as
defined by PEP 489. As part of this, a new explicit check has been added that
each such module is only imported once per Python process. This comes with
the side-effect that deleting
numpyfromsys.modulesand re-importingit will now fail with an
ImportError. This has always been unsafe, withunexpected side-effects, though did not previously raise an error.
(gh-29030)
numpy.roundnow always returns a copy. Previously, it returned a viewfor integer inputs for
decimals >= 0and a copy in all other cases.This change brings
roundin line withceil,floorandtrunc.(gh-29137)
Type-checkers will no longer accept calls to
numpy.arangewithstartas a keyword argument. This was done for compatibility withthe Array API standard. At runtime it is still possible to use
numpy.arangewithstartas a keyword argument.(gh-30147)
The Macro NPY_ALIGNMENT_REQUIRED has been removed The macro was defined in
the
npy_cpu.hfile, so might be regarded as semi public. As it turns out,with modern compilers and hardware it is almost always the case that
alignment is required, so numpy no longer uses the macro. It is unlikely
anyone uses it, but you might want to compile with the
-Wundefflag orequivalent to be sure.
(gh-29094)
C API changes
The NPY_SORTKIND enum has been enhanced with new variables
This is of interest if you are using
PyArray_SortorPyArray_ArgSort.We have changed the semantics of the old names in the
NPY_SORTKINDenum andadded new ones. The changes are backward compatible, and no recompilation is
needed. The new names of interest are:
NPY_SORT_DEFAULT-- default sort (same value asNPY_QUICKSORT)NPY_SORT_STABLE-- the sort must be stable (same value asNPY_MERGESORT)NPY_SORT_DESCENDING-- the sort must be descendingThe semantic change is that
NPY_HEAPSORTis mapped toNPY_QUICKSORTwhen used.Note that
NPY_SORT_DESCENDINGis not yet implemented.(gh-29642)
New
NPY_DT_get_constantslot for DType constant retrievalA new slot
NPY_DT_get_constanthas been added to the DType API, allowingdtype implementations to provide constant values such as machine limits and
special values. The slot function has the signature:
It returns 1 on success, 0 if the constant is not available, or -1 on error.
The function is always called with the GIL held and may write to unaligned memory.
Integer constants (marked with the
1 << 16bit) returnnpy_intpvalues,while floating-point constants return values of the dtype's native type.
Implementing this can be used by user DTypes to provide
numpy.finfovalues.(gh-29836)
A new
PyUFunc_AddLoopsFromSpecsconvenience function has been added to the C API.This function allows adding multiple ufunc loops from their specs in one call
using a NULL-terminated array of
PyUFunc_LoopSlotstructs. It allowsregistering sorting and argsorting loops using the new ArrayMethod API.
(gh-29900)
New Features
Let
np.sizeaccept multiple axes.(gh-29240)
Extend
numpy.padto accept a dictionary for thepad_widthargument.(gh-29273)
'same_value'for casting by valueThe
castingkwarg now has a'same_value'option that checks the actualvalues can be round-trip cast without changing value. Currently it is only
implemented in
ndarray.astype. This will raise aValueErrorif any of thevalues in the array would change as a result of the cast, including rounding of
floats or overflowing of ints.
(gh-29129)
StringDTypefill_value support innumpy.ma.MaskedArrayMasked arrays now accept and preserve a Python
stras theirfill_valuewhen using the variable‑width
StringDType(kind'T'), including throughslicing and views. The default is
'N/A'and may be overridden by any validstring. This fixes issue gh‑29421
and was implemented in pull request gh‑29423.
(gh-29423)
ndmaxoption fornumpy.arrayThe
ndmaxoption is now available fornumpy.array.It explicitly limits the maximum number of dimensions created from nested sequences.
This is particularly useful when creating arrays of list-like objects with
dtype=object.By default, NumPy recurses through all nesting levels to create the highest possible
dimensional array, but this behavior may not be desired when the intent is to preserve
nested structures as objects. The
ndmaxparameter provides explicit control overthis recursion depth.
([gh-29569]
Configuration
📅 Schedule: (UTC)
🚦 Automerge: Enabled.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate.