Skip to content

Commit

Permalink
👽️ sparse: >2-d coo_array support
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenham committed Dec 17, 2024
1 parent e6fa2a2 commit 25af394
Show file tree
Hide file tree
Showing 13 changed files with 296 additions and 200 deletions.
168 changes: 102 additions & 66 deletions scipy-stubs/sparse/_base.pyi

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions scipy-stubs/sparse/_bsr.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ from ._base import _spbase, sparray
from ._compressed import _cs_matrix
from ._data import _minmax_mixin
from ._matrix import spmatrix
from ._typing import Int, Scalar, ToShape2D
from ._typing import Int, Scalar, ToShape2d

__all__ = ["bsr_array", "bsr_matrix", "isspmatrix_bsr"]

Expand Down Expand Up @@ -47,7 +47,7 @@ class _bsr_base(_cs_matrix[_SCT, tuple[int, int]], _minmax_mixin[_SCT, tuple[int
self,
/,
arg1: _ToMatrix[_SCT] | _ToData[_SCT],
shape: ToShape2D | None = None,
shape: ToShape2d | None = None,
dtype: None = None,
copy: bool = False,
blocksize: tuple[int, int] | None = None,
Expand All @@ -58,7 +58,7 @@ class _bsr_base(_cs_matrix[_SCT, tuple[int, int]], _minmax_mixin[_SCT, tuple[int
def __init__(
self: _bsr_base[np.float64],
/,
arg1: ToShape2D,
arg1: ToShape2d,
shape: None = None,
dtype: None = None,
copy: bool = False,
Expand All @@ -69,7 +69,7 @@ class _bsr_base(_cs_matrix[_SCT, tuple[int, int]], _minmax_mixin[_SCT, tuple[int
self: _bsr_base[np.bool_],
/,
arg1: _ToMatrixPy[bool],
shape: ToShape2D | None = None,
shape: ToShape2d | None = None,
dtype: onp.AnyBoolDType | None = None,
copy: bool = False,
blocksize: tuple[int, int] | None = None,
Expand All @@ -81,7 +81,7 @@ class _bsr_base(_cs_matrix[_SCT, tuple[int, int]], _minmax_mixin[_SCT, tuple[int
self: _bsr_base[np.int_],
/,
arg1: _ToMatrixPy[opt.JustInt],
shape: ToShape2D | None = None,
shape: ToShape2d | None = None,
dtype: type[opt.JustInt] | onp.AnyIntPDType | None = None,
copy: bool = False,
blocksize: tuple[int, int] | None = None,
Expand All @@ -93,7 +93,7 @@ class _bsr_base(_cs_matrix[_SCT, tuple[int, int]], _minmax_mixin[_SCT, tuple[int
self: _bsr_base[np.float64],
/,
arg1: _ToMatrixPy[opt.Just[float]],
shape: ToShape2D | None = None,
shape: ToShape2d | None = None,
dtype: type[opt.Just[float]] | onp.AnyFloat64DType | None = None,
copy: bool = False,
blocksize: tuple[int, int] | None = None,
Expand All @@ -105,7 +105,7 @@ class _bsr_base(_cs_matrix[_SCT, tuple[int, int]], _minmax_mixin[_SCT, tuple[int
self: _bsr_base[np.complex128],
/,
arg1: _ToMatrixPy[opt.Just[complex]],
shape: ToShape2D | None = None,
shape: ToShape2d | None = None,
dtype: type[opt.Just[complex]] | onp.AnyComplex128DType | None = None,
copy: bool = False,
blocksize: tuple[int, int] | None = None,
Expand All @@ -117,7 +117,7 @@ class _bsr_base(_cs_matrix[_SCT, tuple[int, int]], _minmax_mixin[_SCT, tuple[int
self,
/,
arg1: onp.ToComplexND,
shape: ToShape2D | None,
shape: ToShape2d | None,
dtype: _ToDType[_SCT],
copy: bool = False,
blocksize: tuple[int, int] | None = None,
Expand All @@ -129,7 +129,7 @@ class _bsr_base(_cs_matrix[_SCT, tuple[int, int]], _minmax_mixin[_SCT, tuple[int
self,
/,
arg1: onp.ToComplexND,
shape: ToShape2D | None = None,
shape: ToShape2d | None = None,
*,
dtype: _ToDType[_SCT],
copy: bool = False,
Expand Down
49 changes: 25 additions & 24 deletions scipy-stubs/sparse/_compressed.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,23 @@ from ._typing import (
Index1D,
Int,
Scalar,
Shape,
ToDType,
ToDTypeBool,
ToDTypeComplex,
ToDTypeFloat,
ToDTypeInt,
ToShape,
ToShape1D,
ToShape2D,
ToShape1d,
ToShape1dNd,
ToShape2d,
)

__all__: list[str] = []

_T = TypeVar("_T")
_SCT = TypeVar("_SCT", bound=Scalar, default=Any)
_SCT0 = TypeVar("_SCT0", bound=Scalar)
_ShapeT_co = TypeVar("_ShapeT_co", bound=tuple[int] | tuple[int, int], default=tuple[int] | tuple[int, int], covariant=True)
_ShapeT_co = TypeVar("_ShapeT_co", bound=Shape, default=Shape, covariant=True)

_ToMatrix: TypeAlias = _spbase[_SCT] | onp.CanArrayND[_SCT] | Sequence[onp.CanArrayND[_SCT]] | _ToMatrixPy[_SCT]
_ToMatrixPy: TypeAlias = Sequence[_T] | Sequence[Sequence[_T]]
Expand Down Expand Up @@ -85,7 +86,7 @@ class _cs_matrix(
self: _cs_matrix[_SCT0, tuple[int]],
/,
arg1: Sequence[_SCT0],
shape: ToShape1D | None = None,
shape: ToShape1d | None = None,
dtype: ToDType[_SCT0] | None = None,
copy: bool = False,
*,
Expand All @@ -96,7 +97,7 @@ class _cs_matrix(
self: _cs_matrix[_SCT0, tuple[int, int]],
/,
arg1: Sequence[Sequence[_SCT0]] | Sequence[onp.CanArrayND[_SCT0]], # assumes max. 2-d
shape: ToShape2D | None = None,
shape: ToShape2d | None = None,
dtype: ToDType[_SCT0] | None = None,
copy: bool = False,
*,
Expand All @@ -107,7 +108,7 @@ class _cs_matrix(
self,
/,
arg1: _ToMatrix[_SCT] | _ToData[_SCT],
shape: ToShape | None = None,
shape: ToShape1dNd | None = None,
dtype: ToDType[_SCT] | None = None,
copy: bool = False,
*,
Expand All @@ -117,8 +118,8 @@ class _cs_matrix(
def __init__(
self: _cs_matrix[np.float64, tuple[int]],
/,
arg1: ToShape1D,
shape: ToShape1D | None = None,
arg1: ToShape1d,
shape: ToShape1d | None = None,
dtype: ToDTypeFloat | None = None,
copy: bool = False,
*,
Expand All @@ -128,8 +129,8 @@ class _cs_matrix(
def __init__(
self: _cs_matrix[np.float64, tuple[int, int]],
/,
arg1: ToShape2D,
shape: ToShape2D | None = None,
arg1: ToShape2d,
shape: ToShape2d | None = None,
dtype: ToDTypeFloat | None = None,
copy: bool = False,
*,
Expand All @@ -140,7 +141,7 @@ class _cs_matrix(
self: _cs_matrix[np.bool_, tuple[int]],
/,
arg1: Sequence[bool],
shape: ToShape1D | None = None,
shape: ToShape1d | None = None,
dtype: ToDTypeBool | None = None,
copy: bool = False,
*,
Expand All @@ -151,7 +152,7 @@ class _cs_matrix(
self: _cs_matrix[np.bool_, tuple[int, int]],
/,
arg1: Sequence[Sequence[bool]],
shape: ToShape2D | None = None,
shape: ToShape2d | None = None,
dtype: ToDTypeBool | None = None,
copy: bool = False,
*,
Expand All @@ -162,7 +163,7 @@ class _cs_matrix(
self: _cs_matrix[np.int_, tuple[int]],
/,
arg1: Sequence[opt.JustInt],
shape: ToShape | None = None,
shape: ToShape1dNd | None = None,
dtype: ToDTypeInt | None = None,
copy: bool = False,
*,
Expand All @@ -173,7 +174,7 @@ class _cs_matrix(
self: _cs_matrix[np.int_, tuple[int, int]],
/,
arg1: Sequence[Sequence[opt.JustInt]],
shape: ToShape | None = None,
shape: ToShape1dNd | None = None,
dtype: ToDTypeInt | None = None,
copy: bool = False,
*,
Expand All @@ -184,7 +185,7 @@ class _cs_matrix(
self: _cs_matrix[np.float64, tuple[int]],
/,
arg1: Sequence[opt.Just[float]],
shape: ToShape | None = None,
shape: ToShape1dNd | None = None,
dtype: ToDTypeFloat | None = None,
copy: bool = False,
*,
Expand All @@ -195,7 +196,7 @@ class _cs_matrix(
self: _cs_matrix[np.float64, tuple[int, int]],
/,
arg1: Sequence[Sequence[opt.Just[float]]],
shape: ToShape | None = None,
shape: ToShape1dNd | None = None,
dtype: ToDTypeFloat | None = None,
copy: bool = False,
*,
Expand All @@ -206,7 +207,7 @@ class _cs_matrix(
self: _cs_matrix[np.complex128, tuple[int]],
/,
arg1: Sequence[opt.Just[complex]],
shape: ToShape | None = None,
shape: ToShape1dNd | None = None,
dtype: ToDTypeComplex | None = None,
copy: bool = False,
*,
Expand All @@ -217,7 +218,7 @@ class _cs_matrix(
self: _cs_matrix[np.complex128, tuple[int, int]],
/,
arg1: Sequence[Sequence[opt.Just[complex]]],
shape: ToShape | None = None,
shape: ToShape1dNd | None = None,
dtype: ToDTypeComplex | None = None,
copy: bool = False,
*,
Expand All @@ -228,7 +229,7 @@ class _cs_matrix(
self: _cs_matrix[_SCT0, tuple[int]],
/,
arg1: onp.ToComplexStrict1D,
shape: ToShape1D | None,
shape: ToShape1d | None,
dtype: ToDType[_SCT0],
copy: bool = False,
*,
Expand All @@ -239,7 +240,7 @@ class _cs_matrix(
self: _cs_matrix[_SCT0, tuple[int]],
/,
arg1: onp.ToComplexStrict1D,
shape: ToShape1D | None = None,
shape: ToShape1d | None = None,
*,
dtype: ToDType[_SCT0],
copy: bool = False,
Expand All @@ -250,7 +251,7 @@ class _cs_matrix(
self: _cs_matrix[_SCT0, tuple[int, int]],
/,
arg1: onp.ToComplexStrict2D,
shape: ToShape2D | None,
shape: ToShape2d | None,
dtype: ToDType[_SCT0],
copy: bool = False,
*,
Expand All @@ -261,7 +262,7 @@ class _cs_matrix(
self: _cs_matrix[_SCT0, tuple[int, int]],
/,
arg1: onp.ToComplexStrict2D,
shape: ToShape2D | None = None,
shape: ToShape2d | None = None,
*,
dtype: ToDType[_SCT0],
copy: bool = False,
Expand All @@ -272,7 +273,7 @@ class _cs_matrix(
self,
/,
arg1: onp.ToComplex1D | onp.ToComplex2D,
shape: ToShape | None = None,
shape: ToShape1dNd | None = None,
dtype: npt.DTypeLike | None = ...,
copy: bool = False,
*,
Expand Down
Loading

0 comments on commit 25af394

Please sign in to comment.