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 (Numpy) –

  • dict

  • as returned by dimod samplers. (or) –

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)     
{0: 1, 1: 2, 2: 3}