You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In NumType, all scalar types have their are annotated as concrete subclasses. Most function will no longer accepts floating[_32Bit], and require float32 instead. This is because floating[_32Bit] is no longer assignable to float32.
The purpose of numpy.typing.NBitBase was as upper bound to a type parameter, for use in generic abstract scalar types like floating[T]. But the now concrete scalar types will no longer accept anyfloating[T].
NBitBase should therefore not be used anymore.
Type parameters can instead use an abstract scalar type as an upper bound. So instead of
This is a breaking change in the public NumPy API. This change will affect many users, and a quick code search for
npt.NBitBase
brings of 239 hits: https://github.com/search?q=npt.NBitBase+language%3APython&type=code&l=PythonBut even so, this has to happen.
In NumType, all scalar types have their are annotated as concrete subclasses. Most function will no longer accepts
floating[_32Bit]
, and requirefloat32
instead. This is becausefloating[_32Bit]
is no longer assignable tofloat32
.The purpose of
numpy.typing.NBitBase
was as upper bound to a type parameter, for use in generic abstract scalar types likefloating[T]
. But the now concrete scalar types will no longer accept anyfloating[T]
.NBitBase
should therefore not be used anymore.Type parameters can instead use an abstract scalar type as an upper bound. So instead of
you can write
If that isn't possible, for example with
then
typing.overload
can be used instead:See also https://numpy.org/doc/stable/reference/typing.html#numpy.typing.NBitBase
The text was updated successfully, but these errors were encountered: