_polybase.pyi 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. import abc
  2. import decimal
  3. import numbers
  4. from collections.abc import Iterator, Mapping, Sequence
  5. from typing import (
  6. Any,
  7. ClassVar,
  8. Generic,
  9. Literal,
  10. LiteralString,
  11. Self,
  12. SupportsIndex,
  13. TypeAlias,
  14. overload,
  15. )
  16. from typing_extensions import TypeIs, TypeVar
  17. import numpy as np
  18. import numpy.typing as npt
  19. from numpy._typing import (
  20. _ArrayLikeComplex_co,
  21. _ArrayLikeFloat_co,
  22. _FloatLike_co,
  23. _NumberLike_co,
  24. )
  25. from ._polytypes import (
  26. _AnyInt,
  27. _Array2,
  28. _ArrayLikeCoef_co,
  29. _ArrayLikeCoefObject_co,
  30. _CoefLike_co,
  31. _CoefSeries,
  32. _Series,
  33. _SeriesLikeCoef_co,
  34. _SeriesLikeInt_co,
  35. _Tuple2,
  36. )
  37. __all__ = ["ABCPolyBase"]
  38. _NameCo = TypeVar(
  39. "_NameCo",
  40. bound=LiteralString | None,
  41. covariant=True,
  42. default=LiteralString | None
  43. )
  44. _Other = TypeVar("_Other", bound=ABCPolyBase)
  45. _AnyOther: TypeAlias = ABCPolyBase | _CoefLike_co | _SeriesLikeCoef_co
  46. _Hundred: TypeAlias = Literal[100]
  47. class ABCPolyBase(Generic[_NameCo], abc.ABC):
  48. __hash__: ClassVar[None] # type: ignore[assignment] # pyright: ignore[reportIncompatibleMethodOverride]
  49. __array_ufunc__: ClassVar[None]
  50. maxpower: ClassVar[_Hundred]
  51. _superscript_mapping: ClassVar[Mapping[int, str]]
  52. _subscript_mapping: ClassVar[Mapping[int, str]]
  53. _use_unicode: ClassVar[bool]
  54. basis_name: _NameCo
  55. coef: _CoefSeries
  56. domain: _Array2[np.inexact | np.object_]
  57. window: _Array2[np.inexact | np.object_]
  58. _symbol: LiteralString
  59. @property
  60. def symbol(self, /) -> LiteralString: ...
  61. def __init__(
  62. self,
  63. /,
  64. coef: _SeriesLikeCoef_co,
  65. domain: _SeriesLikeCoef_co | None = ...,
  66. window: _SeriesLikeCoef_co | None = ...,
  67. symbol: str = ...,
  68. ) -> None: ...
  69. @overload
  70. def __call__(self, /, arg: _Other) -> _Other: ...
  71. # TODO: Once `_ShapeT@ndarray` is covariant and bounded (see #26081),
  72. # additionally include 0-d arrays as input types with scalar return type.
  73. @overload
  74. def __call__(
  75. self,
  76. /,
  77. arg: _FloatLike_co | decimal.Decimal | numbers.Real | np.object_,
  78. ) -> np.float64 | np.complex128: ...
  79. @overload
  80. def __call__(
  81. self,
  82. /,
  83. arg: _NumberLike_co | numbers.Complex,
  84. ) -> np.complex128: ...
  85. @overload
  86. def __call__(self, /, arg: _ArrayLikeFloat_co) -> (
  87. npt.NDArray[np.float64]
  88. | npt.NDArray[np.complex128]
  89. | npt.NDArray[np.object_]
  90. ): ...
  91. @overload
  92. def __call__(
  93. self,
  94. /,
  95. arg: _ArrayLikeComplex_co,
  96. ) -> npt.NDArray[np.complex128] | npt.NDArray[np.object_]: ...
  97. @overload
  98. def __call__(
  99. self,
  100. /,
  101. arg: _ArrayLikeCoefObject_co,
  102. ) -> npt.NDArray[np.object_]: ...
  103. def __format__(self, fmt_str: str, /) -> str: ...
  104. def __eq__(self, x: object, /) -> bool: ...
  105. def __ne__(self, x: object, /) -> bool: ...
  106. def __neg__(self, /) -> Self: ...
  107. def __pos__(self, /) -> Self: ...
  108. def __add__(self, x: _AnyOther, /) -> Self: ...
  109. def __sub__(self, x: _AnyOther, /) -> Self: ...
  110. def __mul__(self, x: _AnyOther, /) -> Self: ...
  111. def __truediv__(self, x: _AnyOther, /) -> Self: ...
  112. def __floordiv__(self, x: _AnyOther, /) -> Self: ...
  113. def __mod__(self, x: _AnyOther, /) -> Self: ...
  114. def __divmod__(self, x: _AnyOther, /) -> _Tuple2[Self]: ...
  115. def __pow__(self, x: _AnyOther, /) -> Self: ...
  116. def __radd__(self, x: _AnyOther, /) -> Self: ...
  117. def __rsub__(self, x: _AnyOther, /) -> Self: ...
  118. def __rmul__(self, x: _AnyOther, /) -> Self: ...
  119. def __rtruediv__(self, x: _AnyOther, /) -> Self: ...
  120. def __rfloordiv__(self, x: _AnyOther, /) -> Self: ...
  121. def __rmod__(self, x: _AnyOther, /) -> Self: ...
  122. def __rdivmod__(self, x: _AnyOther, /) -> _Tuple2[Self]: ...
  123. def __len__(self, /) -> int: ...
  124. def __iter__(self, /) -> Iterator[np.inexact | object]: ...
  125. def __getstate__(self, /) -> dict[str, Any]: ...
  126. def __setstate__(self, dict: dict[str, Any], /) -> None: ...
  127. def has_samecoef(self, /, other: ABCPolyBase) -> bool: ...
  128. def has_samedomain(self, /, other: ABCPolyBase) -> bool: ...
  129. def has_samewindow(self, /, other: ABCPolyBase) -> bool: ...
  130. @overload
  131. def has_sametype(self, /, other: ABCPolyBase) -> TypeIs[Self]: ...
  132. @overload
  133. def has_sametype(self, /, other: object) -> Literal[False]: ...
  134. def copy(self, /) -> Self: ...
  135. def degree(self, /) -> int: ...
  136. def cutdeg(self, /) -> Self: ...
  137. def trim(self, /, tol: _FloatLike_co = ...) -> Self: ...
  138. def truncate(self, /, size: _AnyInt) -> Self: ...
  139. @overload
  140. def convert(
  141. self,
  142. /,
  143. domain: _SeriesLikeCoef_co | None,
  144. kind: type[_Other],
  145. window: _SeriesLikeCoef_co | None = ...,
  146. ) -> _Other: ...
  147. @overload
  148. def convert(
  149. self,
  150. /,
  151. domain: _SeriesLikeCoef_co | None = ...,
  152. *,
  153. kind: type[_Other],
  154. window: _SeriesLikeCoef_co | None = ...,
  155. ) -> _Other: ...
  156. @overload
  157. def convert(
  158. self,
  159. /,
  160. domain: _SeriesLikeCoef_co | None = ...,
  161. kind: None = None,
  162. window: _SeriesLikeCoef_co | None = ...,
  163. ) -> Self: ...
  164. def mapparms(self, /) -> _Tuple2[Any]: ...
  165. def integ(
  166. self,
  167. /,
  168. m: SupportsIndex = ...,
  169. k: _CoefLike_co | _SeriesLikeCoef_co = ...,
  170. lbnd: _CoefLike_co | None = ...,
  171. ) -> Self: ...
  172. def deriv(self, /, m: SupportsIndex = ...) -> Self: ...
  173. def roots(self, /) -> _CoefSeries: ...
  174. def linspace(
  175. self,
  176. /,
  177. n: SupportsIndex = ...,
  178. domain: _SeriesLikeCoef_co | None = ...,
  179. ) -> _Tuple2[_Series[np.float64 | np.complex128]]: ...
  180. @overload
  181. @classmethod
  182. def fit(
  183. cls,
  184. x: _SeriesLikeCoef_co,
  185. y: _SeriesLikeCoef_co,
  186. deg: int | _SeriesLikeInt_co,
  187. domain: _SeriesLikeCoef_co | None = ...,
  188. rcond: _FloatLike_co = ...,
  189. full: Literal[False] = ...,
  190. w: _SeriesLikeCoef_co | None = ...,
  191. window: _SeriesLikeCoef_co | None = ...,
  192. symbol: str = ...,
  193. ) -> Self: ...
  194. @overload
  195. @classmethod
  196. def fit(
  197. cls,
  198. x: _SeriesLikeCoef_co,
  199. y: _SeriesLikeCoef_co,
  200. deg: int | _SeriesLikeInt_co,
  201. domain: _SeriesLikeCoef_co | None = ...,
  202. rcond: _FloatLike_co = ...,
  203. *,
  204. full: Literal[True],
  205. w: _SeriesLikeCoef_co | None = ...,
  206. window: _SeriesLikeCoef_co | None = ...,
  207. symbol: str = ...,
  208. ) -> tuple[Self, Sequence[np.inexact | np.int32]]: ...
  209. @overload
  210. @classmethod
  211. def fit(
  212. cls,
  213. x: _SeriesLikeCoef_co,
  214. y: _SeriesLikeCoef_co,
  215. deg: int | _SeriesLikeInt_co,
  216. domain: _SeriesLikeCoef_co | None,
  217. rcond: _FloatLike_co,
  218. full: Literal[True], /,
  219. w: _SeriesLikeCoef_co | None = ...,
  220. window: _SeriesLikeCoef_co | None = ...,
  221. symbol: str = ...,
  222. ) -> tuple[Self, Sequence[np.inexact | np.int32]]: ...
  223. @classmethod
  224. def fromroots(
  225. cls,
  226. roots: _ArrayLikeCoef_co,
  227. domain: _SeriesLikeCoef_co | None = ...,
  228. window: _SeriesLikeCoef_co | None = ...,
  229. symbol: str = ...,
  230. ) -> Self: ...
  231. @classmethod
  232. def identity(
  233. cls,
  234. domain: _SeriesLikeCoef_co | None = ...,
  235. window: _SeriesLikeCoef_co | None = ...,
  236. symbol: str = ...,
  237. ) -> Self: ...
  238. @classmethod
  239. def basis(
  240. cls,
  241. deg: _AnyInt,
  242. domain: _SeriesLikeCoef_co | None = ...,
  243. window: _SeriesLikeCoef_co | None = ...,
  244. symbol: str = ...,
  245. ) -> Self: ...
  246. @classmethod
  247. def cast(
  248. cls,
  249. series: ABCPolyBase,
  250. domain: _SeriesLikeCoef_co | None = ...,
  251. window: _SeriesLikeCoef_co | None = ...,
  252. ) -> Self: ...
  253. @classmethod
  254. def _str_term_unicode(cls, /, i: str, arg_str: str) -> str: ...
  255. @staticmethod
  256. def _str_term_ascii(i: str, arg_str: str) -> str: ...
  257. @staticmethod
  258. def _repr_latex_term(i: str, arg_str: str, needs_parens: bool) -> str: ...