_stride_tricks_impl.pyi 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. from collections.abc import Iterable
  2. from typing import Any, SupportsIndex, TypeVar, overload
  3. from numpy import generic
  4. from numpy._typing import ArrayLike, NDArray, _AnyShape, _ArrayLike, _ShapeLike
  5. __all__ = ["broadcast_to", "broadcast_arrays", "broadcast_shapes"]
  6. _ScalarT = TypeVar("_ScalarT", bound=generic)
  7. class DummyArray:
  8. __array_interface__: dict[str, Any]
  9. base: NDArray[Any] | None
  10. def __init__(
  11. self,
  12. interface: dict[str, Any],
  13. base: NDArray[Any] | None = None,
  14. ) -> None: ...
  15. @overload
  16. def as_strided(
  17. x: _ArrayLike[_ScalarT],
  18. shape: Iterable[int] | None = None,
  19. strides: Iterable[int] | None = None,
  20. subok: bool = False,
  21. writeable: bool = True,
  22. ) -> NDArray[_ScalarT]: ...
  23. @overload
  24. def as_strided(
  25. x: ArrayLike,
  26. shape: Iterable[int] | None = None,
  27. strides: Iterable[int] | None = None,
  28. subok: bool = False,
  29. writeable: bool = True,
  30. ) -> NDArray[Any]: ...
  31. @overload
  32. def sliding_window_view(
  33. x: _ArrayLike[_ScalarT],
  34. window_shape: int | Iterable[int],
  35. axis: SupportsIndex | None = None,
  36. *,
  37. subok: bool = False,
  38. writeable: bool = False,
  39. ) -> NDArray[_ScalarT]: ...
  40. @overload
  41. def sliding_window_view(
  42. x: ArrayLike,
  43. window_shape: int | Iterable[int],
  44. axis: SupportsIndex | None = None,
  45. *,
  46. subok: bool = False,
  47. writeable: bool = False,
  48. ) -> NDArray[Any]: ...
  49. @overload
  50. def broadcast_to(
  51. array: _ArrayLike[_ScalarT],
  52. shape: int | Iterable[int],
  53. subok: bool = False,
  54. ) -> NDArray[_ScalarT]: ...
  55. @overload
  56. def broadcast_to(
  57. array: ArrayLike,
  58. shape: int | Iterable[int],
  59. subok: bool = False,
  60. ) -> NDArray[Any]: ...
  61. def broadcast_shapes(*args: _ShapeLike) -> _AnyShape: ...
  62. def broadcast_arrays(*args: ArrayLike, subok: bool = False) -> tuple[NDArray[Any], ...]: ...
  63. # used internally by `lib._function_base_impl._parse_input_dimensions`
  64. def _broadcast_shape(*args: ArrayLike) -> _AnyShape: ...