_polybase.pyi 8.3 KB

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