polynomial.pyi
1 from typing import ( 2 Literal as L, 3 overload, 4 Any, 5 SupportsInt, 6 SupportsIndex, 7 TypeVar, 8 NoReturn, 9 ) 10 11 from numpy import ( 12 RankWarning as RankWarning, 13 poly1d as poly1d, 14 unsignedinteger, 15 signedinteger, 16 floating, 17 complexfloating, 18 bool_, 19 int32, 20 int64, 21 float64, 22 complex128, 23 object_, 24 ) 25 26 from numpy._typing import ( 27 NDArray, 28 ArrayLike, 29 _ArrayLikeBool_co, 30 _ArrayLikeUInt_co, 31 _ArrayLikeInt_co, 32 _ArrayLikeFloat_co, 33 _ArrayLikeComplex_co, 34 _ArrayLikeObject_co, 35 ) 36 37 _T = TypeVar("_T") 38 39 _2Tup = tuple[_T, _T] 40 _5Tup = tuple[ 41 _T, 42 NDArray[float64], 43 NDArray[int32], 44 NDArray[float64], 45 NDArray[float64], 46 ] 47 48 __all__: list[str] 49 50 def poly(seq_of_zeros: ArrayLike) -> NDArray[floating[Any]]: ... 51 52 # Returns either a float or complex array depending on the input values. 53 # See `np.linalg.eigvals`. 54 def roots(p: ArrayLike) -> NDArray[complexfloating[Any, Any]] | NDArray[floating[Any]]: ... 55 56 @overload 57 def polyint( 58 p: poly1d, 59 m: SupportsInt | SupportsIndex = ..., 60 k: None | _ArrayLikeComplex_co | _ArrayLikeObject_co = ..., 61 ) -> poly1d: ... 62 @overload 63 def polyint( 64 p: _ArrayLikeFloat_co, 65 m: SupportsInt | SupportsIndex = ..., 66 k: None | _ArrayLikeFloat_co = ..., 67 ) -> NDArray[floating[Any]]: ... 68 @overload 69 def polyint( 70 p: _ArrayLikeComplex_co, 71 m: SupportsInt | SupportsIndex = ..., 72 k: None | _ArrayLikeComplex_co = ..., 73 ) -> NDArray[complexfloating[Any, Any]]: ... 74 @overload 75 def polyint( 76 p: _ArrayLikeObject_co, 77 m: SupportsInt | SupportsIndex = ..., 78 k: None | _ArrayLikeObject_co = ..., 79 ) -> NDArray[object_]: ... 80 81 @overload 82 def polyder( 83 p: poly1d, 84 m: SupportsInt | SupportsIndex = ..., 85 ) -> poly1d: ... 86 @overload 87 def polyder( 88 p: _ArrayLikeFloat_co, 89 m: SupportsInt | SupportsIndex = ..., 90 ) -> NDArray[floating[Any]]: ... 91 @overload 92 def polyder( 93 p: _ArrayLikeComplex_co, 94 m: SupportsInt | SupportsIndex = ..., 95 ) -> NDArray[complexfloating[Any, Any]]: ... 96 @overload 97 def polyder( 98 p: _ArrayLikeObject_co, 99 m: SupportsInt | SupportsIndex = ..., 100 ) -> NDArray[object_]: ... 101 102 @overload 103 def polyfit( 104 x: _ArrayLikeFloat_co, 105 y: _ArrayLikeFloat_co, 106 deg: SupportsIndex | SupportsInt, 107 rcond: None | float = ..., 108 full: L[False] = ..., 109 w: None | _ArrayLikeFloat_co = ..., 110 cov: L[False] = ..., 111 ) -> NDArray[float64]: ... 112 @overload 113 def polyfit( 114 x: _ArrayLikeComplex_co, 115 y: _ArrayLikeComplex_co, 116 deg: SupportsIndex | SupportsInt, 117 rcond: None | float = ..., 118 full: L[False] = ..., 119 w: None | _ArrayLikeFloat_co = ..., 120 cov: L[False] = ..., 121 ) -> NDArray[complex128]: ... 122 @overload 123 def polyfit( 124 x: _ArrayLikeFloat_co, 125 y: _ArrayLikeFloat_co, 126 deg: SupportsIndex | SupportsInt, 127 rcond: None | float = ..., 128 full: L[False] = ..., 129 w: None | _ArrayLikeFloat_co = ..., 130 cov: L[True, "unscaled"] = ..., 131 ) -> _2Tup[NDArray[float64]]: ... 132 @overload 133 def polyfit( 134 x: _ArrayLikeComplex_co, 135 y: _ArrayLikeComplex_co, 136 deg: SupportsIndex | SupportsInt, 137 rcond: None | float = ..., 138 full: L[False] = ..., 139 w: None | _ArrayLikeFloat_co = ..., 140 cov: L[True, "unscaled"] = ..., 141 ) -> _2Tup[NDArray[complex128]]: ... 142 @overload 143 def polyfit( 144 x: _ArrayLikeFloat_co, 145 y: _ArrayLikeFloat_co, 146 deg: SupportsIndex | SupportsInt, 147 rcond: None | float = ..., 148 full: L[True] = ..., 149 w: None | _ArrayLikeFloat_co = ..., 150 cov: bool | L["unscaled"] = ..., 151 ) -> _5Tup[NDArray[float64]]: ... 152 @overload 153 def polyfit( 154 x: _ArrayLikeComplex_co, 155 y: _ArrayLikeComplex_co, 156 deg: SupportsIndex | SupportsInt, 157 rcond: None | float = ..., 158 full: L[True] = ..., 159 w: None | _ArrayLikeFloat_co = ..., 160 cov: bool | L["unscaled"] = ..., 161 ) -> _5Tup[NDArray[complex128]]: ... 162 163 @overload 164 def polyval( 165 p: _ArrayLikeBool_co, 166 x: _ArrayLikeBool_co, 167 ) -> NDArray[int64]: ... 168 @overload 169 def polyval( 170 p: _ArrayLikeUInt_co, 171 x: _ArrayLikeUInt_co, 172 ) -> NDArray[unsignedinteger[Any]]: ... 173 @overload 174 def polyval( 175 p: _ArrayLikeInt_co, 176 x: _ArrayLikeInt_co, 177 ) -> NDArray[signedinteger[Any]]: ... 178 @overload 179 def polyval( 180 p: _ArrayLikeFloat_co, 181 x: _ArrayLikeFloat_co, 182 ) -> NDArray[floating[Any]]: ... 183 @overload 184 def polyval( 185 p: _ArrayLikeComplex_co, 186 x: _ArrayLikeComplex_co, 187 ) -> NDArray[complexfloating[Any, Any]]: ... 188 @overload 189 def polyval( 190 p: _ArrayLikeObject_co, 191 x: _ArrayLikeObject_co, 192 ) -> NDArray[object_]: ... 193 194 @overload 195 def polyadd( 196 a1: poly1d, 197 a2: _ArrayLikeComplex_co | _ArrayLikeObject_co, 198 ) -> poly1d: ... 199 @overload 200 def polyadd( 201 a1: _ArrayLikeComplex_co | _ArrayLikeObject_co, 202 a2: poly1d, 203 ) -> poly1d: ... 204 @overload 205 def polyadd( 206 a1: _ArrayLikeBool_co, 207 a2: _ArrayLikeBool_co, 208 ) -> NDArray[bool_]: ... 209 @overload 210 def polyadd( 211 a1: _ArrayLikeUInt_co, 212 a2: _ArrayLikeUInt_co, 213 ) -> NDArray[unsignedinteger[Any]]: ... 214 @overload 215 def polyadd( 216 a1: _ArrayLikeInt_co, 217 a2: _ArrayLikeInt_co, 218 ) -> NDArray[signedinteger[Any]]: ... 219 @overload 220 def polyadd( 221 a1: _ArrayLikeFloat_co, 222 a2: _ArrayLikeFloat_co, 223 ) -> NDArray[floating[Any]]: ... 224 @overload 225 def polyadd( 226 a1: _ArrayLikeComplex_co, 227 a2: _ArrayLikeComplex_co, 228 ) -> NDArray[complexfloating[Any, Any]]: ... 229 @overload 230 def polyadd( 231 a1: _ArrayLikeObject_co, 232 a2: _ArrayLikeObject_co, 233 ) -> NDArray[object_]: ... 234 235 @overload 236 def polysub( 237 a1: poly1d, 238 a2: _ArrayLikeComplex_co | _ArrayLikeObject_co, 239 ) -> poly1d: ... 240 @overload 241 def polysub( 242 a1: _ArrayLikeComplex_co | _ArrayLikeObject_co, 243 a2: poly1d, 244 ) -> poly1d: ... 245 @overload 246 def polysub( 247 a1: _ArrayLikeBool_co, 248 a2: _ArrayLikeBool_co, 249 ) -> NoReturn: ... 250 @overload 251 def polysub( 252 a1: _ArrayLikeUInt_co, 253 a2: _ArrayLikeUInt_co, 254 ) -> NDArray[unsignedinteger[Any]]: ... 255 @overload 256 def polysub( 257 a1: _ArrayLikeInt_co, 258 a2: _ArrayLikeInt_co, 259 ) -> NDArray[signedinteger[Any]]: ... 260 @overload 261 def polysub( 262 a1: _ArrayLikeFloat_co, 263 a2: _ArrayLikeFloat_co, 264 ) -> NDArray[floating[Any]]: ... 265 @overload 266 def polysub( 267 a1: _ArrayLikeComplex_co, 268 a2: _ArrayLikeComplex_co, 269 ) -> NDArray[complexfloating[Any, Any]]: ... 270 @overload 271 def polysub( 272 a1: _ArrayLikeObject_co, 273 a2: _ArrayLikeObject_co, 274 ) -> NDArray[object_]: ... 275 276 # NOTE: Not an alias, but they do have the same signature (that we can reuse) 277 polymul = polyadd 278 279 @overload 280 def polydiv( 281 u: poly1d, 282 v: _ArrayLikeComplex_co | _ArrayLikeObject_co, 283 ) -> _2Tup[poly1d]: ... 284 @overload 285 def polydiv( 286 u: _ArrayLikeComplex_co | _ArrayLikeObject_co, 287 v: poly1d, 288 ) -> _2Tup[poly1d]: ... 289 @overload 290 def polydiv( 291 u: _ArrayLikeFloat_co, 292 v: _ArrayLikeFloat_co, 293 ) -> _2Tup[NDArray[floating[Any]]]: ... 294 @overload 295 def polydiv( 296 u: _ArrayLikeComplex_co, 297 v: _ArrayLikeComplex_co, 298 ) -> _2Tup[NDArray[complexfloating[Any, Any]]]: ... 299 @overload 300 def polydiv( 301 u: _ArrayLikeObject_co, 302 v: _ArrayLikeObject_co, 303 ) -> _2Tup[NDArray[Any]]: ...