@classmethod
    def sample(cls, dataset, samples=[]):
        ndims = dataset.ndims
        dimensions = dataset.dimensions(label=True)
        arrays = [dataset.data[vdim.name] for vdim in dataset.vdims]
        data = defaultdict(list)

        first_sample = util.wrap_tuple(samples[0])
        if any(len(util.wrap_tuple(s)) != len(first_sample) for s in samples):
            raise IndexError('Sample coordinates must all be of the same length.')

        for sample in samples:
            if np.isscalar(sample): sample = [sample]
            if len(sample) != ndims:
                sample = [sample[i] if i < len(sample) else None
                          for i in range(ndims)]
            sampled, int_inds = [], []
            for d, ind in zip(dimensions, sample):
                cdata = dataset.data[d]
                mask = cls.key_select_mask(dataset, cdata, ind)
                inds = np.arange(len(cdata)) if mask is None else np.argwhere(mask)
                int_inds.append(inds)
                sampled.append(cdata[mask])
            for d, arr in zip(dimensions, np.meshgrid(*sampled)):
                data[d].append(arr)
            for vdim, array in zip(dataset.vdims, arrays):
                flat_index = np.ravel_multi_index(tuple(int_inds), array.shape)
                data[vdim.name].append(array.flat[flat_index])
        concatenated = {d: np.concatenate(arrays).flatten() for d, arrays in data.items()}
        return concatenated
Convert a file of First Order Formulas into a list of {Expression}s.
dataset/ETHPy150Open ioam/holoviews/holoviews/core/data/grid.py/GridInterface.sample--crossover with--dataset/ETHPy150Open nltk/nltk/nltk/sem/logic.py/read_logic