66if TYPE_CHECKING :
77 import numpy as np
88 from scipy .sparse import sparray , spmatrix , coo_array , coo_matrix
9+ from ._utils import ndarray
910
1011
1112NO_DEFAULT = object ()
@@ -17,10 +18,10 @@ def __init__(self, value: dict[int, float], dimensions: int, /) -> None:
1718 ...
1819
1920 @overload
20- def __init__ (self , value : list [float ] | np . ndarray [ tuple [ int , ...], np . dtype [ np . floating ]] | sparray | spmatrix , / ) -> None :
21+ def __init__ (self , value : list [float ] | ndarray | sparray | spmatrix , / ) -> None :
2122 ...
2223
23- def __init__ (self , value : dict [int , float ] | list [float ] | np . ndarray [ tuple [ int , ...], np . dtype [ np . floating ]] | sparray | spmatrix , dimensions : int | Any = NO_DEFAULT , / ) -> None :
24+ def __init__ (self , value : dict [int , float ] | list [float ] | ndarray | sparray | spmatrix , dimensions : int | Any = NO_DEFAULT , / ) -> None :
2425 if is_sparse_array (value ):
2526 if dimensions is not NO_DEFAULT :
2627 raise ValueError ('extra argument' )
@@ -107,7 +108,7 @@ def _from_sparse(self, arr: sparray | spmatrix) -> None:
107108 self ._indices = value .col .tolist ()
108109 self ._values = value .data .tolist ()
109110
110- def _from_dense (self , value : list [float ] | np . ndarray [ tuple [ int ], np . dtype [ np . floating ]] ) -> None :
111+ def _from_dense (self , value : list [float ] | ndarray ) -> None :
111112 self ._dim = len (value )
112113 self ._indices = [i for i , v in enumerate (value ) if v != 0 ]
113114 self ._values = [float (value [i ]) for i in self ._indices ]
@@ -148,7 +149,7 @@ def _from_parts(cls, dim: int, indices: list[int], values: list[float]) -> Spars
148149 return vec
149150
150151 @classmethod
151- def _to_db (cls , value : list [float ] | np . ndarray [ tuple [ int ], np . dtype [ np . floating ]] | sparray | spmatrix | SparseVector | None ) -> str | None :
152+ def _to_db (cls , value : list [float ] | ndarray | sparray | spmatrix | SparseVector | None ) -> str | None :
152153 if value is None :
153154 return value
154155
0 commit comments