text stringlengths 81 112k |
|---|
Crosses two W flips over a partial CZ.
[Where W(a) is shorthand for PhasedX(phase_exponent=a).]
Uses the following identity:
───W(a)───@─────
│
───W(b)───@^t───
≡ ──────────@────────────W(a)───
│ (single-cross top W over CZ)
... |
Validates that a probability is between 0 and 1 inclusively.
Args:
p: The value to validate.
p_str: What to call the probability in error messages.
Returns:
The probability p if the probability if valid.
Raises:
ValueError if the probability is invalid.
def validate_proba... |
Returns a phased version of the effect.
For example, an X gate phased by 90 degrees would be a Y gate.
This works by calling `val`'s _phase_by_ method and returning
the result.
Args:
val: The value to describe with a unitary matrix.
phase_turns: The amount to phase the gate, in fractio... |
Returns a list of operations apply this gate to each of the targets.
Args:
*targets: The qubits to apply this gate to.
Returns:
Operations applying this gate to the target qubits.
Raises:
ValueError if targets are not instances of Qid.
def on_each(self, *t... |
Returns an Engine instance configured using environment variables.
If the environment variables are set, but incorrect, an authentication
failure will occur when attempting to run jobs on the engine.
Required Environment Variables:
QUANTUM_ENGINE_PROJECT: The name of a google cloud project, with t... |
Plot the state histogram from a single result with repetitions.
States is a bitstring representation of all the qubit states in a single
result.
Currently this function assumes each measurement gate applies to only
a single qubit.
Args:
result: The trial results to plot.
Returns:
... |
Converts sweep into an equivalent protobuf representation.
def sweep_to_proto_dict(sweep: Sweep, repetitions: int=1) -> Dict:
"""Converts sweep into an equivalent protobuf representation."""
msg = {} # type: Dict
if not sweep == UnitSweep:
sweep = _to_zip_product(sweep)
msg['sweep'] = {
... |
Converts sweep to a product of zips of single sweeps, if possible.
def _to_zip_product(sweep: Sweep) -> Product:
"""Converts sweep to a product of zips of single sweeps, if possible."""
if not isinstance(sweep, Product):
sweep = Product(sweep)
if not all(isinstance(f, Zip) for f in sweep.factors):
... |
Implementation of `SupportsApproximateEquality` protocol.
def _approx_eq_(self, other: Any, atol: float) -> bool:
"""Implementation of `SupportsApproximateEquality` protocol."""
if not isinstance(other, type(self)):
return NotImplemented
#self.value = value % period in __init__() c... |
Removes redundant acquaintance opportunities.
def remove_redundant_acquaintance_opportunities(
strategy: circuits.Circuit) -> int:
"""Removes redundant acquaintance opportunities."""
if not is_acquaintance_strategy(strategy):
raise TypeError('not is_acquaintance_strategy(circuit)')
qubits ... |
Runs the supplied Circuit or Schedule, mimicking quantum hardware.
In contrast to run, this allows for sweeping over different parameter
values.
Args:
program: The circuit or schedule to simulate.
params: Parameters to run with the program.
repetitions: The ... |
Run a simulation, mimicking quantum hardware.
Args:
circuit: The circuit to simulate.
param_resolver: Parameters to run with the program.
repetitions: Number of times to repeat the run.
Returns:
A dictionary from measurement gate key to measurement
... |
Computes SamplesDisplays in the supplied Circuit or Schedule.
Args:
program: The circuit or schedule to simulate.
param_resolver: Parameters to run with the program.
Returns:
ComputeDisplaysResult for the simulation.
def compute_samples_displays(
self,
... |
Computes SamplesDisplays in the supplied Circuit or Schedule.
In contrast to `compute_displays`, this allows for sweeping
over different parameter values.
Args:
program: The circuit or schedule to simulate.
params: Parameters to run with the program.
Returns:
... |
Simulates the supplied Circuit or Schedule.
This method returns a result which allows access to the entire
wave function.
Args:
program: The circuit or schedule to simulate.
param_resolver: Parameters to run with the program.
qubit_order: Determines the cano... |
Simulates the supplied Circuit or Schedule.
This method returns a result which allows access to the entire
wave function. In contrast to simulate, this allows for sweeping
over different parameter values.
Args:
program: The circuit or schedule to simulate.
param... |
Simulates the supplied Circuit or Schedule.
This method returns a result which allows access to the entire
wave function. In contrast to simulate, this allows for sweeping
over different parameter values.
Args:
program: The circuit or schedule to simulate.
param... |
Returns an iterator of StepResults for each moment simulated.
If the circuit being simulated is empty, a single step result should
be returned with the state being set to the initial state.
Args:
circuit: The Circuit to simulate.
param_resolver: A ParamResolver for dete... |
Iterator over StepResult from Moments of a Circuit.
Args:
circuit: The circuit to simulate.
param_resolver: A ParamResolver for determining values of
Symbols.
qubit_order: Determines the canonical ordering of the qubits. This
is often used in ... |
This method can be overridden to creation of a trial result.
Args:
params: The ParamResolver for this trial.
measurements: The measurement results for this trial.
final_simulator_state: The final state of the simulator for the
StepResult.
Returns:
... |
Samples from the system at this point in the computation.
Note that this does not collapse the wave function.
Args:
qubits: The qubits to be sampled in an order that influence the
returned measurement results.
repetitions: The number of samples to take.
... |
Samples from the system at this point in the computation.
Note that this does not collapse the wave function.
In contrast to `sample` which samples qubits, this takes a list of
`cirq.GateOperation` instances whose gates are `cirq.MeasurementGate`
instances and then returns a mapping fr... |
Decomposition ignores connectivity.
def xor_nonlocal_decompose(qubits: Iterable[raw_types.Qid],
onto_qubit: raw_types.Qid
) -> Iterable[raw_types.Operation]:
"""Decomposition ignores connectivity."""
for qubit in qubits:
if qubit != onto_qubit:
... |
Overrides sympy and numpy returning repr strings that don't parse.
def proper_repr(value: Any) -> str:
"""Overrides sympy and numpy returning repr strings that don't parse."""
if isinstance(value, sympy.Basic):
result = sympy.srepr(value)
# HACK: work around https://github.com/sympy/sympy/iss... |
Runs a Rabi oscillation experiment.
Rotates a qubit around the x-axis of the Bloch sphere by a sequence of Rabi
angles evenly spaced between 0 and max_angle. For each rotation, repeat
the circuit a number of times and measure the average probability of the
qubit being in the |1> state.
Args:
... |
Clifford-based randomized benchmarking (RB) of a single qubit.
A total of num_circuits random circuits are generated, each of which
contains a fixed number of single-qubit Clifford gates plus one
additional Clifford that inverts the whole sequence and a measurement in
the z-basis. Each circuit is repea... |
Clifford-based randomized benchmarking (RB) of two qubits.
A total of num_circuits random circuits are generated, each of which
contains a fixed number of two-qubit Clifford gates plus one additional
Clifford that inverts the whole sequence and a measurement in the
z-basis. Each circuit is repeated a n... |
Single-qubit state tomography.
The density matrix of the output state of a circuit is measured by first
doing projective measurements in the z-basis, which determine the
diagonal elements of the matrix. A X/2 or Y/2 rotation is then added before
the z-basis measurement, which determines the imaginary a... |
r"""Two-qubit state tomography.
To measure the density matrix of the output state of a two-qubit circuit,
different combinations of I, X/2 and Y/2 operations are applied to the
two qubits before measurements in the z-basis to determine the state
probabilities P_00, P_01, P_10.
The density matrix r... |
Generates a two-qubit Clifford gate.
An integer (idx) from 0 to 11519 is used to generate a two-qubit Clifford
gate which is constructed with single-qubit X and Y rotations and CZ gates.
The decomposition of the Cliffords follow those described in the appendix
of Barends et al., Nature 508, 500.
T... |
Returns a sequence of tuple pairs with the first item being a Rabi
angle and the second item being the corresponding excited state
probability.
def data(self) -> Sequence[Tuple[float, float]]:
"""Returns a sequence of tuple pairs with the first item being a Rabi
angle and the second ite... |
Plots excited state probability vs the Rabi angle (angle of rotation
around the x-axis).
Args:
**plot_kwargs: Arguments to be passed to matplotlib.pyplot.plot.
def plot(self, **plot_kwargs: Any) -> None:
"""Plots excited state probability vs the Rabi angle (angle of rotation
... |
Returns a sequence of tuple pairs with the first item being a
number of Cliffords and the second item being the corresponding average
ground state probability.
def data(self) -> Sequence[Tuple[int, float]]:
"""Returns a sequence of tuple pairs with the first item being a
number of Cliff... |
Plots the average ground state probability vs the number of
Cliffords in the RB study.
Args:
**plot_kwargs: Arguments to be passed to matplotlib.pyplot.plot.
def plot(self, **plot_kwargs: Any) -> None:
"""Plots the average ground state probability vs the number of
Cliffords... |
Raises a matrix with two opposing eigenvalues to a power.
Args:
reflection_matrix: The matrix to raise to a power.
exponent: The power to raise the matrix to.
Returns:
The given matrix raised to the given power.
def reflection_matrix_pow(reflection_matrix: np.ndarray, exponent: float)... |
Phases the given matrices so that they agree on the phase of one entry.
To maximize precision, the position with the largest entry from one of the
matrices is used when attempting to compute the phase difference between
the two matrices.
Args:
a: A numpy array.
b: Another numpy array.
... |
Left-multiplies the given axes of the target tensor by the given matrix.
Note that the matrix must have a compatible tensor structure.
For example, if you have an 6-qubit state vector `input_state` with shape
(2, 2, 2, 2, 2, 2), and a 2-qubit unitary operation `op` with shape
(2, 2, 2, 2), and you wan... |
r"""Conjugates the given tensor about the target tensor.
This method computes a target tensor conjugated by another tensor.
Here conjugate is used in the sense of conjugating by a matrix, i.a.
A conjugated about B is $A B A^\dagger$ where $\dagger$ represents the
conjugate transpose.
Abstractly th... |
Left-multiplies an NxN matrix onto N slices of a numpy array.
Example:
The 4x4 matrix of a fractional SWAP gate can be expressed as
[ 1 ]
[ X**t ]
[ 1 ]
Where X is the 2x2 Pauli X gate and t is the power of the swap with t=1
being a full swa... |
Takes the partial trace of a given tensor.
The input tensor must have shape `(d_0, ..., d_{k-1}, d_0, ..., d_{k-1})`.
The trace is done over all indices that are not in keep_indices. The
resulting tensor has shape `(d_{i_0}, ..., d_{i_r}, d_{i_0}, ..., d_{i_r})`
where `i_j` is the `j`th element of `kee... |
Returns lhs * rhs, or else a default if the operator is not implemented.
This method is mostly used by __pow__ methods trying to return
NotImplemented instead of causing a TypeError.
Args:
lhs: Left hand side of the multiplication.
rhs: Right hand side of the multiplication.
defaul... |
Determines if a matrix is a approximately diagonal.
A matrix is diagonal if i!=j implies m[i,j]==0.
Args:
matrix: The matrix to check.
atol: The per-matrix-entry absolute tolerance on equality.
Returns:
Whether the matrix is diagonal within the given tolerance.
def is_diagonal(ma... |
Determines if a matrix is approximately Hermitian.
A matrix is Hermitian if it's square and equal to its adjoint.
Args:
matrix: The matrix to check.
rtol: The per-matrix-entry relative tolerance on equality.
atol: The per-matrix-entry absolute tolerance on equality.
Returns:
... |
Determines if a matrix is approximately orthogonal.
A matrix is orthogonal if it's square and real and its transpose is its
inverse.
Args:
matrix: The matrix to check.
rtol: The per-matrix-entry relative tolerance on equality.
atol: The per-matrix-entry absolute tolerance on equali... |
Determines if a matrix is approximately special orthogonal.
A matrix is special orthogonal if it is square and real and its transpose
is its inverse and its determinant is one.
Args:
matrix: The matrix to check.
rtol: The per-matrix-entry relative tolerance on equality.
atol: The p... |
Determines if a matrix is approximately unitary.
A matrix is unitary if it's square and its adjoint is its inverse.
Args:
matrix: The matrix to check.
rtol: The per-matrix-entry relative tolerance on equality.
atol: The per-matrix-entry absolute tolerance on equality.
Returns:
... |
Determines if a matrix is approximately unitary with unit determinant.
A matrix is special-unitary if it is square and its adjoint is its inverse
and its determinant is one.
Args:
matrix: The matrix to check.
rtol: The per-matrix-entry relative tolerance on equality.
atol: The per-... |
Determines if two matrices approximately commute.
Two matrices A and B commute if they are square and have the same size and
AB = BA.
Args:
m1: One of the matrices.
m2: The other matrix.
rtol: The per-matrix-entry relative tolerance on equality.
atol: The per-matrix-entry a... |
Determines if a ~= b * exp(i t) for some t.
Args:
a: A numpy array.
b: Another numpy array.
rtol: Relative error tolerance.
atol: Absolute error tolerance.
equal_nan: Whether or not NaN entries should be considered equal to
other NaN entries.
def allclose_up_to_... |
Returns an index corresponding to a desired subset of an np.ndarray.
It is assumed that the np.ndarray's shape is of the form (2, 2, 2, ..., 2).
Example:
```python
# A '4 qubit' tensor with values from 0 to 15.
r = np.array(range(16)).reshape((2,) * 4)
# We want to index into... |
Creates a scheduled operation with a device-determined duration.
def op_at_on(operation: ops.Operation,
time: Timestamp,
device: Device):
"""Creates a scheduled operation with a device-determined duration."""
return ScheduledOperation(time,
... |
Returns number of qubits in the domain if known, None if unknown.
def num_qubits(self) -> Optional[int]:
"""Returns number of qubits in the domain if known, None if unknown."""
if not self:
return None
any_gate = next(iter(self))
return any_gate.num_qubits() |
Reconstructs matrix of self using unitaries of underlying gates.
Raises:
TypeError: if any of the gates in self does not provide a unitary.
def matrix(self) -> np.ndarray:
"""Reconstructs matrix of self using unitaries of underlying gates.
Raises:
TypeError: if any of ... |
Finds a box drawing character based on its connectivity.
For example:
box_draw_character(
NORMAL_BOX_CHARS,
BOLD_BOX_CHARS,
top=-1,
right=+1)
evaluates to '┕', which has a normal upward leg and bold rightward leg.
Args:
first: The character... |
Returns an application of this gate to the given qubits.
Args:
*qubits: The collection of qubits to potentially apply the gate to.
def on(self,
*qubits: raw_types.Qid) -> 'SingleQubitPauliStringGateOperation':
"""Returns an application of this gate to the given qubits.
... |
Recursively decomposes a value into `cirq.Operation`s meeting a criteria.
Args:
val: The value to decompose into operations.
intercepting_decomposer: An optional method that is called before the
default decomposer (the value's `_decompose_` method). If
`intercepting_decompos... |
Decomposes a value into operations, if possible.
This method decomposes the value exactly once, instead of decomposing it
and then continuing to decomposing the decomposed operations recursively
until some criteria is met (which is what `cirq.decompose` does).
Args:
val: The value to call `_de... |
Decomposes a value into operations on the given qubits.
This method is used when decomposing gates, which don't know which qubits
they are being applied to unless told. It decomposes the gate exactly once,
instead of decomposing it and then continuing to decomposing the decomposed
operations recursivel... |
A basis that contains exactly the given qubits in the given order.
Args:
fixed_qubits: The qubits in basis order.
fallback: A fallback order to use for extra qubits not in the
fixed_qubits list. Extra qubits will always come after the
fixed_qubits, but wi... |
A basis that orders qubits ascending based on a key function.
Args:
key: A function that takes a qubit and returns a key value. The
basis will be ordered ascending according to these key values.
Returns:
A basis that orders qubits ascending based on a key funct... |
Returns a qubit tuple ordered corresponding to the basis.
Args:
qubits: Qubits that should be included in the basis. (Additional
qubits may be added into the output by the basis.)
Returns:
A tuple of qubits in the same order that their single-qubit
m... |
Converts a value into a basis.
Args:
val: An iterable or a basis.
Returns:
The basis implied by the value.
def as_qubit_order(val: 'qubit_order_or_list.QubitOrderOrList'
) -> 'QubitOrder':
"""Converts a value into a basis.
Args:
... |
Transforms the Basis so that it applies to wrapped qubits.
Args:
externalize: Converts an internal qubit understood by the underlying
basis into an external qubit understood by the caller.
internalize: Converts an external qubit understood by the caller
i... |
A str method with hacks to support better lexicographic ordering.
The output strings are not intended to be human readable.
The returned string will have digit-runs zero-padded up to at least 8
digits. That way, instead of 'a10' coming before 'a2', 'a000010' will come
after 'a000002'.
Also, the o... |
Returns a range of NamedQubits.
The range returned starts with the prefix, and followed by a qubit for
each number in the range, e.g.:
NamedQubit.range(3, prefix="a") -> ["a1", "a2", "a3]
NamedQubit.range(2, 4, prefix="a") -> ["a2", "a3]
Args:
*args: Args to be pas... |
r"""Returns a list of matrices describing the channel for the given value.
These matrices are the terms in the operator sum representation of
a quantum channel. If the returned matrices are {A_0,A_1,..., A_{r-1}},
then this describes the channel:
\rho \rightarrow \sum_{k=0}^{r-1} A_0 \rho A_0^\dagg... |
Returns whether the value has a channel representation.
Returns:
If `val` has a `_has_channel_` method and its result is not
NotImplemented, that result is returned. Otherwise, if `val` has a
`_has_mixture_` method and its result is not NotImplemented, that
result is returned. Other... |
Decomposes a two-qubit operation into Z/XY/CZ gates.
Args:
q0: The first qubit being operated on.
q1: The other qubit being operated on.
mat: Defines the operation to apply to the pair of qubits.
allow_partial_czs: Enables the use of Partial-CZ gates.
atol: A limit on the am... |
Assumes that the decomposition is canonical.
def _kak_decomposition_to_operations(q0: ops.Qid,
q1: ops.Qid,
kak: linalg.KakDecomposition,
allow_partial_czs: bool,
atol: fl... |
Tests if a circuit for an operator exp(i*rad*XX) (or YY, or ZZ) can
be performed with a whole CZ.
Args:
rad: The angle in radians, assumed to be in the range [-pi/4, pi/4]
def _is_trivial_angle(rad: float, atol: float) -> bool:
"""Tests if a circuit for an operator exp(i*rad*XX) (or YY, or ZZ) can... |
Yields a ZZ interaction framed by the given operation.
def _parity_interaction(q0: ops.Qid,
q1: ops.Qid,
rads: float,
atol: float,
gate: Optional[ops.Gate] = None):
"""Yields a ZZ interaction framed by the given operati... |
Yields non-local operation of KAK decomposition.
def _non_local_part(q0: ops.Qid,
q1: ops.Qid,
interaction_coefficients: Tuple[float, float, float],
allow_partial_czs: bool,
atol: float = 1e-8):
"""Yields non-local operation of KAK dec... |
Runs the simulator.
def simulate(sim_type: str,
num_qubits: int,
num_gates: int,
num_prefix_qubits: int = 0,
use_processes: bool = False) -> None:
""""Runs the simulator."""
circuit = cirq.Circuit(device=test_device)
for _ in range(num_gates):
wh... |
See definition in `cirq.SimulatesSamples`.
def _run(
self,
circuit: circuits.Circuit,
param_resolver: study.ParamResolver,
repetitions: int) -> Dict[str, List[np.ndarray]]:
"""See definition in `cirq.SimulatesSamples`."""
param_resolver = param_resolver or study.ParamRes... |
Simulate an op that has a unitary.
def _simulate_unitary(self, op: ops.Operation, data: _StateAndBuffer,
indices: List[int]) -> None:
"""Simulate an op that has a unitary."""
result = protocols.apply_unitary(
op,
args=protocols.ApplyUnitaryArgs(
... |
Simulate an op that is a measurement in the computataional basis.
def _simulate_measurement(self, op: ops.Operation, data: _StateAndBuffer,
indices: List[int], measurements: Dict[str, List[bool]],
num_qubits: int) -> None:
"""Simulate an op that is a measurement in the computataional ba... |
Simulate an op that is a mixtures of unitaries.
def _simulate_mixture(self, op: ops.Operation, data: _StateAndBuffer,
indices: List[int]) -> None:
"""Simulate an op that is a mixtures of unitaries."""
probs, unitaries = zip(*protocols.mixture(op))
# We work around numpy barfing on c... |
Acquaints every triple of qubits.
Exploits the fact that in a simple linear swap network every pair of
logical qubits that starts at distance two remains so (except temporarily
near the edge), and that every third one `goes through` the pair at some
point in the network. The strategy then iterates thro... |
Parse ASCIIart device layout into info about qubits and connectivity.
Args:
s: String representing the qubit layout. Each line represents a row,
and each character in the row is a qubit, or a blank site if the
character is a hyphen '-'. Different letters for the qubit specify
... |
Approximately compares two objects.
If `val` implements SupportsApproxEquality protocol then it is invoked and
takes precedence over all other checks:
- For primitive numeric types `int` and `float` approximate equality is
delegated to math.isclose().
- For complex primitive type the real and ... |
Iterates over arguments and calls approx_eq recursively.
Types of `val` and `other` does not necessarily needs to match each other.
They just need to be iterable of the same length and have the same
structure, approx_eq() will be called on each consecutive element of `val`
and `other`.
Args:
... |
Convenience wrapper around np.isclose.
def _isclose(a: Any, b: Any, *, atol: Union[int, float]) -> bool:
"""Convenience wrapper around np.isclose."""
return True if np.isclose([a], [b], atol=atol, rtol=0.0)[0] else False |
Returns an acquaintance strategy capable of executing a gate corresponding
to any set of at most acquaintance_size qubits.
Args:
qubit_order: The qubits on which the strategy should be defined.
acquaintance_size: The maximum number of qubits to be acted on by
an operation.
Returns:... |
Add the specified number of input and output qubits.
def set_io_qubits(qubit_count):
"""Add the specified number of input and output qubits."""
input_qubits = [cirq.GridQubit(i, 0) for i in range(qubit_count)]
output_qubit = cirq.GridQubit(qubit_count, 0)
return (input_qubits, output_qubit) |
Implement function {f(x) = 1 if x==x', f(x) = 0 if x!= x'}.
def make_oracle(input_qubits, output_qubit, x_bits):
"""Implement function {f(x) = 1 if x==x', f(x) = 0 if x!= x'}."""
# Make oracle.
# for (1, 1) it's just a Toffoli gate
# otherwise negate the zero-bits.
yield(cirq.X(q) for (q, bit) in z... |
Find the value recognized by the oracle in sqrt(N) attempts.
def make_grover_circuit(input_qubits, output_qubit, oracle):
"""Find the value recognized by the oracle in sqrt(N) attempts."""
# For 2 input qubits, that means using Grover operator only once.
c = cirq.Circuit()
# Initialize qubits.
c.a... |
Iterates through relevant python files within the given directory.
Args:
directory: The top-level directory to explore.
Yields:
File paths.
def get_unhidden_ungenerated_python_files(directory: str) -> Iterable[str]:
"""Iterates through relevant python files within the given directory.
... |
Creates a new virtual environment and then installs dependencies.
Args:
venv_path: Where to put the virtual environment's state.
requirements_paths: Location of requirements files to -r install.
python_path: The python binary to use.
verbose: When set, more progress output is produc... |
Creates a python 2.7 environment starting from a prepared python 3 one.
Args:
destination_directory: Where to put the python 2 environment.
python3_environment: The prepared environment to start from.
verbose: When set, more progress output is produced.
env_name: The name to use for... |
Construct the following phase estimator circuit and execute simulations.
---------
---H---------------------@------| |---M--- [m4]:lowest bit
| | |
---H---------------@-----+------| |---M--- [m3]
... |
Execute the phase estimator cirquit with multiple settings and
show results.
def experiment(qnum, repetitions=100):
"""Execute the phase estimator cirquit with multiple settings and
show results.
"""
def example_gate(phi):
"""An example unitary 1-qubit gate U with an eigen vector |0> and a... |
A quantum circuit (QFT_inv) with the following structure.
---H--@-------@--------@----------------------------------------------
| | |
------@^-0.5--+--------+---------H--@-------@-------------------------
| | | |
--------... |
Searches for linear sequence of qubits on device.
Args:
device: Google Xmon device instance.
length: Desired number of qubits making up the line.
method: Line placement method. Defaults to
cirq.greedy.GreedySequenceSearchMethod.
Returns:
Line sequences search re... |
Returns `val**factor` of the given value, if defined.
Values define an extrapolation by defining a __pow__(self, exponent) method.
Note that the method may return NotImplemented to indicate a particular
extrapolation can't be done.
Args:
val: The value or iterable of values to invert.
... |
Simulates sampling from the given circuit or schedule.
Args:
program: The circuit or schedule to sample from.
noise: Noise model to use while running the simulation.
param_resolver: Parameters to run with the program.
repetitions: The number of samples to take.
dtype: The `n... |
Runs the supplied Circuit or Schedule, mimicking quantum hardware.
In contrast to run, this allows for sweeping over different parameter
values.
Args:
program: The circuit or schedule to simulate.
params: Parameters to run with the program.
noise: Noise model to use while running t... |
Returns a schedule aligned with the moment structure of the Circuit.
This method attempts to create a schedule in which each moment of a circuit
is scheduled starting at the same time. Given the constraints of the
given device, such a schedule may not be possible, in this case the
the method will raise... |
Minimum width necessary to render the block's contents.
def min_width(self) -> int:
"""Minimum width necessary to render the block's contents."""
return max(
max(len(e) for e in self.content.split('\n')),
# Only horizontal lines can cross 0 width blocks.
int(any([sel... |
Minimum height necessary to render the block's contents.
def min_height(self) -> int:
"""Minimum height necessary to render the block's contents."""
return max(
len(self.content.split('\n')) if self.content else 0,
# Only vertical lines can cross 0 height blocks.
int... |
Draws lines in the box using the given character set.
Supports merging the new lines with the lines from a previous call to
draw_curve, including when they have different character sets (assuming
there exist characters merging the two).
Args:
grid_characters: The character ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.