Returned solutions and samples are described under Binary Quadratic Models.

sample_like Objects

as_samples(samples_like[, dtype, copy, order])

Convert a samples_like object to a NumPy array and list of labels.


class SampleSet(record, variables, info, vartype)[source]

Samples and any other data returned by dimod samplers.

  • record (numpy.recarray) – A NumPy record array. Must have ‘sample’, ‘energy’ and ‘num_occurrences’ as fields. The ‘sample’ field should be a 2D NumPy array where each row is a sample and each column represents the value of a variable.

  • variables (iterable) – An iterable of variable labels, corresponding to columns in record.samples.

  • info (dict) – Information about the SampleSet as a whole, formatted as a dict.

  • vartype (Vartype/str/set) –

    Variable type for the SampleSet. Accepted input values:

    • Vartype.SPIN, 'SPIN', {-1, 1}

    • Vartype.BINARY, 'BINARY', {0, 1}

    • ExtendedVartype.DISCRETE, 'DISCRETE'


This example creates a SampleSet out of a samples_like object (a NumPy array).

>>> import numpy as np
>>> sampleset =  dimod.SampleSet.from_samples(np.ones(5, dtype='int8'),
...                                           'BINARY', 0)
>>> sampleset.variables
Variables([0, 1, 2, 3, 4])



Sample with the lowest-energy.

Dict of information about the SampleSet as a whole.


numpy.recarray containing the samples, energies, number of occurences, and other sample data.


Variables of variable labels.


Vartype of the samples.



Create a new SampleSet with repeated samples aggregated.

SampleSet.append_variables(samples_like[, ...])

Deprecated in favor of dimod.append_variables.

SampleSet.change_vartype(vartype[, ...])

Return the SampleSet with the given vartype.


Create a shallow copy.[fields, sorted_by, name, ...])

Iterate over the data in the SampleSet.


Return True if a pending computation is done.


Return a new sampleset with rows filtered by the given predicate.

SampleSet.from_future(future[, result_hook])

Construct a SampleSet referencing the result of a future computation.

SampleSet.from_samples(samples_like, ...[, ...])

Build a SampleSet from raw samples.

SampleSet.from_samples_bqm(samples_like, ...)

Build a sample set from raw samples and a binary quadratic model.


Deserialize a SampleSet.

SampleSet.lowest([rtol, atol])

Return a sample set containing the lowest-energy samples.


Ensure that the sampleset is resolved if constructed from a future.

SampleSet.relabel_variables(mapping[, inplace])

Relabel the variables of a SampleSet according to the specified mapping.

SampleSet.samples([n, sorted_by])

Return an iterable over the samples.

SampleSet.slice(*slice_args, **kwargs)

Create a new sample set with rows sliced according to standard Python slicing syntax.


Convert a sample set to a Pandas DataFrame

SampleSet.to_serializable([use_bytes, ...])

Convert a SampleSet to a serializable object.

SampleSet.truncate(n[, sorted_by])

Create a new sample set with up to n rows.

Utility Functions

append_data_vectors(sampleset, **vectors)

Create a new SampleSet with additional fields in SampleSet.record.

append_variables(sampleset, samples_like[, ...])

Create a new SampleSet with the given variables and values.

concatenate(samplesets[, defaults])

Combine sample sets.

drop_variables(sampleset, variables)

Return a new sample set with the given variables removed.

keep_variables(sampleset, variables)

Return a new sample set with only the given variables.