Skip to content

Commit 16fee6b

Browse files
committed
πŸ’₯ remove NBitBase
1 parent d05158d commit 16fee6b

10 files changed

Lines changed: 51 additions & 99 deletions

File tree

β€Žsrc/_numtype/__init__.pyiβ€Ž

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ from ._dtype import (
3737
ToDTypeUInt32 as ToDTypeUInt32,
3838
ToDTypeUInt64 as ToDTypeUInt64,
3939
ToDTypeVoid as ToDTypeVoid,
40+
_ToDType as _ToDType,
4041
)
4142
from ._just import (
4243
Just as Just,
@@ -578,17 +579,17 @@ ToNumber_2nd = TypeAliasType("ToNumber_2nd", _ToArray2_2nd[np.number, _PyNumber]
578579
ToNumber_3nd = TypeAliasType("ToNumber_3nd", _ToArray2_3nd[np.number, _PyNumber])
579580

580581
# integers and real floats
581-
ToReal_nd = TypeAliasType("ToReal_nd", _ToArray2_nd[np.number[Any, float], _PyReal])
582-
ToReal_0d = TypeAliasType("ToReal_0d", _ToArray2_0d[np.number[Any, float], _PyReal])
583-
ToReal_1d = TypeAliasType("ToReal_1d", _ToArray2_1d[np.number[Any, float], _PyReal])
584-
ToReal_2d = TypeAliasType("ToReal_2d", _ToArray2_2d[np.number[Any, float], _PyReal])
585-
ToReal_3d = TypeAliasType("ToReal_3d", _ToArray2_3d[np.number[Any, float], _PyReal])
586-
ToReal_1ds = TypeAliasType("ToReal_1ds", _ToArray2_1ds[np.number[Any, float], _PyReal])
587-
ToReal_2ds = TypeAliasType("ToReal_2ds", _ToArray2_2ds[np.number[Any, float], _PyReal])
588-
ToReal_3ds = TypeAliasType("ToReal_3ds", _ToArray2_3ds[np.number[Any, float], _PyReal])
589-
ToReal_1nd = TypeAliasType("ToReal_1nd", _ToArray2_1nd[np.number[Any, float], _PyReal])
590-
ToReal_2nd = TypeAliasType("ToReal_2nd", _ToArray2_2nd[np.number[Any, float], _PyReal])
591-
ToReal_3nd = TypeAliasType("ToReal_3nd", _ToArray2_3nd[np.number[Any, float], _PyReal])
582+
ToReal_nd = TypeAliasType("ToReal_nd", _ToArray2_nd[np.number[float], _PyReal])
583+
ToReal_0d = TypeAliasType("ToReal_0d", _ToArray2_0d[np.number[float], _PyReal])
584+
ToReal_1d = TypeAliasType("ToReal_1d", _ToArray2_1d[np.number[float], _PyReal])
585+
ToReal_2d = TypeAliasType("ToReal_2d", _ToArray2_2d[np.number[float], _PyReal])
586+
ToReal_3d = TypeAliasType("ToReal_3d", _ToArray2_3d[np.number[float], _PyReal])
587+
ToReal_1ds = TypeAliasType("ToReal_1ds", _ToArray2_1ds[np.number[float], _PyReal])
588+
ToReal_2ds = TypeAliasType("ToReal_2ds", _ToArray2_2ds[np.number[float], _PyReal])
589+
ToReal_3ds = TypeAliasType("ToReal_3ds", _ToArray2_3ds[np.number[float], _PyReal])
590+
ToReal_1nd = TypeAliasType("ToReal_1nd", _ToArray2_1nd[np.number[float], _PyReal])
591+
ToReal_2nd = TypeAliasType("ToReal_2nd", _ToArray2_2nd[np.number[float], _PyReal])
592+
ToReal_3nd = TypeAliasType("ToReal_3nd", _ToArray2_3nd[np.number[float], _PyReal])
592593

593594
# real- and complex floats
594595
ToInexact_nd = TypeAliasType("ToInexact_nd", _ToArray2_nd[np.inexact, _PyInexact])

β€Žsrc/_numtype/_scalar_co.pyiβ€Ž

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, TypeAlias
1+
from typing import TypeAlias
22

33
import numpy as np
44

@@ -41,28 +41,28 @@ co_int8: TypeAlias = np.int8 | np.bool
4141
co_int16: TypeAlias = np.int16 | co_integer8
4242
co_int32: TypeAlias = np.int32 | co_integer16
4343
co_long: TypeAlias = np.long | co_int32
44-
co_int64: TypeAlias = np.signedinteger[Any] | co_integer32
44+
co_int64: TypeAlias = np.signedinteger | co_integer32
4545

4646
co_uint8: TypeAlias = np.uint8 | np.bool
4747
co_uint16: TypeAlias = np.uint16 | co_uint8
4848
co_uint32: TypeAlias = np.uint32 | co_uint16
4949
co_ulong: TypeAlias = np.ulong | co_uint32
50-
co_uint64: TypeAlias = np.unsignedinteger[Any] | np.bool
50+
co_uint64: TypeAlias = np.unsignedinteger | np.bool
5151

5252
co_integer8: TypeAlias = integer8 | np.bool
5353
co_integer16: TypeAlias = integer16 | co_integer8
5454
co_integer32: TypeAlias = integer32 | co_integer16
55-
co_integer64: TypeAlias = np.integer[Any] | np.bool
55+
co_integer64: TypeAlias = np.integer | np.bool
5656
co_integer = co_integer64
5757

5858
co_float16: TypeAlias = np.float16 | co_integer8
5959
co_float32: TypeAlias = np.float32 | np.float16 | co_integer16
6060
co_float64: TypeAlias = np.float64 | np.float32 | np.float16 | co_integer64
61-
co_float: TypeAlias = np.floating[Any] | co_integer
61+
co_float: TypeAlias = np.floating | co_integer
6262

6363
co_complex64: TypeAlias = inexact32 | number16 | integer8
6464
co_complex128: TypeAlias = number64 | number32 | number16 | co_integer
65-
co_complex: TypeAlias = np.number[Any] | np.bool
65+
co_complex: TypeAlias = np.number | np.bool
6666
co_number = co_complex
6767

6868
co_timedelta: TypeAlias = np.timedelta64 | co_integer

β€Žsrc/numpy-stubs/@test/static/accept/ndarray_conversion.pyiβ€Ž

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ i4_2d: np.ndarray[tuple[int, int], np.dtype[np.int32]]
1010
f8_3d: np.ndarray[tuple[int, int, int], np.dtype[np.float64]]
1111
cG_4d: np.ndarray[tuple[int, int, int, int], np.dtype[np.clongdouble]]
1212
i0_nd: npt.NDArray[np.int_]
13-
uncertain_dtype: np.int32 | np.float64 | np.str_
1413

1514
# item
1615
assert_type(i0_nd.item(), int)
@@ -54,11 +53,6 @@ assert_type(i4_2d.astype(np.uint16), np.ndarray[tuple[int, int], np.dtype[np.uin
5453
assert_type(np.astype(i4_2d, np.uint16), np.ndarray[tuple[int, int], np.dtype[np.uint16]])
5554
assert_type(f8_3d.astype(np.int16), np.ndarray[tuple[int, int, int], np.dtype[np.int16]])
5655
assert_type(np.astype(f8_3d, np.int16), np.ndarray[tuple[int, int, int], np.dtype[np.int16]])
57-
assert_type(
58-
i4_2d.astype(uncertain_dtype), # pyright: ignore[reportAssertTypeFailure] # ndarray[(int, int), np.dtype]
59-
np.ndarray[tuple[int, int], np.dtype[np.generic]],
60-
)
61-
assert_type(np.astype(i4_2d, uncertain_dtype), np.ndarray[tuple[int, int], np.dtype])
6256

6357
# byteswap
6458
assert_type(i0_nd.byteswap(), npt.NDArray[np.int_])

β€Žsrc/numpy-stubs/__init__.pyiβ€Ž

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ from ._pytesttester import PytestTester
351351
from ._typing import (
352352
ArrayLike,
353353
DTypeLike,
354-
NBitBase,
355354
NDArray,
356355
_ArrayLikeDT64_co,
357356
_ArrayLikeObject_co,
@@ -363,7 +362,6 @@ from ._typing import (
363362
_ScalarLike_co,
364363
_ShapeLike,
365364
_TD64Like_co,
366-
_nbit_base as _n,
367365
)
368366
from ._typing._char_codes import _LongCodes, _ULongCodes
369367
from .lib import scimath as emath
@@ -661,10 +659,6 @@ _NumericT = TypeVar("_NumericT", bound=number | timedelta64)
661659
_CoNumberT = TypeVar("_CoNumberT", bound=bool_ | number)
662660
_CharT = TypeVar("_CharT", bound=character)
663661

664-
_BitT = TypeVar("_BitT", bound=NBitBase, default=Any) # pyright: ignore[reportDeprecated]
665-
_BitT1 = TypeVar("_BitT1", bound=NBitBase, default=Any) # pyright: ignore[reportDeprecated]
666-
_BitT2 = TypeVar("_BitT2", bound=NBitBase, default=_BitT1) # pyright: ignore[reportDeprecated]
667-
668662
_ItemT_co = TypeVar("_ItemT_co", default=Any, covariant=True)
669663
_BoolItemT_co = TypeVar("_BoolItemT_co", bound=py_bool, default=py_bool, covariant=True)
670664
_NumberItemT = TypeVar("_NumberItemT", bound=complex)
@@ -4380,11 +4374,7 @@ class bool_(generic[_BoolItemT_co], Generic[_BoolItemT_co]):
43804374

43814375
bool = bool_
43824376

4383-
class number(
4384-
_CmpOpMixin[_nt.CoComplex_0d, _nt.CoComplex_1nd],
4385-
generic[_NumberItemT_co],
4386-
Generic[_BitT, _NumberItemT_co],
4387-
):
4377+
class number(_CmpOpMixin[_nt.CoComplex_0d, _nt.CoComplex_1nd], generic[_NumberItemT_co], Generic[_NumberItemT_co]):
43884378
@type_check_only
43894379
def __nep50_builtin__(self, /) -> tuple[int, Self]: ...
43904380
@final
@@ -4411,7 +4401,7 @@ class number(
44114401
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
44124402

44134403
#
4414-
def __abs__(self, /) -> number[_BitT]: ...
4404+
def __abs__(self, /) -> number: ...
44154405
def __neg__(self, /) -> Self: ...
44164406
def __pos__(self, /) -> Self: ...
44174407

@@ -4525,7 +4515,7 @@ class number(
45254515
# increases over time. Assuming that this *always* holds significantly reduces the
45264516
# complexity of the `[u]intp` and `[u]long` type definitions.
45274517

4528-
class integer(_IntegralMixin, _RoundMixin, number[_BitT, int]):
4518+
class integer(_IntegralMixin, _RoundMixin, number[int]):
45294519
@abc.abstractmethod
45304520
@type_check_only
45314521
def __nep50__(
@@ -4670,7 +4660,7 @@ class integer(_IntegralMixin, _RoundMixin, number[_BitT, int]):
46704660
@overload
46714661
def __ror__(self, x: _nt.CastsWithScalar[Self, _IntegralT], /) -> _IntegralT: ...
46724662

4673-
class signedinteger(integer[_BitT]):
4663+
class signedinteger(integer):
46744664
@abc.abstractmethod
46754665
@type_check_only
46764666
@override
@@ -4691,7 +4681,7 @@ class signedinteger(integer[_BitT]):
46914681
@type_check_only
46924682
def __nep50_rule5__(self, other: _JustInteger | _JustUnsignedInteger, /) -> signedinteger | float64: ...
46934683

4694-
class int8(_IntMixin[L[1]], signedinteger[_n._8]):
4684+
class int8(_IntMixin[L[1]], signedinteger):
46954685
@override
46964686
@type_check_only
46974687
def __nep50__(
@@ -4712,7 +4702,7 @@ class int8(_IntMixin[L[1]], signedinteger[_n._8]):
47124702

47134703
byte = int8
47144704

4715-
class int16(_IntMixin[L[2]], signedinteger[_n._16]):
4705+
class int16(_IntMixin[L[2]], signedinteger):
47164706
@override
47174707
@type_check_only
47184708
def __nep50__(
@@ -4733,7 +4723,7 @@ class int16(_IntMixin[L[2]], signedinteger[_n._16]):
47334723

47344724
short = int16
47354725

4736-
class int32(_IntMixin[L[4]], signedinteger[_n._32]):
4726+
class int32(_IntMixin[L[4]], signedinteger):
47374727
@override
47384728
@type_check_only
47394729
def __nep50__(
@@ -4757,7 +4747,7 @@ class int32(_IntMixin[L[4]], signedinteger[_n._32]):
47574747

47584748
intc = int32
47594749

4760-
class int64(_IntMixin[L[8]], signedinteger[_n._64]):
4750+
class int64(_IntMixin[L[8]], signedinteger):
47614751
@override
47624752
@type_check_only
47634753
def __nep50__(
@@ -4795,7 +4785,7 @@ longlong = int64
47954785
intp = int64
47964786
int_ = intp
47974787

4798-
class unsignedinteger(integer[_BitT]):
4788+
class unsignedinteger(integer):
47994789
@abc.abstractmethod
48004790
@type_check_only
48014791
@override
@@ -4808,7 +4798,7 @@ class unsignedinteger(integer[_BitT]):
48084798
@type_check_only
48094799
def __nep50_rule3__(self, other: _JustUnsignedInteger, /) -> unsignedinteger: ...
48104800

4811-
class uint8(_IntMixin[L[1]], unsignedinteger[_n._8]):
4801+
class uint8(_IntMixin[L[1]], unsignedinteger):
48124802
@override
48134803
@type_check_only
48144804
def __nep50__(
@@ -4833,7 +4823,7 @@ class uint8(_IntMixin[L[1]], unsignedinteger[_n._8]):
48334823

48344824
ubyte = uint8
48354825

4836-
class uint16(_IntMixin[L[2]], unsignedinteger[_n._16]):
4826+
class uint16(_IntMixin[L[2]], unsignedinteger):
48374827
@override
48384828
@type_check_only
48394829
def __nep50__(
@@ -4860,7 +4850,7 @@ class uint16(_IntMixin[L[2]], unsignedinteger[_n._16]):
48604850

48614851
ushort = uint16
48624852

4863-
class uint32(_IntMixin[L[4]], unsignedinteger[_n._32]):
4853+
class uint32(_IntMixin[L[4]], unsignedinteger):
48644854
@override
48654855
@type_check_only
48664856
def __nep50__(
@@ -4887,7 +4877,7 @@ class uint32(_IntMixin[L[4]], unsignedinteger[_n._32]):
48874877

48884878
uintc = uint32
48894879

4890-
class uint64(_IntMixin[L[8]], unsignedinteger[_n._64]):
4880+
class uint64(_IntMixin[L[8]], unsignedinteger):
48914881
@override
48924882
@type_check_only
48934883
def __nep50__(
@@ -4923,7 +4913,7 @@ ulonglong = uint64
49234913
uintp = uint64
49244914
uint = uintp
49254915

4926-
class inexact(number[_BitT, _InexactItemT_co], Generic[_BitT, _InexactItemT_co]):
4916+
class inexact(number[_InexactItemT_co], Generic[_InexactItemT_co]):
49274917
@abc.abstractmethod
49284918
@type_check_only
49294919
def __nep50__(self, below: clongdouble, above: _nt.co_integer8, /) -> inexact: ...
@@ -4961,7 +4951,7 @@ class inexact(number[_BitT, _InexactItemT_co], Generic[_BitT, _InexactItemT_co])
49614951
@overload
49624952
def __rtruediv__(self: _nt.CastsWithComplex[_ComplexFloatingT], x: _nt.JustComplex, /) -> _ComplexFloatingT: ... # pyright: ignore[reportIncompatibleMethodOverride]
49634953

4964-
class floating(_RealMixin, _RoundMixin, inexact[_BitT, float]):
4954+
class floating(_RealMixin, _RoundMixin, inexact[float]):
49654955
@abc.abstractmethod
49664956
@override
49674957
@type_check_only
@@ -5009,7 +4999,7 @@ class floating(_RealMixin, _RoundMixin, inexact[_BitT, float]):
50094999
@overload
50105000
def __rdivmod__(self, x: _nt.CastsWithScalar[Self, _FloatingT], /) -> _2Tuple[_FloatingT]: ...
50115001

5012-
class float16(_FloatMixin[L[2]], floating[_n._16]):
5002+
class float16(_FloatMixin[L[2]], floating):
50135003
@override
50145004
@type_check_only
50155005
def __nep50__(self, below: inexact, above: _nt.co_integer8, /) -> float16: ...
@@ -5030,7 +5020,7 @@ class float16(_FloatMixin[L[2]], floating[_n._16]):
50305020

50315021
half = float16
50325022

5033-
class float32(_FloatMixin[L[4]], floating[_n._32]):
5023+
class float32(_FloatMixin[L[4]], floating):
50345024
@override
50355025
@type_check_only
50365026
def __nep50__(self, below: _float32_min | complexfloating, above: float16 | _nt.co_integer16, /) -> float32: ...
@@ -5049,7 +5039,7 @@ class float32(_FloatMixin[L[4]], floating[_n._32]):
50495039

50505040
single = float32
50515041

5052-
class float64(_FloatMixin[L[8]], floating[_n._64], float): # type: ignore[misc]
5042+
class float64(_FloatMixin[L[8]], floating, float): # type: ignore[misc]
50535043
@override
50545044
@type_check_only
50555045
def __nep50__(self, below: _inexact64_min, above: _float32_max | _nt.co_integer, /) -> float64: ...
@@ -5085,7 +5075,7 @@ class float64(_FloatMixin[L[8]], floating[_n._64], float): # type: ignore[misc]
50855075

50865076
double = float64
50875077

5088-
class longdouble(_FloatMixin[L[12, 16]], floating[_n._64L]):
5078+
class longdouble(_FloatMixin[L[12, 16]], floating):
50895079
@override
50905080
@type_check_only
50915081
def __nep50__(
@@ -5123,7 +5113,7 @@ class longdouble(_FloatMixin[L[12, 16]], floating[_n._64L]):
51235113
float96 = longdouble
51245114
float128 = longdouble
51255115

5126-
class complexfloating(inexact[_BitT1, complex], Generic[_BitT1, _BitT2]):
5116+
class complexfloating(inexact[complex]):
51275117
@abc.abstractmethod
51285118
@override
51295119
@type_check_only
@@ -5172,7 +5162,7 @@ class complexfloating(inexact[_BitT1, complex], Generic[_BitT1, _BitT2]):
51725162
)
51735163
def __round__(self, /, ndigits: CanIndex | None = None) -> Self: ...
51745164

5175-
class complex64(complexfloating[_n._32]):
5165+
class complex64(complexfloating):
51765166
@override
51775167
@type_check_only
51785168
def __nep50__(self, below: complexfloating, above: _float32_max | _nt.co_integer16, /) -> complex64: ...
@@ -5209,7 +5199,7 @@ class complex64(complexfloating[_n._32]):
52095199

52105200
csingle = complex64
52115201

5212-
class complex128(complexfloating[_n._64], complex): # type: ignore[misc]
5202+
class complex128(complexfloating, complex): # type: ignore[misc]
52135203
@override
52145204
@type_check_only
52155205
def __nep50__(self, below: _complex128_min, above: complex64 | _float64_max | _nt.co_integer, /) -> complex128: ...
@@ -5255,7 +5245,7 @@ class complex128(complexfloating[_n._64], complex): # type: ignore[misc]
52555245

52565246
cdouble = complex128
52575247

5258-
class clongdouble(complexfloating[_n._64L]):
5248+
class clongdouble(complexfloating):
52595249
@override
52605250
@type_check_only
52615251
def __nep50__(self, below: clongdouble, above: _nt.co_number, /) -> clongdouble: ...

β€Žsrc/numpy-stubs/_typing/__init__.pyiβ€Ž

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ from ._dtype_like import (
9595
_SupportsDType as _SupportsDType,
9696
_VoidDTypeLike as _VoidDTypeLike,
9797
)
98-
from ._nbit_base import NBitBase as NBitBase
9998
from ._nested_sequence import _NestedSequence as _NestedSequence
10099
from ._scalars import (
101100
_BoolLike_co as _BoolLike_co,

β€Žsrc/numpy-stubs/_typing/_nbit.pyiβ€Ž

Whitespace-only changes.

β€Žsrc/numpy-stubs/_typing/_nbit_base.pyiβ€Ž

Lines changed: 0 additions & 36 deletions
This file was deleted.

β€Žsrc/numpy-stubs/linalg/_linalg.pyiβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,14 +459,14 @@ def cholesky(a: CoComplex128_1nd, /, *, upper: bool = False) -> _Array_2nd[np.in
459459

460460
#
461461
@overload
462-
def outer(x1: _ToArray_1d[_IntegerT], x2: _ToArray_1d[_IntegerT], /) -> Array2D[_IntegerT]: ...
463-
@overload
464462
def outer(x1: ToBool_1d, x2: ToBool_1d, /) -> Array2D[np.bool]: ...
465463
@overload
466464
def outer(x1: ToInt_1d, x2: CoInt64_1d, /) -> Array2D[np.intp]: ...
467465
@overload
468466
def outer(x1: CoInt64_1d, x2: ToInt_1d, /) -> Array2D[np.intp]: ...
469467
@overload
468+
def outer(x1: _ToArray_1d[_IntegerT], x2: _ToArray_1d[_IntegerT], /) -> Array2D[_IntegerT]: ...
469+
@overload
470470
def outer(x1: ToFloat32_1d, x2: ToFloat32_1d, /) -> Array2D[np.float32]: ...
471471
@overload
472472
def outer(x1: ToFloat64_1d, x2: CoFloat64_1d, /) -> Array2D[np.float64]: ...

0 commit comments

Comments
Β (0)