Skip to content
Merged
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
3 changes: 0 additions & 3 deletions .mypyignore-todo
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ numpy(\._core(\.einsumfunc)?|\.matlib)?\.einsum_path
numpy(\._core(\.memmap)?|\.matlib)?\.memmap\.__new__
numpy(\.matrixlib(\.defmatrix)?|\.matlib)?\.matrix\.__new__
numpy(\.lib\._polynomial_impl|\.matlib)?\.poly1d\.integ
numpy(\.lib\._index_tricks_impl|\.matlib)?\.ndindex\.ndincr
numpy(\.lib\._index_tricks_impl|\.matlib)?\.ndenumerate\.iter

numpy._core.cversions
numpy._core.printoptions
Expand Down Expand Up @@ -112,7 +110,6 @@ numpy.fft.helper
numpy.lib(._arrayterator_impl)?.Arrayterator.__array__
numpy.lib.(_array_utils_impl|array_utils).normalize_axis_tuple
numpy.lib.(_npyio_impl|npyio).NpzFile.get
numpy.lib._index_tricks_impl.AxisConcatenator.makemat
numpy.lib._iotools.NameValidator.defaultdeletechars
numpy.lib.format.open_memmap
numpy.lib.format.read_array(_header_(1|2)_0)?
Expand Down
26 changes: 7 additions & 19 deletions src/numpy-stubs/lib/_index_tricks_impl.pyi
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from _typeshed import Incomplete
from collections.abc import Sequence
from typing import Any, Final, Generic, Literal as L, SupportsIndex, TypeAlias, final, overload
from typing_extensions import Self, TypeVar
from typing import Any, ClassVar, Final, Generic, Literal as L, SupportsIndex, TypeAlias, final, overload
from typing_extensions import Self, TypeVar, deprecated

import numpy as np
from _numtype import (
Array,
Is,
Matrix,
Sequence_nd,
ToBool_nd,
ToBytes_nd,
Expand All @@ -19,7 +18,7 @@ from _numtype import (
_ToArray1_nd,
)
from numpy._core.multiarray import ravel_multi_index, unravel_index
from numpy._typing import ArrayLike, DTypeLike, _DTypeLike, _SupportsDType as _HasDType
from numpy._typing import ArrayLike, _SupportsDType as _HasDType

__all__ = [
"c_",
Expand Down Expand Up @@ -57,10 +56,6 @@ _Arrays: TypeAlias = tuple[Array[_ScalarT], ...]
###

class ndenumerate(Generic[_ScalarT_co]):
@property
def iter(self) -> np.flatiter[Array[_ScalarT_co]]: ...

#
@overload
def __init__(self: ndenumerate[_ScalarT], /, arr: _ToArray1_nd[_ScalarT]) -> None: ...
@overload
Expand Down Expand Up @@ -101,6 +96,8 @@ class ndindex:
#
def __iter__(self) -> Self: ...
def __next__(self) -> tuple[int, ...]: ...
@deprecated("Deprecated since 1.20.0.")
def ndincr(self, /) -> None: ...

class nd_grid(Generic[_BoolT_co]):
sparse: _BoolT_co
Expand All @@ -121,6 +118,8 @@ class OGridClass(nd_grid[L[True]]):
class AxisConcatenator(Generic[_AxisT_co, _MatrixT_co, _NDMinT_co, _Trans1DT_co]):
__slots__ = "axis", "matrix", "ndmin", "trans1d"

makemat: ClassVar[type[np.matrix[tuple[int, int], np.dtype[Any]]]]

axis: _AxisT_co
matrix: _MatrixT_co
trans1d: _Trans1DT_co
Expand Down Expand Up @@ -151,17 +150,6 @@ class AxisConcatenator(Generic[_AxisT_co, _MatrixT_co, _NDMinT_co, _Trans1DT_co]
@overload
def concatenate(*a: ArrayLike, axis: SupportsIndex | None = 0, out: None = None) -> Array: ...

#
@staticmethod
@overload
def makemat(data: _ToArray1_nd[_ScalarT], dtype: None = None, copy: bool = True) -> Matrix[_ScalarT]: ...
@staticmethod
@overload
def makemat(data: ArrayLike, dtype: _DTypeLike[_ScalarT], copy: bool = True) -> Matrix[_ScalarT]: ...
@staticmethod
@overload
def makemat(data: ArrayLike, dtype: DTypeLike | None = None, copy: bool = True) -> Matrix: ...

@final
class RClass(AxisConcatenator[L[0], L[False], L[1], L[-1]]):
def __init__(self, /) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion src/numpy-stubs/ma/extras.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class _fromnxfunction_allargs(_fromnxfunction):

class MAxisConcatenator(AxisConcatenator):
@classmethod
def makemat(cls, arr: Incomplete) -> Incomplete: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
def makemat(cls, arr: Incomplete) -> Incomplete: ... # type: ignore[override] # pyright: ignore[reportIncompatibleVariableOverride]

class mr_class(MAxisConcatenator):
def __init__(self) -> None: ...
Expand Down
4 changes: 0 additions & 4 deletions test/runtime/accept/index_tricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
np.ndenumerate(AR_LIKE_f)
np.ndenumerate(AR_LIKE_U)

np.ndenumerate(AR_i8).iter
np.ndenumerate(AR_LIKE_f).iter
np.ndenumerate(AR_LIKE_U).iter

next(np.ndenumerate(AR_i8))
next(np.ndenumerate(AR_LIKE_f))
next(np.ndenumerate(AR_LIKE_U))
Expand Down
8 changes: 1 addition & 7 deletions test/static/accept/index_tricks.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,10 @@ assert_type(np.ndenumerate(AR_LIKE_f), np.ndenumerate[np.float64])
assert_type(np.ndenumerate(AR_LIKE_U), np.ndenumerate[np.str_])
assert_type(np.ndenumerate(AR_LIKE_O), np.ndenumerate[np.object_])

assert_type(np.ndenumerate(AR_i8).iter, np.flatiter[npt.NDArray[np.int64]])
assert_type(np.ndenumerate(AR_LIKE_f).iter, np.flatiter[npt.NDArray[np.float64]])
assert_type(np.ndenumerate(AR_LIKE_U).iter, np.flatiter[npt.NDArray[np.str_]])
assert_type(np.ndenumerate(AR_LIKE_O).iter, np.flatiter[npt.NDArray[np.object_]])

assert_type(next(np.ndenumerate(AR_i8)), tuple[tuple[int, ...], np.int64])
assert_type(next(np.ndenumerate(AR_LIKE_f)), tuple[tuple[int, ...], np.float64])
assert_type(next(np.ndenumerate(AR_LIKE_U)), tuple[tuple[int, ...], np.str_])
# this fails due to an unknown mypy bug
# assert_type(next(np.ndenumerate(AR_LIKE_O)), tuple[tuple[int, ...], Any])
assert_type(next(np.ndenumerate(AR_LIKE_O)), tuple[tuple[int, ...], Any])

assert_type(iter(np.ndenumerate(AR_i8)), np.ndenumerate[np.int64])
assert_type(iter(np.ndenumerate(AR_LIKE_f)), np.ndenumerate[np.float64])
Expand Down