_asarray.pyi 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from collections.abc import Iterable
  2. from typing import TypeVar, Union, overload, Literal
  3. from numpy import ndarray
  4. from numpy._typing import DTypeLike, _SupportsArrayFunc
  5. _ArrayType = TypeVar("_ArrayType", bound=ndarray)
  6. _Requirements = Literal[
  7. "C", "C_CONTIGUOUS", "CONTIGUOUS",
  8. "F", "F_CONTIGUOUS", "FORTRAN",
  9. "A", "ALIGNED",
  10. "W", "WRITEABLE",
  11. "O", "OWNDATA"
  12. ]
  13. _E = Literal["E", "ENSUREARRAY"]
  14. _RequirementsWithE = Union[_Requirements, _E]
  15. @overload
  16. def require(
  17. a: _ArrayType,
  18. dtype: None = ...,
  19. requirements: None | _Requirements | Iterable[_Requirements] = ...,
  20. *,
  21. like: _SupportsArrayFunc = ...
  22. ) -> _ArrayType: ...
  23. @overload
  24. def require(
  25. a: object,
  26. dtype: DTypeLike = ...,
  27. requirements: _E | Iterable[_RequirementsWithE] = ...,
  28. *,
  29. like: _SupportsArrayFunc = ...
  30. ) -> ndarray: ...
  31. @overload
  32. def require(
  33. a: object,
  34. dtype: DTypeLike = ...,
  35. requirements: None | _Requirements | Iterable[_Requirements] = ...,
  36. *,
  37. like: _SupportsArrayFunc = ...
  38. ) -> ndarray: ...