Skip to content

Commit e1988a0

Browse files
committed
🐛 sparse: support lil_{array,matrix} inplace ops +=, -=, *= and /=
1 parent f8c3e05 commit e1988a0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

scipy-stubs/sparse/_lil.pyi

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import numpy as np
66
import optype as op
77
import optype.numpy as onp
88
import optype.typing as opt
9+
from scipy._typing import Falsy
910
from ._base import _spbase, sparray
1011
from ._csr import csr_array, csr_matrix
1112
from ._index import IndexMixin
@@ -130,8 +131,28 @@ class _lil_base(_spbase[_SCT, tuple[int, int]], IndexMixin[_SCT, tuple[int, int]
130131

131132
#
132133
@override
134+
def __iadd__(self, other: Falsy | _spbase[Scalar] | onp.ArrayND[Scalar], /) -> Self: ...
135+
@override
136+
def __isub__(self, other: Falsy | _spbase[Scalar] | onp.ArrayND[Scalar], /) -> Self: ...
137+
@override
138+
def __imul__(self, other: onp.ToComplex, /) -> Self: ... # type: ignore[override]
139+
@override
140+
def __itruediv__(self, other: onp.ToComplex, /) -> Self: ... # type: ignore[override]
141+
@override
142+
def __idiv__(self, other: onp.ToComplex, /) -> Self: ...
143+
144+
#
145+
@override
146+
def tolil(self, /, copy: bool = False) -> Self: ... # type: ignore[override]
147+
@override
133148
def resize(self, /, *shape: int) -> None: ... # type: ignore[override] # pyright: ignore[reportIncompatibleMethodOverride]
134149

150+
# NOTE: Adding `@override` here will crash stubtest (basedmypy 1.13.0)
151+
@overload # type: ignore[explicit-override]
152+
def count_nonzero(self, /, axis: None = None) -> int: ...
153+
@overload
154+
def count_nonzero(self, /, axis: op.CanIndex) -> onp.Array1D[np.intp]: ...
155+
135156
#
136157
def getrowview(self, /, i: int) -> Self: ...
137158
def getrow(self, /, i: onp.ToJustInt) -> csr_array[_SCT, tuple[int, int]] | csr_matrix[_SCT]: ...

0 commit comments

Comments
 (0)