Get the index of the requested dimension.

        Args:
            dimension: Dimension to look up by name or by index

        Returns:
            Integer index of the requested dimension
966455
def get_dimension_index(self, dimension):
        
        if isinstance(dimension, int):
            if (dimension < (self.ndims + len(self.vdims)) or
                dimension < len(self.dimensions())):
                return dimension
            else:
                return IndexError('Dimension index out of bounds')
        dim = dimension_name(dimension)
        try:
            dimensions = self.kdims+self.vdims
            return [i for i, d in enumerate(dimensions) if d == dim][0]
        except IndexError:
            raise Exception("Dimension %s not found in %s." %
                            (dim, self.__class__.__name__))
96247
def get_dimension(dimension_id, do_accept_dimension_id_none=False,**kwargs):
    
    if do_accept_dimension_id_none == True and dimension_id is None:
        # In this special case, the method returns a dimension with id None
        return get_empty_dimension()

    try:
        dimension = db.DBSession.query(Dimension).filter(Dimension.id==dimension_id).one()

        #lazy load units
        dimension.units

        return JSONObject(dimension)
    except NoResultFound:
        # The dimension does not exist
        raise ResourceNotFoundError("Dimension %s not found"%(dimension_id))
418352
def dimension(self):
        
        if self.dim > -1:
            return self.dim
        d = None
        if self.dim != -1 and not self._estimated:  # fixed parametrization
            d = self.dim
        elif self._estimated:  # parametrization finished. Dimension is known
            dim = len(self.eigenvalues)
            if self.var_cutoff < 1.0:  # if subspace_variance, reduce the  if needed
                dim = min(dim, np.searchsorted(self.cumvar, self.var_cutoff) + 1)
            d = dim
        elif self.var_cutoff == 1.0:  # We only know that all dimensions are wanted, so return input dim
            d = self.data_producer.dimension()
        else:  # We know nothing. Give up
            raise RuntimeError('Requested dimension, but the dimension depends on the cumulative variance and the '
                               'transformer has not yet been estimated. Call estimate() before.')
        return d
530169
def index(self, value):
        
        # pylint: disable=arguments-differ
        for idx, val in enumerate(self):
            if value == val:
                return idx
        raise ValueError('{0!r} is not in dict'.format(value))
396704
def get_empty_dimension(**kwargs):
    
    dimension = JSONObject(Dimension())
    dimension.id = None
    dimension.name = ''
    dimension.description = ''
    dimension.project_id = None
    dimension.units = []
    return dimension
330730
def getIndexedValue(self, index):
        
        actions = self._actions

        if (type (actions) is list):
            dict = actions[index]
        else:
            dict = actions
        return dict.get('value', 'NoValue')
849074
def get_dimension(data):
    
    result = [0, 0]

    if isinstance(data, list):
        result = get_dimension_array(data)

    elif isinstance(data, dict):
        result = get_dimension_dict(data)

    return result
1155660
def dimension(self):
        
        dim = sum(f.dimension for f in self.active_features)
        return dim
120506
def index(self, header):
        
        rv = self.find(header)
        if rv < 0:
            raise IndexError(header)
        return rv
521203
def get_index_by_id(self, id):
        """"""
        for i in range(len(self.vertices)):
            if self.vertices[i].id == id:
                return i
        raise ValueError('Reverse look up of id failed.')
824165
def mr_dim_ind(self):
        """"""
        mr_dim_ind = self._cube.mr_dim_ind
        if self._cube.ndim == 3:
            if isinstance(mr_dim_ind, int):
                if mr_dim_ind == 0:
                    # If only the 0th dimension of a 3D is an MR, the sliced
                    # don't actuall have the MR... Thus return None.
                    return None
                return mr_dim_ind - 1
            elif isinstance(mr_dim_ind, tuple):
                # If MR dimension index is a tuple, that means that the cube
                # (only a 3D one if it reached this path) has 2 MR dimensions.
                # If any of those is 0 ind dimension we don't need to include
                # in the slice dimension (because the slice doesn't see the tab
                # that it's on). If it's 1st and 2nd dimension, then subtract 1
                # from those, and present them as 0th and 1st dimension of the
                # slice. This can happend e.g. in a CAT x MR x MR cube (which
                # renders MR x MR slices).
                mr_dim_ind = tuple(i - 1 for i in mr_dim_ind if i)
                return mr_dim_ind if len(mr_dim_ind) > 1 else mr_dim_ind[0]

        return mr_dim_ind
840656
def _valid_dimensions(self, dimensions):
        """"""
        if dimensions is None:
            dimensions = self.kdims
        elif not isinstance(dimensions, list):
            dimensions = [dimensions]

        valid_dimensions = []
        for dim in dimensions:
            if isinstance(dim, Dimension): dim = dim.name
            if dim not in self.kdims:
                raise Exception("Supplied dimensions %s not found." % dim)
            valid_dimensions.append(dim)
        return valid_dimensions
1080956
def _sumindex(self, index=None):
        """"""
        try:
            ndim = len(index)
        except TypeError:
            # turn index into a 1-tuple
            index = (index,)
            ndim = 1
        if len(self.shape) != ndim:
            raise ValueError("Index to %d-dimensional array %s has too %s dimensions" %
                (len(self.shape), self.name, ["many","few"][len(self.shape) > ndim]))
        sumindex = 0
        for i in range(ndim-1,-1,-1):
            index1 = index[i]
            if index1 < 0 or index1 >= self.shape[i]:
                raise ValueError("Dimension %d index for array %s is out of bounds (value=%d)" %
                    (i+1, self.name, index1))
            sumindex = index1 + sumindex*self.shape[i]
        return sumindex
1307722
def _get_index(self):
        
        glyph = self.glyph
        if glyph is None:
            return None
        return glyph.anchors.index(self)
652841
def _get_index(self, index=None):
        

        if self.is_freq_type:
            if index is None:
                index = self._on
            return index, index.asi8
        return index, index
305837
def sub_dimension(self, index, dimension, propagate=True, inplace=False):
        
        filter_ = self._propagate_dim(index, dimension, propagate)
        return self.subindex(filter_, inplace)
161219
def get_property(self, index, doctype, name):
        

        return self.indices[index][doctype].properties[name]