polynomial.pyi 6.8 KB

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