dimod.higherorder.polynomial.BinaryPolynomial.relabel_variables#
- BinaryPolynomial.relabel_variables(mapping, inplace=True)[source]#
Relabel variables of a binary polynomial as specified by mapping.
- Parameters:
- Returns:
A binary polynomial with the variables relabeled. If inplace is set to True, returns itself.
- Return type:
Examples
>>> poly = dimod.BinaryPolynomial({('x', 'y'): -1, ('x', 'y', 'z'): 0.5}, ... 'BINARY') >>> poly2 = poly.relabel_variables({'x': 'k', 'y': 'l'}, inplace=False) >>> 'k' in poly2.variables and 'z' in poly2.variables True