chebyshev.pyi 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. from _typeshed import ConvertibleToInt
  2. from collections.abc import Callable, Iterable
  3. from typing import (
  4. Any,
  5. ClassVar,
  6. Concatenate,
  7. Final,
  8. Literal as L,
  9. Self,
  10. TypeVar,
  11. overload,
  12. )
  13. import numpy as np
  14. import numpy.typing as npt
  15. from numpy._typing import _IntLike_co
  16. from ._polybase import ABCPolyBase
  17. from ._polytypes import (
  18. _Array1,
  19. _Array2,
  20. _CoefSeries,
  21. _FuncBinOp,
  22. _FuncCompanion,
  23. _FuncDer,
  24. _FuncFit,
  25. _FuncFromRoots,
  26. _FuncGauss,
  27. _FuncInteg,
  28. _FuncLine,
  29. _FuncPoly2Ortho,
  30. _FuncPow,
  31. _FuncRoots,
  32. _FuncUnOp,
  33. _FuncVal,
  34. _FuncVal2D,
  35. _FuncVal3D,
  36. _FuncVander,
  37. _FuncVander2D,
  38. _FuncVander3D,
  39. _FuncWeight,
  40. _Series,
  41. _SeriesLikeCoef_co,
  42. )
  43. from .polyutils import trimcoef as chebtrim
  44. __all__ = [
  45. "chebzero",
  46. "chebone",
  47. "chebx",
  48. "chebdomain",
  49. "chebline",
  50. "chebadd",
  51. "chebsub",
  52. "chebmulx",
  53. "chebmul",
  54. "chebdiv",
  55. "chebpow",
  56. "chebval",
  57. "chebder",
  58. "chebint",
  59. "cheb2poly",
  60. "poly2cheb",
  61. "chebfromroots",
  62. "chebvander",
  63. "chebfit",
  64. "chebtrim",
  65. "chebroots",
  66. "chebpts1",
  67. "chebpts2",
  68. "Chebyshev",
  69. "chebval2d",
  70. "chebval3d",
  71. "chebgrid2d",
  72. "chebgrid3d",
  73. "chebvander2d",
  74. "chebvander3d",
  75. "chebcompanion",
  76. "chebgauss",
  77. "chebweight",
  78. "chebinterpolate",
  79. ]
  80. _NumberOrObjectT = TypeVar("_NumberOrObjectT", bound=np.number | np.object_)
  81. _CoefScalarT = TypeVar("_CoefScalarT", bound=np.number | np.bool | np.object_)
  82. def _cseries_to_zseries(c: npt.NDArray[_NumberOrObjectT]) -> _Series[_NumberOrObjectT]: ...
  83. def _zseries_to_cseries(zs: npt.NDArray[_NumberOrObjectT]) -> _Series[_NumberOrObjectT]: ...
  84. def _zseries_mul(z1: npt.NDArray[_NumberOrObjectT], z2: npt.NDArray[_NumberOrObjectT]) -> _Series[_NumberOrObjectT]: ...
  85. def _zseries_div(z1: npt.NDArray[_NumberOrObjectT], z2: npt.NDArray[_NumberOrObjectT]) -> _Series[_NumberOrObjectT]: ...
  86. def _zseries_der(zs: npt.NDArray[_NumberOrObjectT]) -> _Series[_NumberOrObjectT]: ...
  87. def _zseries_int(zs: npt.NDArray[_NumberOrObjectT]) -> _Series[_NumberOrObjectT]: ...
  88. poly2cheb: Final[_FuncPoly2Ortho] = ...
  89. cheb2poly: Final[_FuncUnOp] = ...
  90. chebdomain: Final[_Array2[np.float64]] = ...
  91. chebzero: Final[_Array1[np.int_]] = ...
  92. chebone: Final[_Array1[np.int_]] = ...
  93. chebx: Final[_Array2[np.int_]] = ...
  94. chebline: Final[_FuncLine] = ...
  95. chebfromroots: Final[_FuncFromRoots] = ...
  96. chebadd: Final[_FuncBinOp] = ...
  97. chebsub: Final[_FuncBinOp] = ...
  98. chebmulx: Final[_FuncUnOp] = ...
  99. chebmul: Final[_FuncBinOp] = ...
  100. chebdiv: Final[_FuncBinOp] = ...
  101. chebpow: Final[_FuncPow] = ...
  102. chebder: Final[_FuncDer] = ...
  103. chebint: Final[_FuncInteg] = ...
  104. chebval: Final[_FuncVal] = ...
  105. chebval2d: Final[_FuncVal2D] = ...
  106. chebval3d: Final[_FuncVal3D] = ...
  107. chebgrid2d: Final[_FuncVal2D] = ...
  108. chebgrid3d: Final[_FuncVal3D] = ...
  109. chebvander: Final[_FuncVander] = ...
  110. chebvander2d: Final[_FuncVander2D] = ...
  111. chebvander3d: Final[_FuncVander3D] = ...
  112. chebfit: Final[_FuncFit] = ...
  113. chebcompanion: Final[_FuncCompanion] = ...
  114. chebroots: Final[_FuncRoots] = ...
  115. chebgauss: Final[_FuncGauss] = ...
  116. chebweight: Final[_FuncWeight] = ...
  117. def chebpts1(npts: ConvertibleToInt) -> np.ndarray[tuple[int], np.dtype[np.float64]]: ...
  118. def chebpts2(npts: ConvertibleToInt) -> np.ndarray[tuple[int], np.dtype[np.float64]]: ...
  119. # keep in sync with `Chebyshev.interpolate` (minus `domain` parameter)
  120. @overload
  121. def chebinterpolate(
  122. func: np.ufunc,
  123. deg: _IntLike_co,
  124. args: tuple[()] = (),
  125. ) -> npt.NDArray[np.float64 | np.complex128 | np.object_]: ...
  126. @overload
  127. def chebinterpolate(
  128. func: Callable[[npt.NDArray[np.float64]], _CoefScalarT],
  129. deg: _IntLike_co,
  130. args: tuple[()] = (),
  131. ) -> npt.NDArray[_CoefScalarT]: ...
  132. @overload
  133. def chebinterpolate(
  134. func: Callable[Concatenate[npt.NDArray[np.float64], ...], _CoefScalarT],
  135. deg: _IntLike_co,
  136. args: Iterable[Any],
  137. ) -> npt.NDArray[_CoefScalarT]: ...
  138. class Chebyshev(ABCPolyBase[L["T"]]):
  139. basis_name: ClassVar[L["T"]] = "T" # pyright: ignore[reportIncompatibleMethodOverride]
  140. domain: _Array2[np.float64 | Any] = ... # pyright: ignore[reportIncompatibleMethodOverride]
  141. window: _Array2[np.float64 | Any] = ... # pyright: ignore[reportIncompatibleMethodOverride]
  142. @overload
  143. @classmethod
  144. def interpolate(
  145. cls,
  146. func: Callable[[npt.NDArray[np.float64]], _CoefSeries],
  147. deg: _IntLike_co,
  148. domain: _SeriesLikeCoef_co | None = None,
  149. args: tuple[()] = (),
  150. ) -> Self: ...
  151. @overload
  152. @classmethod
  153. def interpolate(
  154. cls,
  155. func: Callable[Concatenate[npt.NDArray[np.float64], ...], _CoefSeries],
  156. deg: _IntLike_co,
  157. domain: _SeriesLikeCoef_co | None = None,
  158. *,
  159. args: Iterable[Any],
  160. ) -> Self: ...
  161. @overload
  162. @classmethod
  163. def interpolate(
  164. cls,
  165. func: Callable[Concatenate[npt.NDArray[np.float64], ...], _CoefSeries],
  166. deg: _IntLike_co,
  167. domain: _SeriesLikeCoef_co | None,
  168. args: Iterable[Any],
  169. ) -> Self: ...