question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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},
    ]))

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kevinsungcommented, Aug 21, 2020

Note that Sampler.sample actually does use to_sweeps, so it does work with this feature. So as it stands, this feature is inconsistently implemented.

1reaction
maffoocommented, Aug 21, 2020

I think we decided not to do this so that you can resolve list-valued parameters (we have use cases for this internally). Also, there’s an ambiguity if you have multiple parameters; given {'a': [1, 2], 'b': [3, 4]} should that do a cartesian product sweep over a and b or a zip sweep? Instead you need to make the sweep explicit at the top level, either as [{'t': 0.3}, {'t': 0.5}] or using actual sweep objects: cirq.Points('t', [0.3, 0.5]).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sweep-like operations with dplyr/tidyverse - Stack Overflow
I don't think it is important to know given the context, but my data has 77 rows and 1133 columns. Four of the...
Read more >
When You Use The Wrong EV Spread on Pokemon ...
When You Use The Wrong EV Spread on Pokemon Showdown...Pokemon Showdown has never seen a sweep like this before :)xImRaptor vs TJ in...
Read more >
Distinguishing Between Selective Sweeps and Demography ...
In 2002 Kim and Stephan proposed a promising composite-likelihood method for localizing and estimating the fitness advantage of a recently fixed beneficial ...
Read more >
Decay of Solar Wind Turbulence behind Interplanetary Shocks
Solutions of these equations lead to power laws, $E\approx {(t-{t}_{0}) ... and the sweep-like dynamics associated with wave propagation is spread out (Zhou ......
Read more >
Amplification of integrated microscopic motions of high-density ...
The pioneering work of rotaxane-based molecular muscle was reported ... On the one hand, the aromatic protons H1 and H3 of B21C7 wheel...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found