parameters: (fp)
return_statement: return d['shape'], d['fortran_order'], dtype
docstring: Read an array header from a filelike object using the 1.0 file format
      version.
  
      This will leave the file object located just after the header.
  
      Parameters
      ----------
      fp : filelike object
          A file object or something with a `.read()` method like a file.
  
      Returns
      -------
      shape : tuple of int
          The shape of the array.
      fortran_order : bool
          The array data will be written out directly if it is either C-contiguous
          or Fortran-contiguous. Otherwise, it will be made contiguous before
          writing it out.
      dtype : dtype
          The dtype of the file's data.
  
      Raises
      ------
      ValueError
          If the data is invalid.
docstring_summary: Read an array header from a filelike object using the 1.0 file format
      version.
docstring_tokens: Read an array header from a filelike object using the 1 . 0 file format version .
function: def read_array_header_1_0(fp):
      """
      Read an array header from a filelike object using the 1.0 file format
      version.
  
      This will leave the file object located just after the header.
  
      Parameters
      ----------
      fp : filelike object
          A file object or something with a `.read()` method like a file.
  
      Returns
      -------
      shape : tuple of int
          The shape of the array.
      fortran_order : bool
          The array data will be written out directly if it is either C-contiguous
          or Fortran-contiguous. Otherwise, it will be made contiguous before
          writing it out.
      dtype : dtype
          The dtype of the file's data.
  
      Raises
      ------
      ValueError
          If the data is invalid.
  
      """
      # Read an unsigned, little-endian short int which has the length of the
      # header.
      import struct
      hlength_str = _read_bytes(fp, 2, "array header length")
      header_length = struct.unpack('<H', hlength_str)[0]
      header = _read_bytes(fp, header_length, "array header")
  
      # The header is a pretty-printed string representation of a literal Python
      # dictionary with trailing newlines padded to a 16-byte boundary. The keys
      # are strings.
      #   "shape" : tuple of int
      #   "fortran_order" : bool
      #   "descr" : dtype.descr
      try:
          d = safe_eval(header)
      except SyntaxError as e:
          msg = "Cannot parse header: %r\nException: %r"
          raise ValueError(msg % (header, e))
      if not isinstance(d, dict):
          msg = "Header is not a dictionary: %r"
          raise ValueError(msg % d)
      keys = sorted(d.keys())
      if keys != ['descr', 'fortran_order', 'shape']:
          msg = "Header does not contain the correct keys: %r"
          raise ValueError(msg % (keys,))
  
      # Sanity-check the values.
      if (not isinstance(d['shape'], tuple) or
          not numpy.all([isinstance(x, (int, long)) for x in d['shape']])):
          msg = "shape is not valid: %r"
          raise ValueError(msg % (d['shape'],))
      if not isinstance(d['fortran_order'], bool):
          msg = "fortran_order is not a valid bool: %r"
          raise ValueError(msg % (d['fortran_order'],))
      try:
          dtype = numpy.dtype(d['descr'])
      except TypeError as e:
          msg = "descr is not a valid dtype descriptor: %r"
          raise ValueError(msg % (d['descr'],))
  
      return d['shape'], d['fortran_order'], dtype
function_tokens: def read_array_header_1_0 ( fp ) : # Read an unsigned, little-endian short int which has the length of the # header. import struct hlength_str = _read_bytes ( fp , 2 , "array header length" ) header_length = struct . unpack ( '<H' , hlength_str ) [ 0 ] header = _read_bytes ( fp , header_length , "array header" ) # The header is a pretty-printed string representation of a literal Python # dictionary with trailing newlines padded to a 16-byte boundary. The keys # are strings. #   "shape" : tuple of int #   "fortran_order" : bool #   "descr" : dtype.descr try : d = safe_eval ( header ) except SyntaxError as e : msg = "Cannot parse header: %r\nException: %r" raise ValueError ( msg % ( header , e ) ) if not isinstance ( d , dict ) : msg = "Header is not a dictionary: %r" raise ValueError ( msg % d ) keys = sorted ( d . keys ( ) ) if keys != [ 'descr' , 'fortran_order' , 'shape' ] : msg = "Header does not contain the correct keys: %r" raise ValueError ( msg % ( keys , ) ) # Sanity-check the values. if ( not isinstance ( d [ 'shape' ] , tuple ) or not numpy . all ( [ isinstance ( x , ( int , long ) ) for x in d [ 'shape' ] ] ) ) : msg = "shape is not valid: %r" raise ValueError ( msg % ( d [ 'shape' ] , ) ) if not isinstance ( d [ 'fortran_order' ] , bool ) : msg = "fortran_order is not a valid bool: %r" raise ValueError ( msg % ( d [ 'fortran_order' ] , ) ) try : dtype = numpy . dtype ( d [ 'descr' ] ) except TypeError as e : msg = "descr is not a valid dtype descriptor: %r" raise ValueError ( msg % ( d [ 'descr' ] , ) ) return d [ 'shape' ] , d [ 'fortran_order' ] , dtype