(self, key)
return key
Converts a named indexing expression to a numpy-friendly index.
Converts a named indexing expression to a numpy-friendly index.
Converts a named indexing expression to a numpy - friendly index .
def convert_key_item(self, key):
    """Converts a named indexing expression to a numpy-friendly index."""

    _validate_key_item(key)

    if isinstance(key, str):
      key = self._names_to_slices[util.to_native_string(key)]

    elif isinstance(key, (list, np.ndarray)):
      # We assume that either all or none of the items in the sequence are
      # strings representing names. If there is a mix, we will let NumPy throw
      # an error when trying to index with the returned key.
      if isinstance(key[0], str):
        new_key = []
        for k in key:
          idx = self._names_to_indices[util.to_native_string(k)]
          if isinstance(idx, int):
            new_key.append(idx)
          else:
            new_key.extend(idx)
        key = new_key

    return key
def convert_key_item ( self , key ) : _validate_key_item ( key ) if isinstance ( key , str ) : key = self . _names_to_slices [ util . to_native_string ( key ) ] elif isinstance ( key , ( list , np . ndarray ) ) : # We assume that either all or none of the items in the sequence are # strings representing names. If there is a mix, we will let NumPy throw # an error when trying to index with the returned key. if isinstance ( key [ 0 ] , str ) : new_key = [ ] for k in key : idx = self . _names_to_indices [ util . to_native_string ( k ) ] if isinstance ( idx , int ) : new_key . append ( idx ) else : new_key . extend ( idx ) key = new_key return key