-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Labels
area/parametersparameter resolution, parameterized gates, operationsparameter resolution, parameterized gates, operationskind/healthFor CI/testing/release process/refactoring/technical debt itemsFor CI/testing/release process/refactoring/technical debt itemstriage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked onA consensus emerged that this bug report, feature request, or other action should be worked on
Description
Currently if you make a call like sampler.sample(circuit, params={'t': range(5)})
it doesn't work, because it expects e.g. a list of dictionaries instead of a dictionary containing lists. For convenience we should just support both cases. Check if the input is a dictionary with list values (and possibly singletons too), and if so take the cartesian product of the various entries and turn it into a sweep.
Test cases:
assert cirq.to_sweeps({'t': [0, 2, 3]}) == (
cirq.to_sweeps([{'t': 0}, {'t': 2}, {'t': 3}]}))
assert cirq.to_sweeps({'t': [0, 1], 's': [2, 3], 'r': 4}) == (
cirq.to_sweeps([
{'t': 0, 's': 2, 'r': 4},
{'t': 0, 's': 3, 'r': 4},
{'t': 1, 's': 2, 'r': 4},
{'t': 1, 's': 3, 'r': 4},
]))
Metadata
Metadata
Assignees
Labels
area/parametersparameter resolution, parameterized gates, operationsparameter resolution, parameterized gates, operationskind/healthFor CI/testing/release process/refactoring/technical debt itemsFor CI/testing/release process/refactoring/technical debt itemstriage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked onA consensus emerged that this bug report, feature request, or other action should be worked on