m2m模型翻译
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
1.9 KiB

6 months ago
  1. import sys
  2. from typing import TypeVar, Union, Iterable, overload
  3. from numpy import ndarray, _OrderKACF
  4. from numpy.typing import ArrayLike, DTypeLike
  5. if sys.version_info >= (3, 8):
  6. from typing import Literal
  7. else:
  8. from typing_extensions import Literal
  9. _ArrayType = TypeVar("_ArrayType", bound=ndarray)
  10. # TODO: The following functions are now defined in C, so should be defined
  11. # in a (not yet existing) `multiarray.pyi`.
  12. # (with the exception of `require`)
  13. def asarray(
  14. a: object,
  15. dtype: DTypeLike = ...,
  16. order: _OrderKACF = ...,
  17. *,
  18. like: ArrayLike = ...
  19. ) -> ndarray: ...
  20. @overload
  21. def asanyarray(
  22. a: _ArrayType,
  23. dtype: None = ...,
  24. order: _OrderKACF = ...,
  25. *,
  26. like: ArrayLike = ...
  27. ) -> _ArrayType: ...
  28. @overload
  29. def asanyarray(
  30. a: object,
  31. dtype: DTypeLike = ...,
  32. order: _OrderKACF = ...,
  33. *,
  34. like: ArrayLike = ...
  35. ) -> ndarray: ...
  36. def ascontiguousarray(
  37. a: object, dtype: DTypeLike = ..., *, like: ArrayLike = ...
  38. ) -> ndarray: ...
  39. def asfortranarray(
  40. a: object, dtype: DTypeLike = ..., *, like: ArrayLike = ...
  41. ) -> ndarray: ...
  42. _Requirements = Literal[
  43. "C", "C_CONTIGUOUS", "CONTIGUOUS",
  44. "F", "F_CONTIGUOUS", "FORTRAN",
  45. "A", "ALIGNED",
  46. "W", "WRITEABLE",
  47. "O", "OWNDATA"
  48. ]
  49. _E = Literal["E", "ENSUREARRAY"]
  50. _RequirementsWithE = Union[_Requirements, _E]
  51. @overload
  52. def require(
  53. a: _ArrayType,
  54. dtype: None = ...,
  55. requirements: Union[None, _Requirements, Iterable[_Requirements]] = ...,
  56. *,
  57. like: ArrayLike = ...
  58. ) -> _ArrayType: ...
  59. @overload
  60. def require(
  61. a: object,
  62. dtype: DTypeLike = ...,
  63. requirements: Union[_E, Iterable[_RequirementsWithE]] = ...,
  64. *,
  65. like: ArrayLike = ...
  66. ) -> ndarray: ...
  67. @overload
  68. def require(
  69. a: object,
  70. dtype: DTypeLike = ...,
  71. requirements: Union[None, _Requirements, Iterable[_Requirements]] = ...,
  72. *,
  73. like: ArrayLike = ...
  74. ) -> ndarray: ...