dimod.higherorder.polynomial.BinaryPolynomial.energies#
- BinaryPolynomial.energies(samples_like, dtype=<class 'float'>)[source]#
Energies of the given samples.
- Parameters:
samples_like (samples_like) – A collection of raw samples. samples-like is an extension of NumPy’s array_like structure. See
as_samples()
.dtype (
numpy.dtype
, optional) – Data type of the returned energies. Defaults to float.
- Returns:
The energies.
- Return type:
Examples
>>> poly = dimod.BinaryPolynomial({('x', 'y'): -1, ('x', 'y', 'z'): 0.5}, ... 'BINARY') >>> samples = [{'x': 1, 'y': 1, 'z': 0}, ... {'x': 1, 'y': 1, 'z': 1}] >>> poly.energies(samples) array([-1. , -0.5])