From cf4926c2ef7d6be3ade3ee1bb447a108b44b19ce Mon Sep 17 00:00:00 2001 From: jorenham Date: Tue, 17 Dec 2024 20:28:55 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=BD=EF=B8=8F=20`sparse`:=20add=20`expl?= =?UTF-8?q?icit`=20kwarg=20to=20`*min`=20and=20`*max`=20sparse=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .mypyignore-todo | 3 +- scipy-stubs/sparse/_data.pyi | 105 +++++++++++++++++++++++++++-------- 2 files changed, 82 insertions(+), 26 deletions(-) diff --git a/.mypyignore-todo b/.mypyignore-todo index 1ba3bc02..3ed73d73 100644 --- a/.mypyignore-todo +++ b/.mypyignore-todo @@ -1,6 +1,5 @@ -scipy\.sparse\.(_?construct\.)?rand(om(_array)?)? scipy\.sparse\._coo\._coo_base\.tensordot -scipy\.sparse\._data\._minmax_mixin\.(arg|nan)?(max|min) +scipy\.sparse\.(_?construct\.)?rand(om(_array)?)? scipy\.spatial\.distance\.directed_hausdorff scipy\.spatial\.transform\.(_?rotation\.)?Rotation\.random diff --git a/scipy-stubs/sparse/_data.pyi b/scipy-stubs/sparse/_data.pyi index 3d40d429..07e1d5cf 100644 --- a/scipy-stubs/sparse/_data.pyi +++ b/scipy-stubs/sparse/_data.pyi @@ -158,56 +158,113 @@ class _data_matrix(_spbase[_SCT_co, _ShapeT_co], Generic[_SCT_co, _ShapeT_co]): class _minmax_mixin(Generic[_SCT_co, _ShapeT_co]): # NOTE: The following 4 methods have identical signatures @overload # axis: None = ..., out: None = ... - def max(self, /, axis: None = None, out: None = None) -> _SCT_co: ... + def max(self, /, axis: None = None, out: None = None, *, explicit: bool = False) -> _SCT_co: ... @overload # 1-d, axis: int, out: None = ... - def max(self: _minmax_mixin[Any, tuple[int]], /, axis: onp.ToInt | None = None, out: None = None) -> _SCT_co: ... + def max( + self: _minmax_mixin[Any, tuple[int]], + /, + axis: onp.ToInt | None = None, + out: None = None, + *, + explicit: bool = False, + ) -> _SCT_co: ... @overload # sparray, axis: int, out: None = ... - def max(self: sparray, /, axis: onp.ToInt, out: None = None) -> coo_array[_SCT_co, tuple[int]]: ... # type: ignore[misc] + def max(self: sparray, /, axis: onp.ToInt, out: None = None, *, explicit: bool = False) -> coo_array[_SCT_co, tuple[int]]: ... # type: ignore[misc] @overload # spmatrix, axis: int, out: None = ... - def max(self: spmatrix, /, axis: onp.ToInt, out: None = None) -> coo_matrix[_SCT_co]: ... # type: ignore[misc] + def max(self: spmatrix, /, axis: onp.ToInt, out: None = None, *, explicit: bool = False) -> coo_matrix[_SCT_co]: ... # type: ignore[misc] # @overload # axis: None = ..., out: None = ... - def nanmax(self, /, axis: None = None, out: None = None) -> _SCT_co: ... + def nanmax(self, /, axis: None = None, out: None = None, *, explicit: bool = False) -> _SCT_co: ... @overload # 1-d, axis: int, out: None = ... - def nanmax(self: _minmax_mixin[Any, tuple[int]], /, axis: onp.ToInt | None = None, out: None = None) -> _SCT_co: ... + def nanmax( + self: _minmax_mixin[Any, tuple[int]], + /, + axis: onp.ToInt | None = None, + out: None = None, + *, + explicit: bool = False, + ) -> _SCT_co: ... @overload # sparray, axis: int, out: None = ... - def nanmax(self: sparray, /, axis: onp.ToInt, out: None = None) -> coo_array[_SCT_co, tuple[int]]: ... # type: ignore[misc] + def nanmax( # type: ignore[misc] + self: sparray, + /, + axis: onp.ToInt, + out: None = None, + *, + explicit: bool = False, + ) -> coo_array[_SCT_co, tuple[int]]: ... @overload # spmatrix, axis: int, out: None = ... - def nanmax(self: spmatrix, /, axis: onp.ToInt, out: None = None) -> coo_matrix[_SCT_co]: ... # type: ignore[misc] + def nanmax(self: spmatrix, /, axis: onp.ToInt, out: None = None, *, explicit: bool = False) -> coo_matrix[_SCT_co]: ... # type: ignore[misc] # @overload # axis: None = ..., out: None = ... - def min(self, /, axis: None = None, out: None = None) -> _SCT_co: ... + def min(self, /, axis: None = None, out: None = None, *, explicit: bool = False) -> _SCT_co: ... @overload # 1-d, axis: int, out: None = ... - def min(self: _minmax_mixin[Any, tuple[int]], /, axis: onp.ToInt | None = None, out: None = None) -> _SCT_co: ... + def min( + self: _minmax_mixin[Any, tuple[int]], + /, + axis: onp.ToInt | None = None, + out: None = None, + *, + explicit: bool = False, + ) -> _SCT_co: ... @overload # sparray, axis: int, out: None = ... - def min(self: sparray, /, axis: onp.ToInt, out: None = None) -> coo_array[_SCT_co, tuple[int]]: ... # type: ignore[misc] + def min(self: sparray, /, axis: onp.ToInt, out: None = None, *, explicit: bool = False) -> coo_array[_SCT_co, tuple[int]]: ... # type: ignore[misc] @overload # spmatrix, axis: int, out: None = ... - def min(self: spmatrix, /, axis: onp.ToInt, out: None = None) -> coo_matrix[_SCT_co]: ... # type: ignore[misc] + def min(self: spmatrix, /, axis: onp.ToInt, out: None = None, *, explicit: bool = False) -> coo_matrix[_SCT_co]: ... # type: ignore[misc] # @overload # axis: None = ..., out: None = ... - def nanmin(self, /, axis: None = None, out: None = None) -> _SCT_co: ... + def nanmin(self, /, axis: None = None, out: None = None, *, explicit: bool = False) -> _SCT_co: ... @overload # 1-d, axis: int, out: None = ... - def nanmin(self: _minmax_mixin[Any, tuple[int]], /, axis: onp.ToInt | None = None, out: None = None) -> _SCT_co: ... + def nanmin( + self: _minmax_mixin[Any, tuple[int]], + /, + axis: onp.ToInt | None = None, + out: None = None, + *, + explicit: bool = False, + ) -> _SCT_co: ... @overload # sparray, axis: int, out: None = ... - def nanmin(self: sparray, /, axis: onp.ToInt, out: None = None) -> coo_array[_SCT_co, tuple[int]]: ... # type: ignore[misc] + def nanmin( # type: ignore[misc] + self: sparray, + /, + axis: onp.ToInt, + out: None = None, + *, + explicit: bool = False, + ) -> coo_array[_SCT_co, tuple[int]]: ... @overload # spmatrix, axis: int, out: None = ... - def nanmin(self: spmatrix, /, axis: onp.ToInt, out: None = None) -> coo_matrix[_SCT_co]: ... # type: ignore[misc] + def nanmin(self: spmatrix, /, axis: onp.ToInt, out: None = None, *, explicit: bool = False) -> coo_matrix[_SCT_co]: ... # type: ignore[misc] # NOTE: The following 2 methods have identical signatures @overload # axis: None = ..., out: None = ... - def argmax(self, /, axis: None = None, out: None = None) -> int: ... + def argmax(self, /, axis: None = None, out: None = None, *, explicit: bool = False) -> int: ... @overload # 1-d, axis: int, out: None = ... - def argmax(self: _minmax_mixin[Any, tuple[int]], /, axis: onp.ToInt | None = None, out: None = None) -> int: ... + def argmax( + self: _minmax_mixin[Any, tuple[int]], + /, + axis: onp.ToInt | None = None, + out: None = None, + *, + explicit: bool = False, + ) -> int: ... @overload # sparray, axis: int, out: None = ... - def argmax(self: sparray, /, axis: onp.ToInt, out: None = None) -> onp.Array1D[np.intp]: ... # type: ignore[misc] + def argmax(self: sparray, /, axis: onp.ToInt, out: None = None, *, explicit: bool = False) -> onp.Array1D[np.intp]: ... # type: ignore[misc] @overload # spmatrix, axis: int, out: None = ... - def argmax(self: spmatrix, /, axis: onp.ToInt, out: None = None) -> Matrix[np.intp]: ... # type: ignore[misc] + def argmax(self: spmatrix, /, axis: onp.ToInt, out: None = None, *, explicit: bool = False) -> Matrix[np.intp]: ... # type: ignore[misc] + # @overload # axis: None = ..., out: None = ... - def argmin(self, /, axis: None = None, out: None = None) -> int: ... + def argmin(self, /, axis: None = None, out: None = None, *, explicit: bool = False) -> int: ... @overload # 1-d, axis: int, out: None = ... - def argmin(self: _minmax_mixin[Any, tuple[int]], /, axis: onp.ToInt | None = None, out: None = None) -> int: ... + def argmin( + self: _minmax_mixin[Any, tuple[int]], + /, + axis: onp.ToInt | None = None, + out: None = None, + *, + explicit: bool = False, + ) -> int: ... @overload # sparray, axis: int, out: None = ... - def argmin(self: sparray, /, axis: onp.ToInt, out: None = None) -> onp.Array1D[np.intp]: ... # type: ignore[misc] + def argmin(self: sparray, /, axis: onp.ToInt, out: None = None, *, explicit: bool = False) -> onp.Array1D[np.intp]: ... # type: ignore[misc] @overload # spmatrix, axis: int, out: None = ... - def argmin(self: spmatrix, /, axis: onp.ToInt, out: None = None) -> Matrix[np.intp]: ... # type: ignore[misc] + def argmin(self: spmatrix, /, axis: onp.ToInt, out: None = None, *, explicit: bool = False) -> Matrix[np.intp]: ... # type: ignore[misc]