By default, this method invokes run synchronously and simply exposes
its result is an awaitable. Child classes that are capable of true
asynchronous sampling should override it to use other strategies.
Each circuit provided in programs will pair with the optional
associated parameter sweep provided in the params_list, and be run
with the associated repetitions provided in repetitions (if
repetitions is an integer, then all runs will have that number of
repetitions). If params_list is specified, then the number of
circuits is required to match the number of sweeps. Similarly, when
repetitions is a list, the number of circuits is required to match
the length of this list.
By default, this method simply invokes run_sweep sequentially for
each (circuit, parameter sweep, repetitions) tuple. Child classes that
are capable of sampling batches more efficiently should override it to
use other strategies. Note that child classes may have certain
requirements that must be met in order for a speedup to be possible,
such as a constant number of repetitions being used for all circuits.
Refer to the documentation of the child class for any such requirements.
The circuits to execute as a batch.
Parameter sweeps to use with the circuits. The number
of sweeps should match the number of circuits and will be
paired in order with the circuits.
Number of circuit repetitions to run. Can be specified
as a single value to use for all runs, or as a list of values,
one for each circuit.
A list of lists of TrialResults. The outer list corresponds to
the circuits, while each inner list contains the TrialResults
for the corresponding circuit, in the order imposed by the
associated parameter sweep.
Asynchronously sweeps and samples from the given Circuit.
By default, this method invokes run_sweep synchronously and simply
exposes its result is an awaitable. Child classes that are capable of
true asynchronous sampling should override it to use other strategies.
The circuit to sample from.
One or more mappings from parameter keys to parameter values
to use. For each parameter assignment, repetitions samples
will be taken.
Samples the given Circuit, producing a pandas data frame.
The circuit to sample from.
The number of times to sample the program, for each
Maps symbols to one or more values. This argument can be
a dictionary, a list of dictionaries, a cirq.Sweep, a list of
cirq.Sweep, etc. The program will be sampled repetition
times for each mapping. Defaults to a single empty mapping.
A pandas.DataFrame with a row for each sample, and a column for
each measurement key as well as a column for each symbolic
parameter. Measurement results are stored as a big endian integer
representation with one bit for each measured qubit in the key.
See cirq.big_endian_int_to_bits and similar functions for how
to convert this integer into bits.
There is an also index column containing the repetition number,
for each parameter assignment.
a, b, c = cirq.LineQubit.range(3)sampler = cirq.Simulator()circuit = cirq.Circuit(cirq.X(a), cirq.measure(a, key='out'))print(sampler.sample(circuit, repetitions=4)) out0 11 12 13 1