Skip to content

Commit

Permalink
👽️ sparse: add explicit kwarg to *min and *max sparse methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenham committed Dec 17, 2024
1 parent 6dab1dd commit cf4926c
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 26 deletions.
3 changes: 1 addition & 2 deletions .mypyignore-todo
Original file line number Diff line number Diff line change
@@ -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
Expand Down
105 changes: 81 additions & 24 deletions scipy-stubs/sparse/_data.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]

0 comments on commit cf4926c

Please sign in to comment.