function_base.pyi 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import sys
  2. from typing import overload, Tuple, Union, Sequence, Any
  3. from numpy import ndarray
  4. from numpy.typing import ArrayLike, DTypeLike, _SupportsArray, _NumberLike
  5. if sys.version_info >= (3, 8):
  6. from typing import SupportsIndex, Literal
  7. else:
  8. from typing_extensions import Literal, Protocol
  9. class SupportsIndex(Protocol):
  10. def __index__(self) -> int: ...
  11. # TODO: wait for support for recursive types
  12. _ArrayLikeNested = Sequence[Sequence[Any]]
  13. _ArrayLikeNumber = Union[
  14. _NumberLike, Sequence[_NumberLike], ndarray, _SupportsArray, _ArrayLikeNested
  15. ]
  16. @overload
  17. def linspace(
  18. start: _ArrayLikeNumber,
  19. stop: _ArrayLikeNumber,
  20. num: SupportsIndex = ...,
  21. endpoint: bool = ...,
  22. retstep: Literal[False] = ...,
  23. dtype: DTypeLike = ...,
  24. axis: SupportsIndex = ...,
  25. ) -> ndarray: ...
  26. @overload
  27. def linspace(
  28. start: _ArrayLikeNumber,
  29. stop: _ArrayLikeNumber,
  30. num: SupportsIndex = ...,
  31. endpoint: bool = ...,
  32. retstep: Literal[True] = ...,
  33. dtype: DTypeLike = ...,
  34. axis: SupportsIndex = ...,
  35. ) -> Tuple[ndarray, Any]: ...
  36. def logspace(
  37. start: _ArrayLikeNumber,
  38. stop: _ArrayLikeNumber,
  39. num: SupportsIndex = ...,
  40. endpoint: bool = ...,
  41. base: _ArrayLikeNumber = ...,
  42. dtype: DTypeLike = ...,
  43. axis: SupportsIndex = ...,
  44. ) -> ndarray: ...
  45. def geomspace(
  46. start: _ArrayLikeNumber,
  47. stop: _ArrayLikeNumber,
  48. num: SupportsIndex = ...,
  49. endpoint: bool = ...,
  50. dtype: DTypeLike = ...,
  51. axis: SupportsIndex = ...,
  52. ) -> ndarray: ...