Gives the indices for a trajectory file index (without changing the order within the trajectory itself).
        :param traj: a trajectory file index
        :return: a Nx1 - np.array of the indices corresponding to the trajectory index
190692
def ra_indices_for_traj(self, traj):
        
        assert not self.uniform_stride, "requested random access indices, but is in uniform stride mode"
        if traj in self.traj_keys:
            return self.ra_indices_for_traj_dict[traj]
        else:
            return np.array([])
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]
1062888
def _read_next_timestep(self, ts=None):
    """"""

    if self.ts.frame >= self.n_frames-1:
        raise IOError(errno.EIO, 'trying to go over trajectory limit')
    if ts is None:
        ts = self.ts
    ts.frame += 1

    self.zdock_inst._set_pose_num(ts.frame+1)
    ts._pos = self.zdock_inst.static_mobile_copy_uni.trajectory.ts._pos

    return ts
1208030
def ensure_traj(traj):
    

    """
    if is_float_matrix(traj) or is_bool_matrix(traj):
        return traj
    elif is_float_vector(traj):
        return traj[:,None]
    else:
        try:
            arr = np.array(traj)
            arr = ensure_dtype_float(arr)
            if is_float_matrix(arr):
                return arr
            if is_float_vector(arr):
                return arr[:,None]
            else:
                raise TypeError('Argument traj cannot be cast into a two-dimensional array. Check type.')
        except:
            raise TypeError('Argument traj is not a trajectory - only float-arrays or list of float-arrays are allowed. Types is %s' % type(traj))
100476
def pathFromIndex(self, index):
        
        out  = []
        while index and index.isValid():
            out.append(nativestring(unwrapVariant(index.data())))
            index = self._model.parent(index)
        
        return self.joiner().join(reversed(out))
758117
def lookup(self, coordinates):
        
        # Convert coordinates to indices
        index_array = np.clip(np.searchsorted(self.bin_edges, coordinates) - 1,
                              0,
                              len(self.bin_edges) - 2)

        # Use the index array to slice the histogram
        return self.histogram[index_array]
1305047
def point_to_index(self, point):
        
        indices = points_to_indices(points=[point],
                                    pitch=self.pitch,
                                    origin=self.origin)
        index = tuple(indices[0])
        return index
198474
def getIndices(self):
        """"""
        for indexName in self.neograph.nodes.indexes.keys():
            indexObject = self.neograph.nodes.indexes.get(indexName)
            yield Index(indexName, "vertex", "manual", indexObject)
        for indexName in self.neograph.relationships.indexes.keys():
            indexObject = self.neograph.relationships.indexes.get(indexName)
            yield Index(indexName, "edge", "manual", indexObject)
145746
def get_trajectories(self, index, rollout_length, history_length):
        
        indexes = np.arange(index - rollout_length + 1, index + 1, dtype=int)
        return self.get_transitions(indexes, history_length)
621723
def spaced_indexes(len_, n, trunc=False):
    

    if n is None:
        return np.arange(len_)
    all_indexes = np.arange(len_)
    if trunc:
        n = min(len_, n)
    if n == 0:
        return np.empty(0)
    stride = len_ // n
    try:
        indexes = all_indexes[0:-1:stride]
    except ValueError:
        raise ValueError('cannot slice list of len_=%r into n=%r parts' % (len_, n))
    return indexes
451941
def _indexes(arr):
    
    myarr = np.array(arr)
    if myarr.ndim == 1:
        return list(range(len(myarr)))
    elif myarr.ndim == 2:
        return tuple(itertools.product(list(range(arr.shape[0])),
                                       list(range(arr.shape[1]))))
    else:
        raise NotImplementedError('Only supporting arrays of dimension 1 and 2 as yet.')
1121933
def list_indexes(cls):
        

        cls_list = cls.list_mapped_classes()
        rtn_obj = {}
        for key, value in cls_list.items():
            idx = value.es_defs.get('kds_esIndex')[0]
            try:
                rtn_obj[idx].append(value)
            except KeyError:
                rtn_obj[idx] = [value]
        return rtn_obj
10524
def _get_array_index(array_path):
    

    if not array_path.startswith('@'):
        raise XJPathError('Array index must start from @ symbol.')
    array_path = array_path[1:]
    if array_path == 'last':
        return -1
    if array_path == 'first':
        return 0
    if array_path.isdigit() or (array_path.startswith('-')
                                and array_path[1:].isdigit()):
        return int(array_path)
    else:
        raise XJPathError('Unknown index reference', (array_path,))
188691
def iter_starts_with_index(self):
        """"""
        for i in range(1, len(self.endpoints)):
            yield i, self.get_coordinates(i)
480883
def get_trajectories(self, indexes, rollout_length):
        
        # assert indexes.shape[0] > 1, "There must be multiple indexes supplied"
        assert rollout_length > 1, "Rollout length must be greater than 1"

        batch_indexes = (
                indexes.reshape(1, indexes.shape[0]) - np.arange(rollout_length - 1, -1, -1).reshape(rollout_length, 1)
        )

        return self.get_transitions(batch_indexes)
4435
def remove_tracks(self, track_indices):
        
        if isinstance(track_indices, int):
            track_indices = [track_indices]
        self.tracks = [track for idx, track in enumerate(self.tracks)
                       if idx not in track_indices]
334020
def sample_trajectories(self, rollout_length, batch_info) -> Trajectories:
        
        indexes = self.backend.sample_batch_trajectories(rollout_length)
        transition_tensors = self.backend.get_trajectories(indexes, rollout_length)

        return Trajectories(
            num_steps=rollout_length,
            num_envs=self.backend.num_envs,
            environment_information=None,
            transition_tensors={k: torch.from_numpy(v) for k, v in transition_tensors.items()},
            rollout_tensors={}
        )