hybrid.utils.sample_as_dict

sample_as_dict(sample)[source]

Return sample object in dict format.

Parameters:
  • sample (list/dict/dimod.SampleView) – Sample object formatted as a list,
  • array, dict, or as returned by dimod samplers. (Numpy) –
Returns:

Copy of sample formatted as a dict, with variable indices as keys.

Return type:

list

Examples

>>> sample = [1, 2, 3]
>>> sample_as_dict(sample)     # doctest: +SKIP
{0: 1, 1: 2, 2: 3}