dimod.SampleSet.relabel_variables#
- SampleSet.relabel_variables(mapping, inplace=True)[source]#
Relabel the variables of a
SampleSet
according to the specified mapping.- Parameters:
- Returns:
SampleSet with relabeled variables. If inplace is True, returns itself.
- Return type:
Notes
This function is non-blocking.
Examples
This example creates a relabeled copy of a
SampleSet
.>>> sampleset = dimod.ExactSolver().sample_ising({'a': -0.5, 'b': 1.0}, {('a', 'b'): -1}) >>> new_sampleset = sampleset.relabel_variables({'a': 0, 'b': 1}, inplace=False) >>> new_sampleset.variables Variables([0, 1])