dimod.variables.Variables._relabel_as_integers

Variables._relabel_as_integers()[source]

Relabel the variables as integers in-place.

Returns

A mapping that will restore the original labels.

Return type

dict

Examples

>>> variables = dimod.variables.Variables(['a', 'b', 'c', 'd'])
>>> print(variables)
Variables(['a', 'b', 'c', 'd'])
>>> mapping = variables._relabel_as_integers()
>>> print(variables)
Variables([0, 1, 2, 3])
>>> variables._relabel(mapping)  # restore the original labels
>>> print(variables)
Variables(['a', 'b', 'c', 'd'])

This method is semi-public. it is intended to be used by classes that have Variables as an attribute, not by the the user.