hybrid.utils.updated_sample

updated_sample(sample, replacements)[source]

Update a copy of a sample with replacement values.

Parameters:
  • sample (list/dict) – Sample values as returned by dimod samplers to be copied.
  • replacements (list/dict) – Sample values to replace in the copied sample.
Returns:

Copy of sample overwritten by specified values.

Return type:

list/dict

Examples

>>> sample = {'a': 1, 'b': 1}
>>> updated_sample(sample, {'b': 2})       # doctest: +SKIP
{'a': 1, 'b': 2}