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

  • samplers. (or as returned by dimod)

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}