records.pyi 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. import os
  2. from collections.abc import Sequence, Iterable
  3. from typing import (
  4. Any,
  5. TypeVar,
  6. overload,
  7. Protocol,
  8. )
  9. from numpy import (
  10. format_parser as format_parser,
  11. record as record,
  12. recarray as recarray,
  13. dtype,
  14. generic,
  15. void,
  16. _ByteOrder,
  17. _SupportsBuffer,
  18. )
  19. from numpy._typing import (
  20. ArrayLike,
  21. DTypeLike,
  22. NDArray,
  23. _ShapeLike,
  24. _ArrayLikeVoid_co,
  25. _NestedSequence,
  26. )
  27. _SCT = TypeVar("_SCT", bound=generic)
  28. _RecArray = recarray[Any, dtype[_SCT]]
  29. class _SupportsReadInto(Protocol):
  30. def seek(self, offset: int, whence: int, /) -> object: ...
  31. def tell(self, /) -> int: ...
  32. def readinto(self, buffer: memoryview, /) -> int: ...
  33. __all__: list[str]
  34. @overload
  35. def fromarrays(
  36. arrayList: Iterable[ArrayLike],
  37. dtype: DTypeLike = ...,
  38. shape: None | _ShapeLike = ...,
  39. formats: None = ...,
  40. names: None = ...,
  41. titles: None = ...,
  42. aligned: bool = ...,
  43. byteorder: None = ...,
  44. ) -> _RecArray[Any]: ...
  45. @overload
  46. def fromarrays(
  47. arrayList: Iterable[ArrayLike],
  48. dtype: None = ...,
  49. shape: None | _ShapeLike = ...,
  50. *,
  51. formats: DTypeLike,
  52. names: None | str | Sequence[str] = ...,
  53. titles: None | str | Sequence[str] = ...,
  54. aligned: bool = ...,
  55. byteorder: None | _ByteOrder = ...,
  56. ) -> _RecArray[record]: ...
  57. @overload
  58. def fromrecords(
  59. recList: _ArrayLikeVoid_co | tuple[Any, ...] | _NestedSequence[tuple[Any, ...]],
  60. dtype: DTypeLike = ...,
  61. shape: None | _ShapeLike = ...,
  62. formats: None = ...,
  63. names: None = ...,
  64. titles: None = ...,
  65. aligned: bool = ...,
  66. byteorder: None = ...,
  67. ) -> _RecArray[record]: ...
  68. @overload
  69. def fromrecords(
  70. recList: _ArrayLikeVoid_co | tuple[Any, ...] | _NestedSequence[tuple[Any, ...]],
  71. dtype: None = ...,
  72. shape: None | _ShapeLike = ...,
  73. *,
  74. formats: DTypeLike,
  75. names: None | str | Sequence[str] = ...,
  76. titles: None | str | Sequence[str] = ...,
  77. aligned: bool = ...,
  78. byteorder: None | _ByteOrder = ...,
  79. ) -> _RecArray[record]: ...
  80. @overload
  81. def fromstring(
  82. datastring: _SupportsBuffer,
  83. dtype: DTypeLike,
  84. shape: None | _ShapeLike = ...,
  85. offset: int = ...,
  86. formats: None = ...,
  87. names: None = ...,
  88. titles: None = ...,
  89. aligned: bool = ...,
  90. byteorder: None = ...,
  91. ) -> _RecArray[record]: ...
  92. @overload
  93. def fromstring(
  94. datastring: _SupportsBuffer,
  95. dtype: None = ...,
  96. shape: None | _ShapeLike = ...,
  97. offset: int = ...,
  98. *,
  99. formats: DTypeLike,
  100. names: None | str | Sequence[str] = ...,
  101. titles: None | str | Sequence[str] = ...,
  102. aligned: bool = ...,
  103. byteorder: None | _ByteOrder = ...,
  104. ) -> _RecArray[record]: ...
  105. @overload
  106. def fromfile(
  107. fd: str | bytes | os.PathLike[str] | os.PathLike[bytes] | _SupportsReadInto,
  108. dtype: DTypeLike,
  109. shape: None | _ShapeLike = ...,
  110. offset: int = ...,
  111. formats: None = ...,
  112. names: None = ...,
  113. titles: None = ...,
  114. aligned: bool = ...,
  115. byteorder: None = ...,
  116. ) -> _RecArray[Any]: ...
  117. @overload
  118. def fromfile(
  119. fd: str | bytes | os.PathLike[str] | os.PathLike[bytes] | _SupportsReadInto,
  120. dtype: None = ...,
  121. shape: None | _ShapeLike = ...,
  122. offset: int = ...,
  123. *,
  124. formats: DTypeLike,
  125. names: None | str | Sequence[str] = ...,
  126. titles: None | str | Sequence[str] = ...,
  127. aligned: bool = ...,
  128. byteorder: None | _ByteOrder = ...,
  129. ) -> _RecArray[record]: ...
  130. @overload
  131. def array(
  132. obj: _SCT | NDArray[_SCT],
  133. dtype: None = ...,
  134. shape: None | _ShapeLike = ...,
  135. offset: int = ...,
  136. formats: None = ...,
  137. names: None = ...,
  138. titles: None = ...,
  139. aligned: bool = ...,
  140. byteorder: None = ...,
  141. copy: bool = ...,
  142. ) -> _RecArray[_SCT]: ...
  143. @overload
  144. def array(
  145. obj: ArrayLike,
  146. dtype: DTypeLike,
  147. shape: None | _ShapeLike = ...,
  148. offset: int = ...,
  149. formats: None = ...,
  150. names: None = ...,
  151. titles: None = ...,
  152. aligned: bool = ...,
  153. byteorder: None = ...,
  154. copy: bool = ...,
  155. ) -> _RecArray[Any]: ...
  156. @overload
  157. def array(
  158. obj: ArrayLike,
  159. dtype: None = ...,
  160. shape: None | _ShapeLike = ...,
  161. offset: int = ...,
  162. *,
  163. formats: DTypeLike,
  164. names: None | str | Sequence[str] = ...,
  165. titles: None | str | Sequence[str] = ...,
  166. aligned: bool = ...,
  167. byteorder: None | _ByteOrder = ...,
  168. copy: bool = ...,
  169. ) -> _RecArray[record]: ...
  170. @overload
  171. def array(
  172. obj: None,
  173. dtype: DTypeLike,
  174. shape: _ShapeLike,
  175. offset: int = ...,
  176. formats: None = ...,
  177. names: None = ...,
  178. titles: None = ...,
  179. aligned: bool = ...,
  180. byteorder: None = ...,
  181. copy: bool = ...,
  182. ) -> _RecArray[Any]: ...
  183. @overload
  184. def array(
  185. obj: None,
  186. dtype: None = ...,
  187. *,
  188. shape: _ShapeLike,
  189. offset: int = ...,
  190. formats: DTypeLike,
  191. names: None | str | Sequence[str] = ...,
  192. titles: None | str | Sequence[str] = ...,
  193. aligned: bool = ...,
  194. byteorder: None | _ByteOrder = ...,
  195. copy: bool = ...,
  196. ) -> _RecArray[record]: ...
  197. @overload
  198. def array(
  199. obj: _SupportsReadInto,
  200. dtype: DTypeLike,
  201. shape: None | _ShapeLike = ...,
  202. offset: int = ...,
  203. formats: None = ...,
  204. names: None = ...,
  205. titles: None = ...,
  206. aligned: bool = ...,
  207. byteorder: None = ...,
  208. copy: bool = ...,
  209. ) -> _RecArray[Any]: ...
  210. @overload
  211. def array(
  212. obj: _SupportsReadInto,
  213. dtype: None = ...,
  214. shape: None | _ShapeLike = ...,
  215. offset: int = ...,
  216. *,
  217. formats: DTypeLike,
  218. names: None | str | Sequence[str] = ...,
  219. titles: None | str | Sequence[str] = ...,
  220. aligned: bool = ...,
  221. byteorder: None | _ByteOrder = ...,
  222. copy: bool = ...,
  223. ) -> _RecArray[record]: ...