Sub-classes to define. Return a sliced object.

        Parameters
        ----------
        key : string / list of selections
        ndim : 1,2
            requested ndim of result
        subset : object, default None
            subset to act on
969751
def _gotitem(self,
                 key: Union[str, List[str]],
                 ndim: int,
                 subset: Optional[Union[Series, ABCDataFrame]] = None,
                 ) -> Union[Series, ABCDataFrame]:
        
        if subset is None:
            subset = self
        elif subset.ndim == 1:  # is Series
            return subset

        # TODO: _shallow_copy(subset)?
        return subset[key]
152966
def _get_range_dimension_key(self,
                                 base_key: Key,
                                 start_time: datetime,
                                 end_time: datetime,
                                 count: int = 0) -> List[Tuple[Key, Any]]:
        
        raise NotImplementedError()
193960
def _handle_result_by_key(self, key):
        
        invalid_options = ('key', 'keys', 'startkey', 'endkey')
        if any(x in invalid_options for x in self.options):
            raise ResultException(102, invalid_options, self.options)
        return self._ref(key=key, **self.options)
75828
def split_key(key):
    """"""
    if key == KEY_SEP:
        return ()
    key_chunks = tuple(key.strip(KEY_SEP).split(KEY_SEP))
    if key_chunks[0].startswith(KEY_SEP):
        return (key_chunks[0][len(KEY_SEP):],) + key_chunks[1:]
    else:
        return key_chunks
1112220
@Override
  public SparseTensor slice(int[] dimensionNumbers, int[] key) {
    if (dimensionNumbers.length == 0) {
      return this;
    }
    // Check for an efficient case, where the dimensions are the first
    // elements of this.
    if (ArrayUtils.subarrayEquals(getDimensionNumbers(), dimensionNumbers, 0)) {
      long minKeyInt = 0;
      int numDimensions = dimensionNumbers.length;
      for (int i = 0; i < numDimensions; i++) {
        minKeyInt += indexOffsets[i] * key[i];
      }
      long maxKeyInt = minKeyInt + indexOffsets[numDimensions - 1];

      int startIndex = getNearestIndex(minKeyInt);
      int endIndex = getNearestIndex(maxKeyInt);

      long[] newKeyInts = ArrayUtils.copyOfRange(keyNums, startIndex, endIndex);
      int numKeyInts = newKeyInts.length;
      for (int i = 0; i < numKeyInts; i++) {
        newKeyInts[i] -= minKeyInt;
      }

      int[] newDimensionNumbers = ArrayUtils.copyOfRange(getDimensionNumbers(), dimensionNumbers.length, getDimensionNumbers().length);
      int[] newDimensionSizes = ArrayUtils.copyOfRange(getDimensionSizes(), dimensionNumbers.length, getDimensionSizes().length);
      double[] newValues = ArrayUtils.copyOfRange(values, startIndex, endIndex);
      return new SparseTensor(newDimensionNumbers, newDimensionSizes, newKeyInts, newValues);
    }

    // TODO(jayantk): This is an extremely naive implementation of
    // slice.
    // Figure out the appropriate sizes for the subset of dimensions.
    int[] dimensionSizes = new int[dimensionNumbers.length];
    for (int i = 0; i < dimensionNumbers.length; i++) {
      int dimIndex = getDimensionIndex(dimensionNumbers[i]);
      Preconditions.checkArgument(dimIndex >= 0);
      dimensionSizes[i] = getDimensionSizes()[dimIndex];
    }
    SparseTensorBuilder builder = new SparseTensorBuilder(dimensionNumbers, dimensionSizes);
    builder.put(key, 1.0);
    return elementwiseProduct(builder.build()).sumOutDimensions(Ints.asList(dimensionNumbers));
  }
742732
def get(self, key, default=None):
        
        """
        segments = key.split('.')
        result = reduce(
            lambda dct, k: dct and dct.get(k) or None,
            segments, self.data)

        return result or default
1184188
def choose(key, *choices)
    all_choices = choices.flatten
    index = (get_unit(key) * all_choices.length).floor
    index = all_choices.length - 1 if index > all_choices.length - 1
    all_choices[index]
  end
1353288
def get_index(self, key: Hashable) -> pd.Index:
        
        if key not in self.dims:
            raise KeyError(key)

        try:
            return self.indexes[key]
        except KeyError:
            # need to ensure dtype=int64 in case range is empty on Python 2
            return pd.Index(range(self.sizes[key]), name=key, dtype=np.int64)
855062
def get(self):
        
        section = {}
        if self.key is not None and self.value is not None:
            section[self.key] = self.value
        return section
263972
def from_key(key):
    
    model = get_model_from_key(key)
    if model is None:
        raise BadKeyError
    try:
        _, id = key.split(':', 2)
        id = int(id)
    except ValueError, TypeError:
        raise BadKeyError
    return model.objects.get_by_id(id)
666374
def _collection(self, key):
    ''''''
    collection = str(key.path)
    if not collection in self._items:
      self._items[collection] = dict()
    return self._items[collection]
1207384
def get(self, key, index=None):
        
        records = self.get_multi([key], index=index)

        try:
            return records[0][1]  # return the value from the key/value tuple
        except IndexError:
            return None
1110358
def _dict_subset(keys, master_dict):
    '''
    
    '''
    return dict([(k, v) for k, v in six.iteritems(master_dict) if k in keys])
689393
def keys(self):
        " "
        if self.ndims == 1:
            return [k[0] for k in self.data.keys()]
        else:
            return list(self.data.keys())
1104460
def get_all(self, key: str) -> List[str]:
        
        return self._dict.get(key.lower(), [])
900122
def _slice(self, slicer):
        

        # only allow 1 dimensional slicing, but can
        # in a 2-d case be passd (slice(None),....)
        if isinstance(slicer, tuple) and len(slicer) == 2:
            if not com.is_null_slice(slicer[0]):
                raise AssertionError("invalid slicing for a 1-ndim "
                                     "categorical")
            slicer = slicer[1]

        codes = self._codes[slicer]
        return self._constructor(values=codes, dtype=self.dtype, fastpath=True)
608645
def component_by_key(self, key):
        
        filtered = [c for c in self.components if c.key == key]
        if filtered:
            return filtered[0]
        return None