Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/_numtype/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ from ._shape import (
Shape3N as Shape3N,
Shape4 as Shape4,
Shape4N as Shape4N,
ShapeLike as ShapeLike,
)

###
Expand Down
6 changes: 5 additions & 1 deletion src/_numtype/_shape.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Never, TypeAlias
from collections.abc import Sequence
from typing import Any, Never, SupportsIndex, TypeAlias
from typing_extensions import TypeAliasType

__all__ = [
Expand All @@ -15,6 +16,7 @@ __all__ = [
"Shape3N",
"Shape4",
"Shape4N",
"ShapeLike",
"ShapeN",
]

Expand All @@ -35,3 +37,5 @@ Shape1N = TypeAliasType("Shape1N", tuple[int, *tuple[int, ...]])
Shape2N = TypeAliasType("Shape2N", tuple[int, int, *tuple[int, ...]])
Shape3N = TypeAliasType("Shape3N", tuple[int, int, int, *tuple[int, ...]])
Shape4N = TypeAliasType("Shape4N", tuple[int, int, int, int, *tuple[int, ...]])

ShapeLike: TypeAlias = SupportsIndex | Sequence[SupportsIndex]
51 changes: 25 additions & 26 deletions src/numpy-stubs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ from ._typing import (
_NestedSequence,
_NumberLike_co,
_ScalarLike_co,
_ShapeLike,
_TD64Like_co,
)
from .lib import scimath as emath
Expand Down Expand Up @@ -1322,7 +1321,7 @@ class _ArrayOrScalarCommon:
def copy(self, order: _OrderKACF = ...) -> Self: ...
def __copy__(self) -> Self: ...
def __deepcopy__(self, memo: dict[int, Any] | None, /) -> Self: ...
def __setstate__(self, state: tuple[CanIndex, _ShapeLike, _DTypeT_co, bool_, bytes | list[Any]], /) -> None: ...
def __setstate__(self, state: tuple[CanIndex, _nt.ShapeLike, _DTypeT_co, bool_, bytes | list[Any]], /) -> None: ...
def __array_namespace__(self, /, *, api_version: _ArrayAPIVersion | None = None) -> ModuleType: ...

#
Expand Down Expand Up @@ -1351,7 +1350,7 @@ class _ArrayOrScalarCommon:
def max(
self,
/,
axis: _ShapeLike | None = None,
axis: _nt.ShapeLike | None = None,
out: None = None,
*,
keepdims: py_bool | _NoValueType = ...,
Expand All @@ -1362,7 +1361,7 @@ class _ArrayOrScalarCommon:
def max(
self,
/,
axis: _ShapeLike | None,
axis: _nt.ShapeLike | None,
out: _ArrayT,
*,
keepdims: py_bool | _NoValueType = ...,
Expand All @@ -1373,7 +1372,7 @@ class _ArrayOrScalarCommon:
def max(
self,
/,
axis: _ShapeLike | None = None,
axis: _nt.ShapeLike | None = None,
*,
out: _ArrayT,
keepdims: py_bool | _NoValueType = ...,
Expand All @@ -1396,7 +1395,7 @@ class _ArrayOrScalarCommon:
def min(
self,
/,
axis: _ShapeLike | None = None,
axis: _nt.ShapeLike | None = None,
out: None = None,
*,
keepdims: py_bool | _NoValueType = ...,
Expand All @@ -1407,7 +1406,7 @@ class _ArrayOrScalarCommon:
def min(
self,
/,
axis: _ShapeLike | None,
axis: _nt.ShapeLike | None,
out: _ArrayT,
*,
keepdims: py_bool | _NoValueType = ...,
Expand All @@ -1418,7 +1417,7 @@ class _ArrayOrScalarCommon:
def min(
self,
/,
axis: _ShapeLike | None = None,
axis: _nt.ShapeLike | None = None,
*,
out: _ArrayT,
keepdims: py_bool | _NoValueType = ...,
Expand Down Expand Up @@ -1492,7 +1491,7 @@ class _ArrayOrScalarCommon:
def sum(
self,
/,
axis: _ShapeLike | None = None,
axis: _nt.ShapeLike | None = None,
dtype: DTypeLike | None = None,
out: None = None,
*,
Expand All @@ -1504,7 +1503,7 @@ class _ArrayOrScalarCommon:
def sum(
self,
/,
axis: _ShapeLike | None,
axis: _nt.ShapeLike | None,
dtype: DTypeLike | None,
out: _ArrayT,
*,
Expand All @@ -1516,7 +1515,7 @@ class _ArrayOrScalarCommon:
def sum(
self,
/,
axis: _ShapeLike | None = None,
axis: _nt.ShapeLike | None = None,
dtype: DTypeLike | None = None,
*,
out: _ArrayT,
Expand All @@ -1540,7 +1539,7 @@ class _ArrayOrScalarCommon:
def prod(
self,
/,
axis: _ShapeLike | None = None,
axis: _nt.ShapeLike | None = None,
dtype: DTypeLike | None = None,
out: None = None,
*,
Expand All @@ -1552,7 +1551,7 @@ class _ArrayOrScalarCommon:
def prod(
self,
/,
axis: _ShapeLike | None,
axis: _nt.ShapeLike | None,
dtype: DTypeLike | None,
out: _ArrayT,
*,
Expand All @@ -1564,7 +1563,7 @@ class _ArrayOrScalarCommon:
def prod(
self,
/,
axis: _ShapeLike | None = None,
axis: _nt.ShapeLike | None = None,
dtype: DTypeLike | None = None,
*,
out: _ArrayT,
Expand All @@ -1577,7 +1576,7 @@ class _ArrayOrScalarCommon:
@overload
def mean(
self,
axis: _ShapeLike | None = None,
axis: _nt.ShapeLike | None = None,
dtype: DTypeLike | None = None,
out: None = None,
*,
Expand All @@ -1588,7 +1587,7 @@ class _ArrayOrScalarCommon:
def mean(
self,
/,
axis: _ShapeLike | None,
axis: _nt.ShapeLike | None,
dtype: DTypeLike | None,
out: _ArrayT,
*,
Expand All @@ -1599,7 +1598,7 @@ class _ArrayOrScalarCommon:
def mean(
self,
/,
axis: _ShapeLike | None = None,
axis: _nt.ShapeLike | None = None,
dtype: DTypeLike | None = None,
*,
out: _ArrayT,
Expand All @@ -1611,7 +1610,7 @@ class _ArrayOrScalarCommon:
@overload
def std(
self,
axis: _ShapeLike | None = None,
axis: _nt.ShapeLike | None = None,
dtype: DTypeLike | None = None,
out: None = None,
ddof: float = 0,
Expand All @@ -1624,7 +1623,7 @@ class _ArrayOrScalarCommon:
@overload
def std(
self,
axis: _ShapeLike | None,
axis: _nt.ShapeLike | None,
dtype: DTypeLike | None,
out: _ArrayT,
ddof: float = 0,
Expand All @@ -1637,7 +1636,7 @@ class _ArrayOrScalarCommon:
@overload
def std(
self,
axis: _ShapeLike | None = None,
axis: _nt.ShapeLike | None = None,
dtype: DTypeLike | None = None,
*,
out: _ArrayT,
Expand All @@ -1652,7 +1651,7 @@ class _ArrayOrScalarCommon:
@overload
def var(
self,
axis: _ShapeLike | None = None,
axis: _nt.ShapeLike | None = None,
dtype: DTypeLike | None = None,
out: None = None,
ddof: float = 0,
Expand All @@ -1665,7 +1664,7 @@ class _ArrayOrScalarCommon:
@overload
def var(
self,
axis: _ShapeLike | None,
axis: _nt.ShapeLike | None,
dtype: DTypeLike | None,
out: _ArrayT,
ddof: float = 0,
Expand All @@ -1678,7 +1677,7 @@ class _ArrayOrScalarCommon:
@overload
def var(
self,
axis: _ShapeLike | None = None,
axis: _nt.ShapeLike | None = None,
dtype: DTypeLike | None = None,
*,
out: _ArrayT,
Expand Down Expand Up @@ -1751,11 +1750,11 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):
#
def __new__(
cls,
shape: _ShapeLike,
shape: _nt.ShapeLike,
dtype: DTypeLike | None = float, # noqa: PYI011
buffer: Buffer | None = None,
offset: CanIndex = 0,
strides: _ShapeLike | None = None,
strides: _nt.ShapeLike | None = None,
order: _OrderKACF | None = None,
) -> Self: ...

Expand Down Expand Up @@ -2775,7 +2774,7 @@ class ndarray(_ArrayOrScalarCommon, Generic[_ShapeT_co, _DTypeT_co]):

#
@overload
def transpose(self, axes: _ShapeLike | None, /) -> Self: ...
def transpose(self, axes: _nt.ShapeLike | None, /) -> Self: ...
@overload
def transpose(self, /, *axes: CanIndex) -> Self: ...

Expand Down
Loading