1
+ import abc
1
2
import sys
2
3
from collections .abc import Iterator , Mapping , Sequence
3
4
from typing import (
@@ -15,18 +16,24 @@ from typing import (
15
16
16
17
import numpy as np
17
18
import numpy .typing as npt
18
- from numpy ._typing import _ArrayLikeInt_co
19
19
20
8000
td>20
from ._polytypes import (
21
- _AnyInt ,
21
+ _AnyComplexSeries1D ,
22
+ _AnyIntArg ,
22
23
_AnyComplexScalar ,
23
24
_AnyComplexSeriesND ,
25
+ _AnyIntSeries1D ,
26
+ _AnyObjectSeries1D ,
24
27
_AnyObjectSeriesND ,
28
+ _AnyRealScalar ,
29
+ _AnyRealSeries1D ,
25
30
_AnyScalar ,
26
31
_AnySeries1D ,
27
32
_AnySeriesND ,
33
+ _Array1D ,
28
34
_Array2 ,
29
35
_CoefArray1D ,
36
+ _ComplexArrayND ,
30
37
_SupportsLenAndGetItem ,
31
38
_Tuple2 ,
32
39
)
@@ -43,12 +50,11 @@ __all__ = ["ABCPolyBase"]
43
50
44
51
_NameCo = TypeVar ("_NameCo" , bound = None | LiteralString , covariant = True )
45
52
_Self = TypeVar ("_Self" , bound = "ABCPolyBase" )
46
- _Size = TypeVar ("_Size" , bound = int )
47
53
48
54
_AnyOther : TypeAlias = ABCPolyBase | _AnyScalar | _AnySeries1D
49
55
_Hundred : TypeAlias = Literal [100 ]
50
56
51
- class ABCPolyBase (Generic [_NameCo ]):
57
+ class ABCPolyBase (Generic [_NameCo ], metaclass = abc . ABCMeta ):
52
58
__hash__ : ClassVar [None ] # type: ignore[assignment]
53
59
__array_ufunc__ : ClassVar [None ]
54
60
@@ -67,8 +73,7 @@ class ABCPolyBase(Generic[_NameCo]):
67
73
def symbol (self , / ) -> LiteralString : ...
68
74
69
75
def __init__ (
70
- self ,
71
- / ,
76
+ self , / ,
72
77
coef : _AnySeries1D ,
73
78
domain : None | _AnySeries1D = ...,
74
79
window : None | _AnySeries1D = ...,
@@ -132,35 +137,35 @@ class ABCPolyBase(Generic[_NameCo]):
132
137
def has_samecoef (self , / , other : ABCPolyBase ) -> bool : ...
133
138
def has_samedomain (self , / , other : ABCPolyBase ) -> bool : ...
134
139
def has_samewindow (self , / , other : ABCPolyBase ) -> bool : ...
135
- def has_sametype (self : _Self , / , other : object ) -> TypeGuard [_Self ]: ...
140
+ @overload
141
+ def has_sametype (self : _Self , / , other : ABCPolyBase ) -> TypeGuard [_Self ]: ...
142
+ @overload
143
+ def has_sametype (self , / , other : object ) -> Literal [False ]: ...
136
144
137
145
def copy (self : _Self , / ) -> _Self : ...
138
146
def degree (self , / ) -> int : ...
139
147
def cutdeg (self : _Self , / ) -> _Self : ...
140
- def trim (self : _Self , / , tol : float = ...) -> _Self : ...
141
- def truncate (self : _Self , / , size : _AnyInt ) -> _Self : ...
148
+ def trim (self : _Self , / , tol : _AnyRealScalar = ...) -> _Self : ...
149
+ def truncate (self : _Self , / , size : _AnyIntArg ) -> _Self : ...
142
150
143
151
@overload
144
152
def convert (
145
153
self ,
146
154
domain : None | _AnySeries1D ,
147
- kind : type [_Self ],
148
- / ,
155
+ kind : type [_Self ], / ,
149
156
window : None | _AnySeries1D = ...,
150
157
) -> _Self : ...
151
158
@overload
152
159
def convert (
153
- self ,
154
- / ,
160
+ self , / ,
155
161
domain : None | _AnySeries1D = ...,
156
162
* ,
157
163
kind : type [_Self ],
158
164
window : None | _AnySeries1D = ...,
159
165
) -> _Self : ...
160
166
@overload
161
167
def convert (
162
- self : _Self ,
163
- / ,
168
+ self : _Self , / ,
164
169
domain : None | _AnySeries1D = ...,
165
170
kind : type [_Self ] = ...,
166
171
window : None | _AnySeries1D = ...,
@@ -169,8 +174,7 @@ class ABCPolyBase(Generic[_NameCo]):
169
174
def mapparms (self , / ) -> _Tuple2 [Any ]: ...
170
175
171
176
def integ (
172
- self : _Self ,
173
- / ,
177
+ self : _Self , / ,
174
178
m : SupportsIndex = ...,
175
179
k : _AnyComplexScalar | _SupportsLenAndGetItem [_AnyComplexScalar ] = ...,
176
180
lbnd : None | _AnyComplexScalar = ...,
@@ -180,37 +184,21 @@ class ABCPolyBase(Generic[_NameCo]):
180
184
181
185
def roots (self , / ) -> _CoefArray1D : ...
182
186
183
- @overload
184
187
def linspace (
185
- self ,
186
- / ,
187
- n : _Size ,
188
- domain : None | _AnySeries1D = ...,
189
- ) -> tuple [
190
- np .ndarray [tuple [_Size ], np .dtype [np .float64 ]],
191
- np .ndarray [tuple [_Size ], np .dtype [np .float64 | np .complex128 ]],
192
- ]: ...
193
- @overload
194
- def linspace (
195
- self ,
196
- / ,
197
- n : _Hundred = ...,
188
+ self , / ,
189
+ n : SupportsIndex = ...,
198
190
domain : None | _AnySeries1D = ...,
199
- ) -> tuple [
200
- np .ndarray [tuple [_Hundred ], np .dtype [np .float64 ]],
201
- np .ndarray [tuple [_Hundred ], np .dtype [np .float64 | np .complex128 ]],
202
- ]: ...
191
+ ) -> _Tuple2 [_Array1D [np .float64 | np .complex128 ]]: ...
203
192
204
193
@overload
205
194
@classmethod
206
195
def fit (
207
- cls : type [_Self ],
208
- / ,
196
+ cls : type [_Self ], / ,
209
197
x : _AnySeries1D ,
210
198
y : _AnySeries1D ,
211
- deg : _ArrayLikeInt_co ,
199
+ deg : int | _AnyIntSeries1D ,
212
200
domain : None | _AnySeries1D = ...,
213
- rcond : float = ...,
201
+ rcond : _AnyRealScalar = ...,
214
202
full : Literal [False ] = ...,
215
203
w : None | _AnySeries1D = ...,
216
204
window : None | _AnySeries1D = ...,
@@ -222,9 +210,9 @@ class ABCPolyBase(Generic[_NameCo]):
222
210
cls : type [_Self ], / ,
223
211
x : _AnySeries1D ,
224
212
y : _AnySeries1D ,
225
- deg : _ArrayLikeInt_co ,
213
+ deg : int | _AnyIntSeries1D ,
226
214
domain : None | _AnySeries1D = ...,
227
- rcond : float = ...,
215
+ rcond : _AnyRealScalar = ...,
228
216
* ,
229
217
full : Literal [True ],
230
218
w : None | _AnySeries1D = ...,
@@ -237,46 +225,44 @@ class ABCPolyBase(Generic[_NameCo]):
237
225
cls : type [_Self ],
238
226
x : _AnySeries1D ,
239
227
y : _AnySeries1D ,
240
- deg : _ArrayLikeInt_co ,
228
+ deg : int | _AnyIntSeries1D ,
241
229
domain : None | _AnySeries1D ,
242
- rcond : float ,
243
- full : Literal [True ],
244
- / ,
230
+ rcond : _AnyRealScalar ,
231
+ full : Literal [True ], / ,
245
232
w : None | _AnySeries1D = ...,
246
233
window : None | _AnySeries1D = ...,
247
234
symbol : str = ...,
248
235
) -> tuple [_Self , Sequence [np .inexact [Any ] | np .int32 ]]: ...
249
236
250
237
@classmethod
251
238
def fromroots (
252
- cls : type [_Self ],
253
- / ,
239
+ cls : type [_Self ], / ,
254
240
roots : _AnySeriesND ,
255
241
domain : None | _AnySeries1D = ...,
256
242
window : None | _AnySeries1D = ...,
243
+ symbol : str = ...,
257
244
) -> _Self : ...
258
245
259
246
@classmethod
260
247
def identity (
261
- cls : type [_Self ],
262
- / ,
248
+ cls : type [_Self ], / ,
263
249
domain : None | _AnySeries1D = ...,
264
250
window : None | _AnySeries1D = ...,
251
+ symbol : str = ...,
265
252
) -> _Self : ...
266
253
267
254
@classmethod
268
255
def basis (
269
- cls : type [_Self ],
270
- / ,
271
- deg : int ,
256
+ cls : type [_Self ], / ,
257
+ deg : _AnyIntArg ,
272
258
domain : None | _AnySeries1D = ...,
273
259
window : None | _AnySeries1D = ...,
260
+ symbol : str = ...,
274
261
) -> _Self : ...
275
262
276
263
@classmethod
277
264
def cast (
278
- cls : type [_Self ],
279
- / ,
265
+ cls : type [_Self ], / ,
280
266
series : ABCPolyBase ,
281
267
domain : None | _AnySeries1D = ...,
282
268
window : None | _AnySeries1D = ...,
0 commit comments