parameters: (descr)
return_statement: return numpy.dtype({'names': names, 'formats': formats, 'titles': titles,
                          'offsets': offsets, 'itemsize': offset})
docstring: descr may be stored as dtype.descr, which is a list of
      (name, format, [shape]) tuples where format may be a str or a tuple.
      Offsets are not explicitly saved, rather empty fields with
      name, format == '', '|Vn' are added as padding.
  
      This function reverses the process, eliminating the empty padding fields.
docstring_summary: descr may be stored as dtype.descr, which is a list of
      (name, format, [shape]) tuples where format may be a str or a tuple.
      Offsets are not explicitly saved, rather empty fields with
      name, format == '', '|Vn' are added as padding.
docstring_tokens: descr may be stored as dtype . descr which is a list of ( name format [ shape ] ) tuples where format may be a str or a tuple . Offsets are not explicitly saved rather empty fields with name format == |Vn are added as padding .
function: def descr_to_dtype(descr):
      '''
      descr may be stored as dtype.descr, which is a list of
      (name, format, [shape]) tuples where format may be a str or a tuple.
      Offsets are not explicitly saved, rather empty fields with
      name, format == '', '|Vn' are added as padding.
  
      This function reverses the process, eliminating the empty padding fields.
      '''
      if isinstance(descr, str):
          # No padding removal needed
          return numpy.dtype(descr)
      elif isinstance(descr, tuple):
          # subtype, will always have a shape descr[1]
          dt = descr_to_dtype(descr[0])
          return numpy.dtype((dt, descr[1]))
      fields = []
      offset = 0
      for field in descr:
          if len(field) == 2:
              name, descr_str = field
              dt = descr_to_dtype(descr_str)
          else:
              name, descr_str, shape = field
              dt = numpy.dtype((descr_to_dtype(descr_str), shape))
  
          # Ignore padding bytes, which will be void bytes with '' as name
          # Once support for blank names is removed, only "if name == ''" needed)
          is_pad = (name == '' and dt.type is numpy.void and dt.names is None)
          if not is_pad:
              fields.append((name, dt, offset))
  
          offset += dt.itemsize
  
      names, formats, offsets = zip(*fields)
      # names may be (title, names) tuples
      nametups = (n  if isinstance(n, tuple) else (None, n) for n in names)
      titles, names = zip(*nametups)
      return numpy.dtype({'names': names, 'formats': formats, 'titles': titles,
                          'offsets': offsets, 'itemsize': offset})
function_tokens: def descr_to_dtype ( descr ) : if isinstance ( descr , str ) : # No padding removal needed return numpy . dtype ( descr ) elif isinstance ( descr , tuple ) : # subtype, will always have a shape descr[1] dt = descr_to_dtype ( descr [ 0 ] ) return numpy . dtype ( ( dt , descr [ 1 ] ) ) fields = [ ] offset = 0 for field in descr : if len ( field ) == 2 : name , descr_str = field dt = descr_to_dtype ( descr_str ) else : name , descr_str , shape = field dt = numpy . dtype ( ( descr_to_dtype ( descr_str ) , shape ) ) # Ignore padding bytes, which will be void bytes with '' as name # Once support for blank names is removed, only "if name == ''" needed) is_pad = ( name == '' and dt . type is numpy . void and dt . names is None ) if not is_pad : fields . append ( ( name , dt , offset ) ) offset += dt . itemsize names , formats , offsets = zip ( * fields ) # names may be (title, names) tuples nametups = ( n if isinstance ( n , tuple ) else ( None , n ) for n in names ) titles , names = zip ( * nametups ) return numpy . dtype ( { 'names' : names , 'formats' : formats , 'titles' : titles , 'offsets' : offsets , 'itemsize' : offset } )