Returns the indices for all datapoints in the given tensor.
353124
def datapoint_indices_for_tensor(self, tensor_index):
        
        if tensor_index >= self._num_tensors:
            raise ValueError('Tensor index %d is greater than the number of tensors (%d)' %(tensor_index, self._num_tensors))
        return self._file_num_to_indices[tensor_index]
73554
public static EdgeScores tensorToEdgeScores(Tensor t) {
        if (t.getDims().length != 2) {
            throw new IllegalArgumentException("Tensor must be an nxn matrix.");
        }
        int n = t.getDims()[1];
        EdgeScores es = new EdgeScores(n, 0);        
        for (int p = -1; p < n; p++) {
            for (int c = 0; c < n; c++) {
                if (p == c) { continue; }
                int pp = getTensorParent(p, c);
                es.setScore(p, c, t.get(pp, c));
            }
        }
        return es;
    }
820063
def indices(self, data):
        '''
        '''
        duration = self.data_duration(data)

        for start in range(0, duration - self.duration, self.stride):
            yield start
486272
def _get_index_list_of_values(d, k, def_value=None):
    """"""
    v = d.get(k, def_value)
    if v is None:
        return []
    if isinstance(v, list):
        return v
    return [v]
1195803
def index(self, axes):
        
        return None if axes is self._colormap_axes else self._axes.index(axes)
1303691
def get_dimension_indices(self, query):
        
        ids = self['id'] if self.get('id') else self['dimension']['id']
        indices = []

        for idx, id in enumerate(ids):
            indices.append(self.get_dimension_index(id,
                                                    [d.get(id) for d in query
                                                     if id in d][0]))

        return indices
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
1038750
def get_all_resources(datasets):
        # type: (List['Dataset']) -> List[hdx.data.resource.Resource]
        
        resources = []
        for dataset in datasets:
            for resource in dataset.get_resources():
                resources.append(resource)
        return resources
613254
def extract_indexes(coords):
    """"""
    for name, variable in coords.items():
        variable = as_variable(variable, name=name)
        if variable.dims == (name,):
            yield name, variable.to_index()
73297
def get_tensors(object_):
    
    if torch.is_tensor(object_):
        return [object_]
    elif isinstance(object_, (str, float, int)):
        return []

    tensors = set()

    if isinstance(object_, collections.abc.Mapping):
        for value in object_.values():
            tensors.update(get_tensors(value))
    elif isinstance(object_, collections.abc.Iterable):
        for value in object_:
            tensors.update(get_tensors(value))
    else:
        members = [
            value for key, value in inspect.getmembers(object_)
            if not isinstance(value, (collections.abc.Callable, type(None)))
        ]
        tensors.update(get_tensors(members))

    return tensors
601495
def get_ref_indices(self):
        

        ixn_obj = self
        ref_indices = []
        while ixn_obj != ixn_obj.root:
            ref_indices.append(ixn_obj.ref.split(':')[-1])
            ixn_obj = ixn_obj.parent
        return ref_indices[::-1]
116606
def pairwise_indices(self):
        """"""
        return np.array([sig.pairwise_indices for sig in self.values]).T
337135
def _get_indices(self, element, labels='all', mode='or'):
        
        """
        # Parse and validate all input values.
        element = self._parse_element(element, single=True)
        labels = self._parse_labels(labels=labels, element=element)
        if element+'.all' not in self.keys():
            raise Exception('Cannot proceed without {}.all'.format(element))

        # Begin computing label array
        if mode in ['or', 'any', 'union']:
            union = sp.zeros_like(self[element+'.all'], dtype=bool)
            for item in labels:  # Iterate over labels and collect all indices
                union = union + self[element+'.'+item.split('.')[-1]]
            ind = union
        elif mode in ['and', 'all', 'intersection']:
            intersect = sp.ones_like(self[element+'.all'], dtype=bool)
            for item in labels:  # Iterate over labels and collect all indices
                intersect = intersect*self[element+'.'+item.split('.')[-1]]
            ind = intersect
        elif mode in ['xor', 'exclusive_or']:
            xor = sp.zeros_like(self[element+'.all'], dtype=int)
            for item in labels:  # Iterate over labels and collect all indices
                info = self[element+'.'+item.split('.')[-1]]
                xor = xor + sp.int8(info)
            ind = (xor == 1)
        elif mode in ['nor', 'not', 'none']:
            nor = sp.zeros_like(self[element+'.all'], dtype=int)
            for item in labels:  # Iterate over labels and collect all indices
                info = self[element+'.'+item.split('.')[-1]]
                nor = nor + sp.int8(info)
            ind = (nor == 0)
        elif mode in ['nand']:
            nand = sp.zeros_like(self[element+'.all'], dtype=int)
            for item in labels:  # Iterate over labels and collect all indices
                info = self[element+'.'+item.split('.')[-1]]
                nand = nand + sp.int8(info)
            ind = (nand < len(labels)) * (nand > 0)
        elif mode in ['xnor', 'nxor']:
            xnor = sp.zeros_like(self[element+'.all'], dtype=int)
            for item in labels:  # Iterate over labels and collect all indices
                info = self[element+'.'+item.split('.')[-1]]
                xnor = xnor + sp.int8(info)
            ind = (xnor > 1)
        else:
            raise Exception('Unsupported mode: '+mode)
        # Extract indices from boolean mask
        ind = sp.where(ind)[0]
        ind = ind.astype(dtype=int)
        return ind
505575
def indices(self, includeChannel=True):
		
		if self.dimOrder == DimOrder.HeightWidthChannel:
			
			# Equivalent to [self.y:self.y+self.h+1, self.x:self.x+self.w+1]
			return (
				slice(self.y, self.y+self.h),
				slice(self.x, self.x+self.w)
			)
			
		elif self.dimOrder == DimOrder.ChannelHeightWidth:
			
			if includeChannel is True:
				
				# Equivalent to [:, self.y:self.y+self.h+1, self.x:self.x+self.w+1]
				return (
					slice(None, None),
					slice(self.y, self.y+self.h),
					slice(self.x, self.x+self.w)
				)
				
			else:
				
				# Equivalent to [self.y:self.y+self.h+1, self.x:self.x+self.w+1]
				return (
					slice(self.y, self.y+self.h),
					slice(self.x, self.x+self.w)
				)
			
		else:
			raise Error('Unsupported order of dimensions: ' + str(self.dimOrder))
630622
def set_datapoint(self, ind, datapoint):
        
        if ind >= self.num_datapoints:
            raise ValueError('Index %d out of bounds! Tensor has %d datapoints' %(ind, self.num_datapoints))
        self.data[ind, ...] = np.array(datapoint).astype(self.dtype)
830958
def _multi_deref(tensors: List[tf.Tensor], index: tf.Tensor) -> List[tf.Tensor]:
    
    assert tensors
    assert tensors[0].shape[0] > 0
    return _deref_helper(lambda i: [tensor[i, ...] for tensor in tensors],
                         index,
                         0,
                         tensors[0].shape[0] - 1)
1058793
def group_indices(self):
        
        # No groups
        if not self.plydata_groups:
            return np.ones(len(self), dtype=int)

        grouper = self.groupby()
        indices = np.empty(len(self), dtype=int)
        for i, (_, idx) in enumerate(sorted(grouper.indices.items())):
            indices[idx] = i
        return indices