Skip to content

Commit a3fb8e9

Browse files
committed
Move _ShapeLike from numpy._typing to public numtype
1 parent c228475 commit a3fb8e9

22 files changed

Lines changed: 590 additions & 630 deletions

src/_numtype/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ from ._shape import (
144144
AnyShape as AnyShape,
145145
NeitherShape as NeitherShape,
146146
Shape as Shape,
147-
_ShapeLike as _ShapeLike,
148147
Shape0 as Shape0,
149148
Shape0N as Shape0N,
150149
Shape1 as Shape1,
@@ -155,6 +154,7 @@ from ._shape import (
155154
Shape3N as Shape3N,
156155
Shape4 as Shape4,
157156
Shape4N as Shape4N,
157+
ShapeLike as ShapeLike,
158158
)
159159

160160
###

src/_numtype/_shape.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ __all__ = [
1616
"Shape3N",
1717
"Shape4",
1818
"Shape4N",
19+
"ShapeLike",
1920
"ShapeN",
2021
]
2122

@@ -37,4 +38,4 @@ Shape2N = TypeAliasType("Shape2N", tuple[int, int, *tuple[int, ...]])
3738
Shape3N = TypeAliasType("Shape3N", tuple[int, int, int, *tuple[int, ...]])
3839
Shape4N = TypeAliasType("Shape4N", tuple[int, int, int, int, *tuple[int, ...]])
3940

40-
_ShapeLike: TypeAlias = SupportsIndex | Sequence[SupportsIndex]
41+
ShapeLike: TypeAlias = SupportsIndex | Sequence[SupportsIndex]

src/numpy-stubs/__init__.pyi

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,6 @@ from ._typing import (
348348
_ScalarLike_co,
349349
_TD64Like_co,
350350
)
351-
352-
_ShapeLike = _nt._ShapeLike
353351
from .lib import scimath as emath
354352
from .lib._arraypad_impl import pad
355353
from .lib._arraysetops_impl import (
@@ -1323,7 +1321,7 @@ class _ArrayOrScalarCommon:
13231321
def copy(self, order: _OrderKACF = ...) -> Self: ...
13241322
def __copy__(self) -> Self: ...
13251323
def __deepcopy__(self, memo: dict[int, Any] | None, /) -> Self: ...
1326-
def __setstate__(self, state: tuple[CanIndex, _ShapeLike, _DTypeT_co, bool_, bytes | list[Any]], /) -> None: ...
1324+
def __setstate__(self, state: tuple[CanIndex, _nt.ShapeLike, _DTypeT_co, bool_, bytes | list[Any]], /) -> None: ...
13271325
def __array_namespace__(self, /, *, api_version: _ArrayAPIVersion | None = None) -> ModuleType: ...
13281326

13291327
#
@@ -1352,7 +1350,7 @@ class _ArrayOrScalarCommon:
13521350
def max(
13531351
self,
13541352
/,
1355-
axis: _ShapeLike | None = None,
1353+
axis: _nt.ShapeLike | None = None,
13561354
out: None = None,
13571355
*,
13581356
keepdims: py_bool | _NoValueType = ...,
@@ -1363,7 +1361,7 @@ class _ArrayOrScalarCommon:
13631361
def max(
13641362
self,
13651363
/,
1366-
axis: _ShapeLike | None,
1364+
axis: _nt.ShapeLike | None,
13671365
out: _ArrayT,
13681366
*,
13691367
keepdims: py_bool | _NoValueType = ...,
@@ -1374,7 +1372,7 @@ class _ArrayOrScalarCommon:
13741372
def max(
13751373
self,
13761374
/,
1377-
axis: _ShapeLike | None = None,
1375+
axis: _nt.ShapeLike | None = None,
13781376
*,
13791377
out: _ArrayT,
13801378
keepdims: py_bool | _NoValueType = ...,
@@ -1397,7 +1395,7 @@ class _ArrayOrScalarCommon:
13971395
def min(
13981396
self,
13991397
/,
1400-
axis: _ShapeLike | None = None,
1398+
axis: _nt.ShapeLike | None = None,
14011399
out: None = None,
14021400
*,
14031401
keepdims: py_bool | _NoValueType = ...,
@@ -1408,7 +1406,7 @@ class _ArrayOrScalarCommon:
14081406
def min(
14091407
self,
14101408
/,
1411-
axis: _ShapeLike | None,
1409+
axis: _nt.ShapeLike | None,
14121410
out: _ArrayT,
14131411
*,
14141412
keepdims: py_bool | _NoValueType = ...,
@@ -1419,7 +1417,7 @@ class _ArrayOrScalarCommon:
14191417
def min(
14201418
self,
14211419
/,
1422-
axis: _ShapeLike | None = None,
1420+
axis: _nt.ShapeLike | None = None,
14231421
*,
14241422
out: _ArrayT,
14251423
keepdims: py_bool | _NoValueType = ...,
@@ -1493,7 +1491,7 @@ class _ArrayOrScalarCommon:
14931491
def sum(
14941492
self,
14951493
/,
1496-
axis: _ShapeLike | None = None,
1494+
axis: _nt.ShapeLike | None = None,
14971495
dtype: DTypeLike | None = None,
14981496
out: None = None,
14991497
*,
@@ -1505,7 +1503,7 @@ class _ArrayOrScalarCommon:
15051503
def sum(
15061504
self,
15071505
/,
1508-
axis: _ShapeLike | None,
1506+
axis: _nt.ShapeLike | None,
15091507
dtype: DTypeLike | None,
15101508
out: _ArrayT,
15111509
*,
@@ -1517,7 +1515,7 @@ class _ArrayOrScalarCommon:
15171515
def sum(
15181516
self,
15191517
/,
1520-
axis: _ShapeLike | None = None,
1518+
axis: _nt.ShapeLike | None = None,
15211519
dtype: DTypeLike | None = None,
15221520
*,
15231521
out: _ArrayT,
@@ -1541,7 +1539,7 @@ class _ArrayOrScalarCommon:
15411539
def prod(
15421540
self,
15431541
/,
1544-
axis: _ShapeLike | None = None,
1542+
axis: _nt.ShapeLike | None = None,
15451543
dtype: DTypeLike | None = None,
15461544
out: None = None,
15471545
*,
@@ -1553,7 +1551,7 @@ class _ArrayOrScalarCommon:
15531551
def prod(
15541552
self,
15551553
/,
1556-
axis: _ShapeLike | None,
1554+
axis: _nt.ShapeLike | None,
15571555
dtype: DTypeLike | None,
15581556
out: _ArrayT,
15591557
*,
@@ -1565,7 +1563,7 @@ class _ArrayOrScalarCommon:
15651563
def prod(
15661564
self,
15671565
/,
1568-
axis: _ShapeLike | None = None,
1566+
axis: _nt.ShapeLike | None = None,
15691567
dtype: DTypeLike | None = None,
15701568
*,
15711569
out: _ArrayT,
@@ -1578,7 +1576,7 @@ class _ArrayOrScalarCommon:
15781576
@overload
15791577
def mean(
15801578
self,
1581-
axis: _ShapeLike | None = None,
1579+
axis: _nt.ShapeLike | None = None,
15821580
dtype: DTypeLike | None = None,
15831581
out: None = None,
15841582
*,
@@ -1589,7 +1587,7 @@ class _ArrayOrScalarCommon:
15891587
def mean(
15901588
self,
15911589
/,
1592-
axis: _ShapeLike | None,
1590+
axis: _nt.ShapeLike | None,
15931591
dtype: DTypeLike | None,
15941592
out: _ArrayT,
15951593
*,
@@ -1600,7 +1598,7 @@ class _ArrayOrScalarCommon:
16001598
def mean(
16011599
self,
16021600
/,
1603-
axis: _ShapeLike | None = None,
1601+
axis: _nt.ShapeLike | None = None,
16041602
dtype: DTypeLike | None = None,
16051603
*,
16061604
out: _ArrayT,
@@ -1612,7 +1610,7 @@ class _ArrayOrScalarCommon:
16121610
@overload
16131611
def std(
16141612
self,
1615-
axis: _ShapeLike | None = None,
1613+
axis: _nt.ShapeLike | None = None,
16161614
dtype: DTypeLike | None = None,
16171615
out: None = None,
16181616
ddof: float = 0,
@@ -1625,7 +1623,7 @@ class _ArrayOrScalarCommon:
16251623
@overload
16261624
def std(
16271625
self,
1628-
axis: _ShapeLike | None,
1626+
axis: _nt.ShapeLike | None,
16291627
dtype: DTypeLike | None,
16301628
out: _ArrayT,
16311629
ddof: float = 0,
@@ -1638,7 +1636,7 @@ class _ArrayOrScalarCommon:
16381636
@overload
16391637
def std(
16401638
self,
1641-
axis: _ShapeLike | None = None,
1639+
axis: _nt.ShapeLike | None = None,
16421640
dtype: DTypeLike | None = None,
16431641
*,
16441642
out: _ArrayT,
@@ -1653,7 +1651,7 @@ class _ArrayOrScalarCommon:
16531651
@overload
16541652
def var(
16551653
self,
1656-
axis: _ShapeLike | None = None,
1654+
axis: _nt.ShapeLike | None = None,
16571655
dtype: DTypeLike | None = None,
16581656
out: None = None,
16591657
ddof: float = 0,
@@ -1666,7 +1664,7 @@ class _ArrayOrScalarCommon:
16661664
@overload
16671665
def var(
16681666
self,
1669-
axis: _ShapeLike | None,
1667+
axis: _nt.ShapeLike | None,
16701668
dtype: DTypeLike | None,
16711669
out: _ArrayT,
16721670
ddof: float = 0,
@@ -1679,7 +1677,7 @@ class _ArrayOrScalarCommon:
16791677
@overload
16801678
def var(
16811679
self,
1682-
axis: _ShapeLike | None = None,
1680+
axis: _nt.ShapeLike | None = None,
16831681
dtype: DTypeLike | None = None,
16841682
*,
16851683
out: _ArrayT,
@@ -1752,11 +1750,11 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
17521750
#
17531751
def __new__(
17541752
cls,
1755-
shape: _ShapeLike,
1753+
shape: _nt.ShapeLike,
17561754
dtype: DTypeLike | None = float, # noqa: PYI011
17571755
buffer: Buffer | None = None,
17581756
offset: CanIndex = 0,
1759-
strides: _ShapeLike | None = None,
1757+
strides: _nt.ShapeLike | None = None,
17601758
order: _OrderKACF | None = None,
17611759
) -> Self: ...
17621760

@@ -2776,7 +2774,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
27762774

27772775
#
27782776
@overload
2779-
def transpose(self, axes: _ShapeLike | None, /) -> Self: ...
2777+
def transpose(self, axes: _nt.ShapeLike | None, /) -> Self: ...
27802778
@overload
27812779
def transpose(self, /, *axes: CanIndex) -> Self: ...
27822780

0 commit comments

Comments
 (0)