Skip to content

Expand SWEEP_LIKE to work for {'t': [0, 1, 3]} #2698

@Strilanc

Description

@Strilanc

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

Labels

area/parametersparameter resolution, parameterized gates, operationskind/healthFor CI/testing/release process/refactoring/technical debt itemstriage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions