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