Sub-classes to define. Return a sliced object.

        Parameters
        ----------
        key : str / list of selections
        ndim : 1,2
            requested ndim of result
        subset : object, default None
            subset to act on
557730
def _gotitem(self, key, ndim, subset=None):
        

        # create a new object to prevent aliasing
        if subset is None:
            subset = self.obj
        self = self._shallow_copy(subset)
        self._reset_cache()
        if subset.ndim == 2:
            if is_scalar(key) and key in subset or is_list_like(key):
                self._selection = key
        return self
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]
293716
def pick(source, keys, *, transform=None):
  
  check = keys if callable(keys) else lambda key: key in keys
  return {key: transform(source[key]) if transform else source[key]
          for key in source if check(key)}
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)
424944
def is_slice_or_dim_range_request(key, depth=0):
    '''
    
    '''
    # Slice, DimensionRange, or list of those elements
    return (is_slice_or_dim_range(key) or
            # Don't check more than the first depth
            (depth == 0 and non_str_len_no_throw(key) > 0 and
             all(is_slice_or_dim_range_request(subkey, depth+1) for subkey in key)))
740556
def wrap_key(self, key):
        
        return tuple(np.round(
            self.integer_cell.shortest_vector(key)
        ).astype(int))
43143
def getitem_row_array(self, key):
        
        # Convert to list for type checking
        key = list(key)

        def getitem(df, internal_indices=[]):
            return df.iloc[internal_indices]

        result = self.data.apply_func_to_select_indices(
            1, getitem, key, keep_remaining=False
        )
        # We can't just set the index to key here because there may be multiple
        # instances of a key.
        new_index = self.index[key]
        return self.__constructor__(result, new_index, self.columns, self._dtype_cache)
477262
def within(self, key, include_self=True, exclusive=False, biggest_first=True, only=None):
        
        possibles = self.topology if only is None else {k: self[k] for k in only}
        _ = lambda key: [key] if key in possibles else []
        if 'RoW' not in self and key == 'RoW':
            answer = [] + _('RoW') + _('GLO')
            return list(reversed(answer)) if biggest_first else answer

        faces = self[key]
        lst = [
            (k, len(v))
            for k, v in possibles.items()
            if faces.issubset(v)
        ]
        return self._finish_filter(lst, key, include_self, exclusive, biggest_first)
930756
def get(self, key, default=_sentinel):
        
        if default is _sentinel:
            default = HyperParams({})
        return self.__dict__[key] if key in self.__dict__ else default
236594
function(subset, key) {
            return [
              key.nRow(),
              key.nCol(),
              key.at(0, 'D'),
              key.at(0, 'C'),
            ];
          }
1205662
def key(self, key=""):
    
    params = join_params(self.parameters, {"key": key})

    return self.__class__(**params)
1323832
def _get(self, key, section=None, default=_onion_dict_guard):
        
        if section is not None:
            section_dict = self.__sections.get(section, {})
            if key in section_dict:
                return section_dict[key]
        for d in self.__dictionaries:
            if key in d:
                return d[key]
        if default is _onion_dict_guard:
            raise KeyError(key)
        else:
            return default
180425
def _convert_key(self, key, is_setter=False):
        

        # allow arbitrary setting
        if is_setter:
            return list(key)

        for ax, i in zip(self.obj.axes, key):
            if ax.is_integer():
                if not is_integer(i):
                    raise ValueError("At based indexing on an integer index "
                                     "can only have integer indexers")
            else:
                if is_integer(i) and not ax.holds_integer():
                    raise ValueError("At based indexing on an non-integer "
                                     "index can only have non-integer "
                                     "indexers")
        return key
81004
def _get_list_key(self, obj, key, vc, obj_nex_id=None):
        
        k = obj.get(key)
        if k is None:
            return None
        if isinstance(k, dict):
            k = [k]
        if not isinstance(k, list):
            self._error_event(vc.curr_element_type,
                              obj=obj,
                              err_type=gen_MissingExpectedListWarning,
                              anc=vc.anc_list,
                              obj_nex_id=obj_nex_id,
                              key_list=[key, ])
            return None
        return k
554539
def _sliced_list(self, selector):
        
        if self.skipmissing:
            return self.obj[selector]

        # TODO: can be optimized by observing list bounds
        keys = xrange(selector.start or 0,
                      selector.stop or sys.maxint,
                      selector.step or 1)
        res = []
        for key in keys:
            self._append(self.obj, key, res, skipmissing=False)
        return res
870504
def _transform_indices(self, key):
        
        ndims = self.ndims
        if all(not (isinstance(el, slice) or callable(el)) for el in key):
            dim_inds = []
            for dim in self.kdims:
                dim_type = self.get_dimension_type(dim)
                if isinstance(dim_type, type) and issubclass(dim_type, Number):
                    dim_inds.append(self.get_dimension_index(dim))
            str_keys = iter(key[i] for i in range(self.ndims)
                            if i not in dim_inds)
            num_keys = []
            if len(dim_inds):
                keys = list({tuple(k[i] if ndims > 1 else k for i in dim_inds)
                             for k in self.keys()})
                q = np.array([tuple(key[i] if ndims > 1 else key for i in dim_inds)])
                idx = np.argmin([np.inner(q - np.array(x), q - np.array(x))
                                 if len(dim_inds) == 2 else np.abs(q-x)
                                     for x in keys])
                num_keys = iter(keys[idx])
            key = tuple(next(num_keys) if i in dim_inds else next(str_keys)
                        for i in range(self.ndims))
        elif any(not (isinstance(el, slice) or callable(el)) for el in key):
            keys = self.keys()
            for i, k in enumerate(key):
                if isinstance(k, slice):
                    continue
                dim_keys = np.array([ke[i] for ke in keys])
                if dim_keys.dtype.kind in 'OSU':
                    continue
                snapped_val = dim_keys[np.argmin(np.abs(dim_keys-k))]
                key = list(key)
                key[i] = snapped_val
            key = tuple(key)
        return key
935897
def make_slice_strings(cls, slice_key):
        
        start = slice_key.start
        size = slice_key.stop - start
        return (str(start), str(size))