@@ -10,35 +10,22 @@ import optype.numpy as onp
10
10
from ._base import _spbase
11
11
from ._data import _data_matrix , _minmax_mixin
12
12
from ._index import IndexMixin
13
- from ._typing import (
14
- Index1D ,
15
- Int ,
16
- Scalar ,
17
- Shape ,
18
- ToDType ,
19
- ToDTypeBool ,
20
- ToDTypeComplex ,
21
- ToDTypeFloat ,
22
- ToDTypeInt ,
23
- ToShape1d ,
24
- ToShape1dNd ,
25
- ToShape2d ,
26
- )
13
+ from ._typing import Index1D , Integer , Numeric , ToShape1D , ToShape2D , ToShapeMin1D
27
14
28
15
__all__ : list [str ] = []
29
16
30
17
_T = TypeVar ("_T" )
31
- _SCT = TypeVar ("_SCT" , bound = Scalar , default = Any )
32
- _SCT0 = TypeVar ("_SCT0" , bound = Scalar )
33
- _ShapeT_co = TypeVar ("_ShapeT_co" , bound = Shape , default = Shape , covariant = True )
18
+ _SCT = TypeVar ("_SCT" , bound = Numeric , default = Any )
19
+ _SCT0 = TypeVar ("_SCT0" , bound = Numeric )
20
+ _ShapeT_co = TypeVar ("_ShapeT_co" , bound = onp . AtLeast1D , default = onp . AtLeast1D , covariant = True )
34
21
35
22
_ToMatrix : TypeAlias = _spbase [_SCT ] | onp .CanArrayND [_SCT ] | Sequence [onp .CanArrayND [_SCT ]] | _ToMatrixPy [_SCT ]
36
23
_ToMatrixPy : TypeAlias = Sequence [_T ] | Sequence [Sequence [_T ]]
37
24
38
- _ToData2B : TypeAlias = tuple [onp .ArrayND [_SCT ], onp .ArrayND [Int ]] # bsr
39
- _ToData2C : TypeAlias = tuple [onp .ArrayND [_SCT ], tuple [onp .ArrayND [Int ], onp .ArrayND [Int ]]] # csc, csr
25
+ _ToData2B : TypeAlias = tuple [onp .ArrayND [_SCT ], onp .ArrayND [Integer ]] # bsr
26
+ _ToData2C : TypeAlias = tuple [onp .ArrayND [_SCT ], tuple [onp .ArrayND [Integer ], onp .ArrayND [Integer ]]] # csc, csr
40
27
_ToData2 : TypeAlias = _ToData2B [_SCT ] | _ToData2C [_SCT ]
41
- _ToData3 : TypeAlias = tuple [onp .ArrayND [_SCT ], onp .ArrayND [Int ], onp .ArrayND [Int ]]
28
+ _ToData3 : TypeAlias = tuple [onp .ArrayND [_SCT ], onp .ArrayND [Integer ], onp .ArrayND [Integer ]]
42
29
_ToData : TypeAlias = _ToData2 [_SCT ] | _ToData3 [_SCT ]
43
30
44
31
###
@@ -49,7 +36,7 @@ class _cs_matrix(
49
36
IndexMixin [_SCT , _ShapeT_co ],
50
37
Generic [_SCT , _ShapeT_co ],
51
38
):
52
- data : onp .Array [ Any , _SCT ] # the `Any` shape is needed for `numpy<2.1`
39
+ data : onp .ArrayND [ _SCT ]
53
40
indices : Index1D
54
41
indptr : Index1D
55
42
@@ -76,7 +63,7 @@ class _cs_matrix(
76
63
/ ,
77
64
arg1 : _spbase [_SCT , _ShapeT_co ] | onp .CanArrayND [_SCT , _ShapeT_co ],
78
65
shape : _ShapeT_co | None = None ,
79
- dtype : ToDType [_SCT ] | None = None ,
66
+ dtype : onp . ToDType [_SCT ] | None = None ,
80
67
copy : bool = False ,
81
68
* ,
82
69
maxprint : int | None = None ,
@@ -86,8 +73,8 @@ class _cs_matrix(
86
73
self : _cs_matrix [_SCT0 , tuple [int ]],
87
74
/ ,
88
75
arg1 : Sequence [_SCT0 ],
89
- shape : ToShape1d | None = None ,
90
- dtype : ToDType [_SCT0 ] | None = None ,
76
+ shape : ToShape1D | None = None ,
77
+ dtype : onp . ToDType [_SCT0 ] | None = None ,
91
78
copy : bool = False ,
92
79
* ,
93
80
maxprint : int | None = None ,
@@ -97,8 +84,8 @@ class _cs_matrix(
97
84
self : _cs_matrix [_SCT0 , tuple [int , int ]],
98
85
/ ,
99
86
arg1 : Sequence [Sequence [_SCT0 ]] | Sequence [onp .CanArrayND [_SCT0 ]], # assumes max. 2-d
100
- shape : ToShape2d | None = None ,
101
- dtype : ToDType [_SCT0 ] | None = None ,
87
+ shape : ToShape2D | None = None ,
88
+ dtype : onp . ToDType [_SCT0 ] | None = None ,
102
89
copy : bool = False ,
103
90
* ,
104
91
maxprint : int | None = None ,
@@ -108,8 +95,8 @@ class _cs_matrix(
108
95
self ,
109
96
/ ,
110
97
arg1 : _ToMatrix [_SCT ] | _ToData [_SCT ],
111
- shape : ToShape1dNd | None = None ,
112
- dtype : ToDType [_SCT ] | None = None ,
98
+ shape : ToShapeMin1D | None = None ,
99
+ dtype : onp . ToDType [_SCT ] | None = None ,
113
100
copy : bool = False ,
114
101
* ,
115
102
maxprint : int | None = None ,
@@ -118,9 +105,9 @@ class _cs_matrix(
118
105
def __init__ (
119
106
self : _cs_matrix [np .float64 , tuple [int ]],
120
107
/ ,
121
- arg1 : ToShape1d ,
122
- shape : ToShape1d | None = None ,
123
- dtype : ToDTypeFloat | None = None ,
108
+ arg1 : ToShape1D ,
109
+ shape : ToShape1D | None = None ,
110
+ dtype : onp . AnyFloat64DType | None = None ,
124
111
copy : bool = False ,
125
112
* ,
126
113
maxprint : int | None = None ,
@@ -129,9 +116,9 @@ class _cs_matrix(
129
116
def __init__ (
130
117
self : _cs_matrix [np .float64 , tuple [int , int ]],
131
118
/ ,
132
- arg1 : ToShape2d ,
133
- shape : ToShape2d | None = None ,
134
- dtype : ToDTypeFloat | None = None ,
119
+ arg1 : ToShape2D ,
120
+ shape : ToShape2D | None = None ,
121
+ dtype : onp . AnyFloat64DType | None = None ,
135
122
copy : bool = False ,
136
123
* ,
137
124
maxprint : int | None = None ,
@@ -141,8 +128,8 @@ class _cs_matrix(
141
128
self : _cs_matrix [np .bool_ , tuple [int ]],
142
129
/ ,
143
130
arg1 : Sequence [bool ],
144
- shape : ToShape1d | None = None ,
145
- dtype : ToDTypeBool | None = None ,
131
+ shape : ToShape1D | None = None ,
132
+ dtype : onp . AnyBoolDType | None = None ,
146
133
copy : bool = False ,
147
134
* ,
148
135
maxprint : int | None = None ,
@@ -152,8 +139,8 @@ class _cs_matrix(
152
139
self : _cs_matrix [np .bool_ , tuple [int , int ]],
153
140
/ ,
154
141
arg1 : Sequence [Sequence [bool ]],
155
- shape : ToShape2d | None = None ,
156
- dtype : ToDTypeBool | None = None ,
142
+ shape : ToShape2D | None = None ,
143
+ dtype : onp . AnyBoolDType | None = None ,
157
144
copy : bool = False ,
158
145
* ,
159
146
maxprint : int | None = None ,
@@ -163,8 +150,8 @@ class _cs_matrix(
163
150
self : _cs_matrix [np .int_ , tuple [int ]],
164
151
/ ,
165
152
arg1 : Sequence [op .JustInt ],
166
- shape : ToShape1dNd | None = None ,
167
- dtype : ToDTypeInt | None = None ,
153
+ shape : ToShapeMin1D | None = None ,
154
+ dtype : onp . AnyIntDType | None = None ,
168
155
copy : bool = False ,
169
156
* ,
170
157
maxprint : int | None = None ,
@@ -174,8 +161,8 @@ class _cs_matrix(
174
161
self : _cs_matrix [np .int_ , tuple [int , int ]],
175
162
/ ,
176
163
arg1 : Sequence [Sequence [op .JustInt ]],
177
- shape : ToShape1dNd | None = None ,
178
- dtype : ToDTypeInt | None = None ,
164
+ shape : ToShapeMin1D | None = None ,
165
+ dtype : onp . AnyIntDType | None = None ,
179
166
copy : bool = False ,
180
167
* ,
181
168
maxprint : int | None = None ,
@@ -185,8 +172,8 @@ class _cs_matrix(
185
172
self : _cs_matrix [np .float64 , tuple [int ]],
186
173
/ ,
187
174
arg1 : Sequence [op .JustFloat ],
188
- shape : ToShape1dNd | None = None ,
189
- dtype : ToDTypeFloat | None = None ,
175
+ shape : ToShapeMin1D | None = None ,
176
+ dtype : onp . AnyFloat64DType | None = None ,
190
177
copy : bool = False ,
191
178
* ,
192
179
maxprint : int | None = None ,
@@ -196,8 +183,8 @@ class _cs_matrix(
196
183
self : _cs_matrix [np .float64 , tuple [int , int ]],
197
184
/ ,
198
185
arg1 : Sequence [Sequence [op .JustFloat ]],
199
- shape : ToShape1dNd | None = None ,
200
- dtype : ToDTypeFloat | None = None ,
186
+ shape : ToShapeMin1D | None = None ,
187
+ dtype : onp . AnyFloat64DType | None = None ,
201
188
copy : bool = False ,
202
189
* ,
203
190
maxprint : int | None = None ,
@@ -207,8 +194,8 @@ class _cs_matrix(
207
194
self : _cs_matrix [np .complex128 , tuple [int ]],
208
195
/ ,
209
196
arg1 : Sequence [op .JustComplex ],
210
- shape : ToShape1dNd | None = None ,
211
- dtype : ToDTypeComplex | None = None ,
197
+ shape : ToShapeMin1D | None = None ,
198
+ dtype : onp . AnyComplex128DType | None = None ,
212
199
copy : bool = False ,
213
200
* ,
214
201
maxprint : int | None = None ,
@@ -218,8 +205,8 @@ class _cs_matrix(
218
205
self : _cs_matrix [np .complex128 , tuple [int , int ]],
219
206
/ ,
220
207
arg1 : Sequence [Sequence [op .JustComplex ]],
221
- shape : ToShape1dNd | None = None ,
222
- dtype : ToDTypeComplex | None = None ,
208
+ shape : ToShapeMin1D | None = None ,
209
+ dtype : onp . AnyComplex128DType | None = None ,
223
210
copy : bool = False ,
224
211
* ,
225
212
maxprint : int | None = None ,
@@ -229,8 +216,8 @@ class _cs_matrix(
229
216
self : _cs_matrix [_SCT0 , tuple [int ]],
230
217
/ ,
231
218
arg1 : onp .ToComplexStrict1D ,
232
- shape : ToShape1d | None ,
233
- dtype : ToDType [_SCT0 ],
219
+ shape : ToShape1D | None ,
220
+ dtype : onp . ToDType [_SCT0 ],
234
221
copy : bool = False ,
235
222
* ,
236
223
maxprint : int | None = None ,
@@ -240,9 +227,9 @@ class _cs_matrix(
240
227
self : _cs_matrix [_SCT0 , tuple [int ]],
241
228
/ ,
242
229
arg1 : onp .ToComplexStrict1D ,
243
- shape : ToShape1d | None = None ,
230
+ shape : ToShape1D | None = None ,
244
231
* ,
245
- dtype : ToDType [_SCT0 ],
232
+ dtype : onp . ToDType [_SCT0 ],
246
233
copy : bool = False ,
247
234
maxprint : int | None = None ,
248
235
) -> None : ...
@@ -251,8 +238,8 @@ class _cs_matrix(
251
238
self : _cs_matrix [_SCT0 , tuple [int , int ]],
252
239
/ ,
253
240
arg1 : onp .ToComplexStrict2D ,
254
- shape : ToShape2d | None ,
255
- dtype : ToDType [_SCT0 ],
241
+ shape : ToShape2D | None ,
242
+ dtype : onp . ToDType [_SCT0 ],
256
243
copy : bool = False ,
257
244
* ,
258
245
maxprint : int | None = None ,
@@ -262,9 +249,9 @@ class _cs_matrix(
262
249
self : _cs_matrix [_SCT0 , tuple [int , int ]],
263
250
/ ,
264
251
arg1 : onp .ToComplexStrict2D ,
265
- shape : ToShape2d | None = None ,
252
+ shape : ToShape2D | None = None ,
266
253
* ,
267
- dtype : ToDType [_SCT0 ],
254
+ dtype : onp . ToDType [_SCT0 ],
268
255
copy : bool = False ,
269
256
maxprint : int | None = None ,
270
257
) -> None : ...
@@ -273,7 +260,7 @@ class _cs_matrix(
273
260
self ,
274
261
/ ,
275
262
arg1 : onp .ToComplex1D | onp .ToComplex2D ,
276
- shape : ToShape1dNd | None = None ,
263
+ shape : ToShapeMin1D | None = None ,
277
264
dtype : npt .DTypeLike | None = ...,
278
265
copy : bool = False ,
279
266
* ,
0 commit comments