_asarray.pyi 1.1 KB

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