# numpy 2.5.4 (BSD-3-Clause), harvested by tools/harvest_corpus.py
=== input
Create an array from binary file data

    Parameters
    ----------
    fd : str or file type
        If file is a string or a path-like object then that file is opened,
        else it is assumed to be a file object. The file object must
        support random access (i.e. it must have tell and seek methods).
    dtype : data-type, optional
        valid dtype for all arrays
    shape : int or tuple of ints, optional
        shape of each array.
    offset : int, optional
        Position in the file to start reading from.
    formats, names, titles, aligned, byteorder :
        If `dtype` is ``None``, these arguments are passed to
        `numpy.format_parser` to construct a dtype. See that function for
        detailed documentation

    Returns
    -------
    np.recarray
        record array consisting of data enclosed in file.

    Examples
    --------
    >>> from tempfile import TemporaryFile
    >>> a = np.empty(10,dtype='f8,i4,S5')
    >>> a[5] = (0.5,10,'abcde')
    >>>
    >>> fd=TemporaryFile()
    >>> a = a.view(a.dtype.newbyteorder('<'))
    >>> a.tofile(fd)
    >>>
    >>> _ = fd.seek(0)
    >>> r=np.rec.fromfile(fd, formats='f8,i4,S5', shape=10,
    ... byteorder='<')
    >>> print(r[5])
    (0.5, 10, b'abcde')
    >>> r.shape
    (10,)
    
=== parse numpydoc
short_description: 'Create an array from binary file data'
blank_after_short_description: True
blank_after_long_description: False
style: numpydoc
- DocstringParam
  description: |
    If file is a string or a path-like object then that file is opened,
    else it is assumed to be a file object. The file object must
    support random access (i.e. it must have tell and seek methods).
  kind: param
  key: 'param'
  arg_name: 'fd'
  type_name: 'str or file type'
  is_optional: False
- DocstringParam
  description: 'valid dtype for all arrays'
  kind: param
  key: 'param'
  arg_name: 'dtype'
  type_name: 'data-type'
  is_optional: True
  raw_type_name: 'data-type, optional'
- DocstringParam
  description: 'shape of each array.'
  kind: param
  key: 'param'
  arg_name: 'shape'
  type_name: 'int or tuple of ints'
  is_optional: True
  raw_type_name: 'int or tuple of ints, optional'
- DocstringParam
  description: 'Position in the file to start reading from.'
  kind: param
  key: 'param'
  arg_name: 'offset'
  type_name: 'int'
  is_optional: True
  raw_type_name: 'int, optional'
- DocstringParam
  description: |
    If `dtype` is ``None``, these arguments are passed to
    `numpy.format_parser` to construct a dtype. See that function for
    detailed documentation
  kind: param
  key: 'param'
  arg_name: 'formats'
  type_name: ''
  is_optional: False
- DocstringParam
  description: |
    If `dtype` is ``None``, these arguments are passed to
    `numpy.format_parser` to construct a dtype. See that function for
    detailed documentation
  kind: param
  key: 'param'
  arg_name: 'names'
  type_name: ''
  is_optional: False
- DocstringParam
  description: |
    If `dtype` is ``None``, these arguments are passed to
    `numpy.format_parser` to construct a dtype. See that function for
    detailed documentation
  kind: param
  key: 'param'
  arg_name: 'titles'
  type_name: ''
  is_optional: False
- DocstringParam
  description: |
    If `dtype` is ``None``, these arguments are passed to
    `numpy.format_parser` to construct a dtype. See that function for
    detailed documentation
  kind: param
  key: 'param'
  arg_name: 'aligned'
  type_name: ''
  is_optional: False
- DocstringParam
  description: |
    If `dtype` is ``None``, these arguments are passed to
    `numpy.format_parser` to construct a dtype. See that function for
    detailed documentation
  kind: param
  key: 'param'
  arg_name: 'byteorder'
  type_name: ''
  is_optional: False
- DocstringReturns
  description: 'record array consisting of data enclosed in file.'
  kind: returns
  key: 'returns'
  type_name: 'np.recarray'
  is_generator: False
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: '>>> from tempfile import TemporaryFile'
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: ">>> a = np.empty(10,dtype='f8,i4,S5')"
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: ">>> a[5] = (0.5,10,'abcde')"
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: '>>>'
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: '>>> fd=TemporaryFile()'
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: ">>> a = a.view(a.dtype.newbyteorder('<'))"
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: '>>> a.tofile(fd)'
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: '>>>'
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: '>>> _ = fd.seek(0)'
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: |
    >>> r=np.rec.fromfile(fd, formats='f8,i4,S5', shape=10,
    ... byteorder='<')
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: |
    >>> print(r[5])
    (0.5, 10, b'abcde')
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: |
    >>> r.shape
    (10,)
=== detect
numpydoc
=== compose numpydoc
Create an array from binary file data

Parameters
----------
fd : str or file type
    If file is a string or a path-like object then that file is opened,
    else it is assumed to be a file object. The file object must
    support random access (i.e. it must have tell and seek methods).
dtype : data-type, optional
    valid dtype for all arrays
shape : int or tuple of ints, optional
    shape of each array.
offset : int, optional
    Position in the file to start reading from.
formats : 
    If `dtype` is ``None``, these arguments are passed to
    `numpy.format_parser` to construct a dtype. See that function for
    detailed documentation
names : 
    If `dtype` is ``None``, these arguments are passed to
    `numpy.format_parser` to construct a dtype. See that function for
    detailed documentation
titles : 
    If `dtype` is ``None``, these arguments are passed to
    `numpy.format_parser` to construct a dtype. See that function for
    detailed documentation
aligned : 
    If `dtype` is ``None``, these arguments are passed to
    `numpy.format_parser` to construct a dtype. See that function for
    detailed documentation
byteorder : 
    If `dtype` is ``None``, these arguments are passed to
    `numpy.format_parser` to construct a dtype. See that function for
    detailed documentation

Returns
-------
np.recarray
    record array consisting of data enclosed in file.

Examples
--------
>>> from tempfile import TemporaryFile
>>> a = np.empty(10,dtype='f8,i4,S5')
>>> a[5] = (0.5,10,'abcde')
>>>
>>> fd=TemporaryFile()
>>> a = a.view(a.dtype.newbyteorder('<'))
>>> a.tofile(fd)
>>>
>>> _ = fd.seek(0)
>>> r=np.rec.fromfile(fd, formats='f8,i4,S5', shape=10,
... byteorder='<')
>>> print(r[5])
(0.5, 10, b'abcde')
>>> r.shape
(10,)
