_polybase.pyi 7.6 KB

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