numpy.pyi 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. from typing import TypeVar
  2. int8 = 'int8'
  3. int16 = 'int16'
  4. int32 = 'int32'
  5. int64 = 'int64'
  6. int_ = int64
  7. float32 = 'float32'
  8. float64 = 'float64'
  9. float_ = float64
  10. bool_ = 'bool'
  11. _Number = TypeVar('_Number', int, float, bool)
  12. _Dtype = str
  13. _ShapeLike = tuple[int, ...]
  14. class ndarray:
  15. # Dunder Methods
  16. def __add__(self, other: _Number | 'ndarray') -> 'ndarray': ...
  17. def __sub__(self, other: _Number | 'ndarray') -> 'ndarray': ...
  18. def __mul__(self, other: _Number | 'ndarray') -> 'ndarray': ...
  19. def __truediv__(self, other: _Number | 'ndarray') -> 'ndarray': ...
  20. def __pow__(self, other: _Number | 'ndarray') -> 'ndarray': ...
  21. def __matmul__(self, other: 'ndarray') -> 'ndarray': ...
  22. def __and__(self, other: _Number | 'ndarray') -> 'ndarray': ...
  23. def __or__(self, other: _Number | 'ndarray') -> 'ndarray': ...
  24. def __xor__(self, other: _Number | 'ndarray') -> 'ndarray': ...
  25. def __invert__(self) -> 'ndarray': ...
  26. def __eq__(self, other: _Number | 'ndarray') -> 'ndarray': ...
  27. def __ne__(self, other: _Number | 'ndarray') -> 'ndarray': ...
  28. def __getitem__(self, key): ...
  29. def __setitem__(self, key, value): ...
  30. def __len__(self) -> int: ...
  31. def __repr__(self) -> str: ...
  32. def __str__(self) -> str: ...
  33. # Properties
  34. @property
  35. def dtype(self) -> _Dtype: ...
  36. @property
  37. def ndim(self) -> int: ...
  38. @property
  39. def size(self) -> int: ...
  40. @property
  41. def shape(self) -> tuple[int, ...]: ...
  42. # Boolean operations
  43. def all(self, axis: int = 0) -> bool: ...
  44. def any(self, axis: int = 0) -> bool: ...
  45. # Aggregate Functions
  46. def sum(self, axis: int = 0) -> _Number | 'ndarray': ...
  47. def min(self, axis: int = 0) -> _Number | 'ndarray': ...
  48. def max(self, axis: int = 0) -> _Number | 'ndarray': ...
  49. def mean(self, axis: int = 0) -> _Number | 'ndarray': ...
  50. def std(self, axis: int = 0) -> _Number | 'ndarray': ...
  51. def var(self, axis: int = 0) -> _Number | 'ndarray': ...
  52. # Searching and Sorting
  53. def argmin(self, axis: int = 0) -> int | 'ndarray': ...
  54. def argmax(self, axis: int = 0) -> int | 'ndarray': ...
  55. def argsort(self, axis: int = 0) -> 'ndarray': ...
  56. def sort(self, axis: int = 0) -> None: ...
  57. # Shape Manipulation
  58. def reshape(self, shape: _ShapeLike) -> 'ndarray': ...
  59. def resize(self, shape: _ShapeLike) -> None: ...
  60. def repeat(self, repeats: int, axis: int = 0) -> 'ndarray': ...
  61. def transpose(self, axes: _ShapeLike = None) -> 'ndarray': ...
  62. def squeeze(self, axis: int = 0) -> 'ndarray': ...
  63. def flatten(self) -> 'ndarray': ...
  64. # Miscellaneous
  65. def astype(self, dtype: _Dtype) -> 'ndarray': ...
  66. def round(self, decimals: int = 0) -> 'ndarray': ...
  67. def copy(self) -> 'ndarray': ...
  68. def tolist(self) -> list[_Number]: ...
  69. # Array Creation
  70. def array(object, dtype: _Dtype = None) -> 'ndarray': ...
  71. def zeros(shape: _ShapeLike, dtype: _Dtype = float_) -> 'ndarray': ...
  72. def ones(shape: _ShapeLike, dtype: _Dtype = float_) -> 'ndarray': ...
  73. def full(shape: _ShapeLike, fill_value: _Number, dtype: _Dtype = None) -> 'ndarray': ...
  74. def identity(n: int, dtype: _Dtype = float_) -> 'ndarray': ...
  75. def arange(start: int, stop: int, step: int, dtype: _Dtype = int_) -> 'ndarray': ...
  76. def linspace(start: _Number, stop: _Number, num: int, endpoint: bool = True, dtype: _Dtype = float_) -> 'ndarray': ...
  77. # Trigonometry
  78. def sin(x: 'ndarray') -> 'ndarray': ...
  79. def cos(x: 'ndarray') -> 'ndarray': ...
  80. def tan(x: 'ndarray') -> 'ndarray': ...
  81. def arcsin(x: 'ndarray') -> 'ndarray': ...
  82. def arccos(x: 'ndarray') -> 'ndarray': ...
  83. def arctan(x: 'ndarray') -> 'ndarray': ...
  84. # Exponents and Logarithms
  85. def exp(x: 'ndarray') -> 'ndarray': ...
  86. def log(x: 'ndarray') -> 'ndarray': ...
  87. def log2(x: 'ndarray') -> 'ndarray': ...
  88. def log10(x: 'ndarray') -> 'ndarray': ...
  89. # Miscellaneous
  90. def abs(x: 'ndarray') -> 'ndarray': ...
  91. def ceil(x: 'ndarray') -> 'ndarray': ...
  92. def floor(x: 'ndarray') -> 'ndarray': ...
  93. def concatenate(arrays: tuple['ndarray', ...], axis: int = 0) -> 'ndarray': ...
  94. def corrcoef(x: 'ndarray', y: 'ndarray') -> 'ndarray': ...
  95. class random:
  96. @staticmethod
  97. def rand(*size) -> 'ndarray': ...
  98. @staticmethod
  99. def randn(*size) -> 'ndarray': ...
  100. @staticmethod
  101. def randint(low: int, high: int, size: _ShapeLike) -> 'ndarray': ...
  102. @staticmethod
  103. def normal(loc: _Number, scale: _Number, size: _ShapeLike) -> 'ndarray': ...
  104. @staticmethod
  105. def uniform(low: _Number, high: _Number, size: _ShapeLike) -> 'ndarray': ...