partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
drop_temporary
Filters out problems that may be temporary.
dev_tools/auto_merge.py
def drop_temporary(pr: PullRequestDetails, problem: Optional[CannotAutomergeError], prev_seen_times: Dict[int, datetime.datetime], next_seen_times: Dict[int, datetime.datetime], ) -> Optional[CannotAutomergeError]: """Filters out problems t...
def drop_temporary(pr: PullRequestDetails, problem: Optional[CannotAutomergeError], prev_seen_times: Dict[int, datetime.datetime], next_seen_times: Dict[int, datetime.datetime], ) -> Optional[CannotAutomergeError]: """Filters out problems t...
[ "Filters", "out", "problems", "that", "may", "be", "temporary", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/auto_merge.py#L794-L807
[ "def", "drop_temporary", "(", "pr", ":", "PullRequestDetails", ",", "problem", ":", "Optional", "[", "CannotAutomergeError", "]", ",", "prev_seen_times", ":", "Dict", "[", "int", ",", "datetime", ".", "datetime", "]", ",", "next_seen_times", ":", "Dict", "[", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
PullRequestDetails.from_github
References: https://developer.github.com/v3/pulls/#get-a-single-pull-request
dev_tools/auto_merge.py
def from_github(repo: GithubRepository, pull_id: int) -> 'PullRequestDetails': """ References: https://developer.github.com/v3/pulls/#get-a-single-pull-request """ url = ("https://api.github.com/repos/{}/{}/pulls/{}" "?access_token={}".forma...
def from_github(repo: GithubRepository, pull_id: int) -> 'PullRequestDetails': """ References: https://developer.github.com/v3/pulls/#get-a-single-pull-request """ url = ("https://api.github.com/repos/{}/{}/pulls/{}" "?access_token={}".forma...
[ "References", ":", "https", ":", "//", "developer", ".", "github", ".", "com", "/", "v3", "/", "pulls", "/", "#get", "-", "a", "-", "single", "-", "pull", "-", "request" ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/dev_tools/auto_merge.py#L43-L63
[ "def", "from_github", "(", "repo", ":", "GithubRepository", ",", "pull_id", ":", "int", ")", "->", "'PullRequestDetails'", ":", "url", "=", "(", "\"https://api.github.com/repos/{}/{}/pulls/{}\"", "\"?access_token={}\"", ".", "format", "(", "repo", ".", "organization",...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
MS
The Mølmer–Sørensen gate, a native two-qubit operation in ion traps. A rotation around the XX axis in the two-qubit bloch sphere. The gate implements the following unitary: exp(-i t XX) = [ cos(t) 0 0 -isin(t)] [ 0 cos(t) -isin(t) 0 ] ...
cirq/ion/ion_gates.py
def MS(rads: float) -> ops.XXPowGate: """The Mølmer–Sørensen gate, a native two-qubit operation in ion traps. A rotation around the XX axis in the two-qubit bloch sphere. The gate implements the following unitary: exp(-i t XX) = [ cos(t) 0 0 -isin(t)] [ 0 ...
def MS(rads: float) -> ops.XXPowGate: """The Mølmer–Sørensen gate, a native two-qubit operation in ion traps. A rotation around the XX axis in the two-qubit bloch sphere. The gate implements the following unitary: exp(-i t XX) = [ cos(t) 0 0 -isin(t)] [ 0 ...
[ "The", "Mølmer–Sørensen", "gate", "a", "native", "two", "-", "qubit", "operation", "in", "ion", "traps", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ion/ion_gates.py#L22-L40
[ "def", "MS", "(", "rads", ":", "float", ")", "->", "ops", ".", "XXPowGate", ":", "return", "ops", ".", "XXPowGate", "(", "exponent", "=", "rads", "*", "2", "/", "np", ".", "pi", ",", "global_shift", "=", "-", "0.5", ")" ]
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_accept
Calculates probability and draws if solution should be accepted. Based on exp(-Delta*E/T) formula. Args: random_sample: Uniformly distributed random number in the range [0, 1). cost_diff: Cost difference between new and previous solutions. temp: Current temperature. Returns: ...
cirq/google/line/placement/optimization.py
def _accept(random_sample: float, cost_diff: float, temp: float) -> Tuple[bool, float]: """Calculates probability and draws if solution should be accepted. Based on exp(-Delta*E/T) formula. Args: random_sample: Uniformly distributed random number in the range [0, 1). cost_diff:...
def _accept(random_sample: float, cost_diff: float, temp: float) -> Tuple[bool, float]: """Calculates probability and draws if solution should be accepted. Based on exp(-Delta*E/T) formula. Args: random_sample: Uniformly distributed random number in the range [0, 1). cost_diff:...
[ "Calculates", "probability", "and", "draws", "if", "solution", "should", "be", "accepted", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/line/placement/optimization.py#L22-L43
[ "def", "_accept", "(", "random_sample", ":", "float", ",", "cost_diff", ":", "float", ",", "temp", ":", "float", ")", "->", "Tuple", "[", "bool", ",", "float", "]", ":", "exponent", "=", "-", "cost_diff", "/", "temp", "if", "exponent", ">=", "0.0", "...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
anneal_minimize
Minimize solution using Simulated Annealing meta-heuristic. Args: initial: Initial solution of type T to the problem. cost_func: Callable which takes current solution of type T, evaluates it and returns float with the cost estimate. The better solution is, the lower resultin...
cirq/google/line/placement/optimization.py
def anneal_minimize( initial: T, cost_func: Callable[[T], float], move_func: Callable[[T], T], random_sample: Callable[[], float], temp_initial: float = 1.0e-2, temp_final: float = 1e-6, cooling_factor: float = 0.99, repeat: int = 100, trace_func: ...
def anneal_minimize( initial: T, cost_func: Callable[[T], float], move_func: Callable[[T], T], random_sample: Callable[[], float], temp_initial: float = 1.0e-2, temp_final: float = 1e-6, cooling_factor: float = 0.99, repeat: int = 100, trace_func: ...
[ "Minimize", "solution", "using", "Simulated", "Annealing", "meta", "-", "heuristic", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/line/placement/optimization.py#L46-L128
[ "def", "anneal_minimize", "(", "initial", ":", "T", ",", "cost_func", ":", "Callable", "[", "[", "T", "]", ",", "float", "]", ",", "move_func", ":", "Callable", "[", "[", "T", "]", ",", "T", "]", ",", "random_sample", ":", "Callable", "[", "[", "]"...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
op_gate_of_type
Returns the gate of given type, if the op has that gate otherwise None.
cirq/ops/gate_operation.py
def op_gate_of_type(op: raw_types.Operation, gate_type: Type[TV]) -> Optional[TV]: """Returns the gate of given type, if the op has that gate otherwise None. """ if isinstance(op, GateOperation) and isinstance(op.gate, gate_type): return op.gate return None
def op_gate_of_type(op: raw_types.Operation, gate_type: Type[TV]) -> Optional[TV]: """Returns the gate of given type, if the op has that gate otherwise None. """ if isinstance(op, GateOperation) and isinstance(op.gate, gate_type): return op.gate return None
[ "Returns", "the", "gate", "of", "given", "type", "if", "the", "op", "has", "that", "gate", "otherwise", "None", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/gate_operation.py#L188-L194
[ "def", "op_gate_of_type", "(", "op", ":", "raw_types", ".", "Operation", ",", "gate_type", ":", "Type", "[", "TV", "]", ")", "->", "Optional", "[", "TV", "]", ":", "if", "isinstance", "(", "op", ",", "GateOperation", ")", "and", "isinstance", "(", "op"...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
qubit_pairs_to_qubit_order
Takes a sequence of qubit pairs and returns a sequence in which every pair is at distance two. Specifically, given pairs (1a, 1b), (2a, 2b), etc. returns (1a, 2a, 1b, 2b, 3a, 4a, 3b, 4b, ...).
cirq/contrib/acquaintance/strategies/quartic_paired.py
def qubit_pairs_to_qubit_order( qubit_pairs: Sequence[Sequence[ops.Qid]] ) -> List[ops.Qid]: """Takes a sequence of qubit pairs and returns a sequence in which every pair is at distance two. Specifically, given pairs (1a, 1b), (2a, 2b), etc. returns (1a, 2a, 1b, 2b, 3a, 4a, 3b, 4b, ...). ""...
def qubit_pairs_to_qubit_order( qubit_pairs: Sequence[Sequence[ops.Qid]] ) -> List[ops.Qid]: """Takes a sequence of qubit pairs and returns a sequence in which every pair is at distance two. Specifically, given pairs (1a, 1b), (2a, 2b), etc. returns (1a, 2a, 1b, 2b, 3a, 4a, 3b, 4b, ...). ""...
[ "Takes", "a", "sequence", "of", "qubit", "pairs", "and", "returns", "a", "sequence", "in", "which", "every", "pair", "is", "at", "distance", "two", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/acquaintance/strategies/quartic_paired.py#L24-L45
[ "def", "qubit_pairs_to_qubit_order", "(", "qubit_pairs", ":", "Sequence", "[", "Sequence", "[", "ops", ".", "Qid", "]", "]", ")", "->", "List", "[", "ops", ".", "Qid", "]", ":", "if", "set", "(", "len", "(", "qubit_pair", ")", "for", "qubit_pair", "in"...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
quartic_paired_acquaintance_strategy
Acquaintance strategy for pairs of pairs. Implements UpCCGSD ansatz from arXiv:1810.02327.
cirq/contrib/acquaintance/strategies/quartic_paired.py
def quartic_paired_acquaintance_strategy( qubit_pairs: Iterable[Tuple[ops.Qid, ops.Qid]] ) -> Tuple[circuits.Circuit, Sequence[ops.Qid]]: """Acquaintance strategy for pairs of pairs. Implements UpCCGSD ansatz from arXiv:1810.02327. """ qubit_pairs = tuple( cast(Tuple[ops.Qid, ops.Q...
def quartic_paired_acquaintance_strategy( qubit_pairs: Iterable[Tuple[ops.Qid, ops.Qid]] ) -> Tuple[circuits.Circuit, Sequence[ops.Qid]]: """Acquaintance strategy for pairs of pairs. Implements UpCCGSD ansatz from arXiv:1810.02327. """ qubit_pairs = tuple( cast(Tuple[ops.Qid, ops.Q...
[ "Acquaintance", "strategy", "for", "pairs", "of", "pairs", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/acquaintance/strategies/quartic_paired.py#L48-L69
[ "def", "quartic_paired_acquaintance_strategy", "(", "qubit_pairs", ":", "Iterable", "[", "Tuple", "[", "ops", ".", "Qid", ",", "ops", ".", "Qid", "]", "]", ")", "->", "Tuple", "[", "circuits", ".", "Circuit", ",", "Sequence", "[", "ops", ".", "Qid", "]",...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
circuit_diagram_info
Requests information on drawing an operation in a circuit diagram. Calls _circuit_diagram_info_ on `val`. If `val` doesn't have _circuit_diagram_info_, or it returns NotImplemented, that indicates that diagram information is not available. Args: val: The operation or gate that will need to be ...
cirq/protocols/circuit_diagram_info.py
def circuit_diagram_info(val: Any, args: Optional[CircuitDiagramInfoArgs] = None, default=RaiseTypeErrorIfNotProvided): """Requests information on drawing an operation in a circuit diagram. Calls _circuit_diagram_info_ on `val`. If `val` doesn't have _circu...
def circuit_diagram_info(val: Any, args: Optional[CircuitDiagramInfoArgs] = None, default=RaiseTypeErrorIfNotProvided): """Requests information on drawing an operation in a circuit diagram. Calls _circuit_diagram_info_ on `val`. If `val` doesn't have _circu...
[ "Requests", "information", "on", "drawing", "an", "operation", "in", "a", "circuit", "diagram", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/circuit_diagram_info.py#L197-L248
[ "def", "circuit_diagram_info", "(", "val", ":", "Any", ",", "args", ":", "Optional", "[", "CircuitDiagramInfoArgs", "]", "=", "None", ",", "default", "=", "RaiseTypeErrorIfNotProvided", ")", ":", "# Attempt.", "if", "args", "is", "None", ":", "args", "=", "C...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
pauli_expansion
Returns coefficients of the expansion of val in the Pauli basis. Args: val: The value whose Pauli expansion is to returned. default: Determines what happens when `val` does not have methods that allow Pauli expansion to be obtained (see below). If set, the value is returned ...
cirq/protocols/pauli_expansion.py
def pauli_expansion( val: Any, *, default: Union[value.LinearDict[str], TDefault] = RaiseTypeErrorIfNotProvided, atol: float = 1e-9 ) -> Union[value.LinearDict[str], TDefault]: """Returns coefficients of the expansion of val in the Pauli basis. Args: val: The value whose Pauli e...
def pauli_expansion( val: Any, *, default: Union[value.LinearDict[str], TDefault] = RaiseTypeErrorIfNotProvided, atol: float = 1e-9 ) -> Union[value.LinearDict[str], TDefault]: """Returns coefficients of the expansion of val in the Pauli basis. Args: val: The value whose Pauli e...
[ "Returns", "coefficients", "of", "the", "expansion", "of", "val", "in", "the", "Pauli", "basis", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/pauli_expansion.py#L29-L74
[ "def", "pauli_expansion", "(", "val", ":", "Any", ",", "*", ",", "default", ":", "Union", "[", "value", ".", "LinearDict", "[", "str", "]", ",", "TDefault", "]", "=", "RaiseTypeErrorIfNotProvided", ",", "atol", ":", "float", "=", "1e-9", ")", "->", "Un...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
DensityMatrixSimulator._run
See definition in `cirq.SimulatesSamples`.
cirq/sim/density_matrix_simulator.py
def _run(self, circuit: circuits.Circuit, param_resolver: study.ParamResolver, repetitions: int) -> Dict[str, np.ndarray]: """See definition in `cirq.SimulatesSamples`.""" param_resolver = param_resolver or study.ParamResolver({}) resolved_circuit = protocols.resolve_pa...
def _run(self, circuit: circuits.Circuit, param_resolver: study.ParamResolver, repetitions: int) -> Dict[str, np.ndarray]: """See definition in `cirq.SimulatesSamples`.""" param_resolver = param_resolver or study.ParamResolver({}) resolved_circuit = protocols.resolve_pa...
[ "See", "definition", "in", "cirq", ".", "SimulatesSamples", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/density_matrix_simulator.py#L132-L143
[ "def", "_run", "(", "self", ",", "circuit", ":", "circuits", ".", "Circuit", ",", "param_resolver", ":", "study", ".", "ParamResolver", ",", "repetitions", ":", "int", ")", "->", "Dict", "[", "str", ",", "np", ".", "ndarray", "]", ":", "param_resolver", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
DensityMatrixSimulator._simulator_iterator
See definition in `cirq.SimulatesIntermediateState`. If the initial state is an int, the state is set to the computational basis state corresponding to this state. Otherwise if the initial state is a np.ndarray it is the full initial state, either a pure state or the full density matri...
cirq/sim/density_matrix_simulator.py
def _simulator_iterator(self, circuit: circuits.Circuit, param_resolver: study.ParamResolver, qubit_order: ops.QubitOrderOrList, initial_state: Union[int, np.ndarray]) -> Iterator: """See definition in `cirq.SimulatesIntermediat...
def _simulator_iterator(self, circuit: circuits.Circuit, param_resolver: study.ParamResolver, qubit_order: ops.QubitOrderOrList, initial_state: Union[int, np.ndarray]) -> Iterator: """See definition in `cirq.SimulatesIntermediat...
[ "See", "definition", "in", "cirq", ".", "SimulatesIntermediateState", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/density_matrix_simulator.py#L176-L195
[ "def", "_simulator_iterator", "(", "self", ",", "circuit", ":", "circuits", ".", "Circuit", ",", "param_resolver", ":", "study", ".", "ParamResolver", ",", "qubit_order", ":", "ops", ".", "QubitOrderOrList", ",", "initial_state", ":", "Union", "[", "int", ",",...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
DensityMatrixSimulator.compute_displays_sweep
Computes displays 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. qubit_order: D...
cirq/sim/density_matrix_simulator.py
def compute_displays_sweep( self, program: Union[circuits.Circuit, schedules.Schedule], params: Optional[study.Sweepable] = None, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, initial_state: Union[int, np.ndarray] = 0, ) -> List[study.ComputeDisplaysResult]: ...
def compute_displays_sweep( self, program: Union[circuits.Circuit, schedules.Schedule], params: Optional[study.Sweepable] = None, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, initial_state: Union[int, np.ndarray] = 0, ) -> List[study.ComputeDisplaysResult]: ...
[ "Computes", "displays", "in", "the", "supplied", "Circuit", "or", "Schedule", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/density_matrix_simulator.py#L322-L388
[ "def", "compute_displays_sweep", "(", "self", ",", "program", ":", "Union", "[", "circuits", ".", "Circuit", ",", "schedules", ".", "Schedule", "]", ",", "params", ":", "Optional", "[", "study", ".", "Sweepable", "]", "=", "None", ",", "qubit_order", ":", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
DensityMatrixStepResult.set_density_matrix
Set the density matrix to a new density matrix. Args: density_matrix_repr: If this is an int, the density matrix is set to the computational basis state corresponding to this state. Otherwise if this is a np.ndarray it is the full state, either a pure state or th...
cirq/sim/density_matrix_simulator.py
def set_density_matrix(self, density_matrix_repr: Union[int, np.ndarray]): """Set the density matrix to a new density matrix. Args: density_matrix_repr: If this is an int, the density matrix is set to the computational basis state corresponding to this state. Otherwise ...
def set_density_matrix(self, density_matrix_repr: Union[int, np.ndarray]): """Set the density matrix to a new density matrix. Args: density_matrix_repr: If this is an int, the density matrix is set to the computational basis state corresponding to this state. Otherwise ...
[ "Set", "the", "density", "matrix", "to", "a", "new", "density", "matrix", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/density_matrix_simulator.py#L470-L487
[ "def", "set_density_matrix", "(", "self", ",", "density_matrix_repr", ":", "Union", "[", "int", ",", "np", ".", "ndarray", "]", ")", ":", "density_matrix", "=", "density_matrix_utils", ".", "to_valid_density_matrix", "(", "density_matrix_repr", ",", "len", "(", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
DensityMatrixStepResult.density_matrix
Returns the density matrix at this step in the simulation. The density matrix that is stored in this result is returned in the computational basis with these basis states defined by the qubit_map. In particular the value in the qubit_map is the index of the qubit, and these are translat...
cirq/sim/density_matrix_simulator.py
def density_matrix(self): """Returns the density matrix at this step in the simulation. The density matrix that is stored in this result is returned in the computational basis with these basis states defined by the qubit_map. In particular the value in the qubit_map is the index of the ...
def density_matrix(self): """Returns the density matrix at this step in the simulation. The density matrix that is stored in this result is returned in the computational basis with these basis states defined by the qubit_map. In particular the value in the qubit_map is the index of the ...
[ "Returns", "the", "density", "matrix", "at", "this", "step", "in", "the", "simulation", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/density_matrix_simulator.py#L489-L518
[ "def", "density_matrix", "(", "self", ")", ":", "size", "=", "2", "**", "len", "(", "self", ".", "_qubit_map", ")", "return", "np", ".", "reshape", "(", "self", ".", "_density_matrix", ",", "(", "size", ",", "size", ")", ")" ]
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
kron_bases
Creates tensor product of bases.
cirq/linalg/operator_spaces.py
def kron_bases(*bases: Dict[str, np.ndarray], repeat: int = 1) -> Dict[str, np.ndarray]: """Creates tensor product of bases.""" product_basis = {'': 1} for basis in bases * repeat: product_basis = { name1 + name2: np.kron(matrix1, matrix2) for name1, matrix1 in...
def kron_bases(*bases: Dict[str, np.ndarray], repeat: int = 1) -> Dict[str, np.ndarray]: """Creates tensor product of bases.""" product_basis = {'': 1} for basis in bases * repeat: product_basis = { name1 + name2: np.kron(matrix1, matrix2) for name1, matrix1 in...
[ "Creates", "tensor", "product", "of", "bases", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/operator_spaces.py#L31-L41
[ "def", "kron_bases", "(", "*", "bases", ":", "Dict", "[", "str", ",", "np", ".", "ndarray", "]", ",", "repeat", ":", "int", "=", "1", ")", "->", "Dict", "[", "str", ",", "np", ".", "ndarray", "]", ":", "product_basis", "=", "{", "''", ":", "1",...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
hilbert_schmidt_inner_product
Computes Hilbert-Schmidt inner product of two matrices. Linear in second argument.
cirq/linalg/operator_spaces.py
def hilbert_schmidt_inner_product(m1: np.ndarray, m2: np.ndarray) -> complex: """Computes Hilbert-Schmidt inner product of two matrices. Linear in second argument. """ return np.einsum('ij,ij', m1.conj(), m2)
def hilbert_schmidt_inner_product(m1: np.ndarray, m2: np.ndarray) -> complex: """Computes Hilbert-Schmidt inner product of two matrices. Linear in second argument. """ return np.einsum('ij,ij', m1.conj(), m2)
[ "Computes", "Hilbert", "-", "Schmidt", "inner", "product", "of", "two", "matrices", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/operator_spaces.py#L44-L49
[ "def", "hilbert_schmidt_inner_product", "(", "m1", ":", "np", ".", "ndarray", ",", "m2", ":", "np", ".", "ndarray", ")", "->", "complex", ":", "return", "np", ".", "einsum", "(", "'ij,ij'", ",", "m1", ".", "conj", "(", ")", ",", "m2", ")" ]
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
expand_matrix_in_orthogonal_basis
Computes coefficients of expansion of m in basis. We require that basis be orthogonal w.r.t. the Hilbert-Schmidt inner product. We do not require that basis be orthonormal. Note that Pauli basis (I, X, Y, Z) is orthogonal, but not orthonormal.
cirq/linalg/operator_spaces.py
def expand_matrix_in_orthogonal_basis( m: np.ndarray, basis: Dict[str, np.ndarray], ) -> value.LinearDict[str]: """Computes coefficients of expansion of m in basis. We require that basis be orthogonal w.r.t. the Hilbert-Schmidt inner product. We do not require that basis be orthonormal. Not...
def expand_matrix_in_orthogonal_basis( m: np.ndarray, basis: Dict[str, np.ndarray], ) -> value.LinearDict[str]: """Computes coefficients of expansion of m in basis. We require that basis be orthogonal w.r.t. the Hilbert-Schmidt inner product. We do not require that basis be orthonormal. Not...
[ "Computes", "coefficients", "of", "expansion", "of", "m", "in", "basis", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/operator_spaces.py#L52-L66
[ "def", "expand_matrix_in_orthogonal_basis", "(", "m", ":", "np", ".", "ndarray", ",", "basis", ":", "Dict", "[", "str", ",", "np", ".", "ndarray", "]", ",", ")", "->", "value", ".", "LinearDict", "[", "str", "]", ":", "return", "value", ".", "LinearDic...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
matrix_from_basis_coefficients
Computes linear combination of basis vectors with given coefficients.
cirq/linalg/operator_spaces.py
def matrix_from_basis_coefficients(expansion: value.LinearDict[str], basis: Dict[str, np.ndarray]) -> np.ndarray: """Computes linear combination of basis vectors with given coefficients.""" some_element = next(iter(basis.values())) result = np.zeros_like(some_element, dtyp...
def matrix_from_basis_coefficients(expansion: value.LinearDict[str], basis: Dict[str, np.ndarray]) -> np.ndarray: """Computes linear combination of basis vectors with given coefficients.""" some_element = next(iter(basis.values())) result = np.zeros_like(some_element, dtyp...
[ "Computes", "linear", "combination", "of", "basis", "vectors", "with", "given", "coefficients", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/operator_spaces.py#L69-L76
[ "def", "matrix_from_basis_coefficients", "(", "expansion", ":", "value", ".", "LinearDict", "[", "str", "]", ",", "basis", ":", "Dict", "[", "str", ",", "np", ".", "ndarray", "]", ")", "->", "np", ".", "ndarray", ":", "some_element", "=", "next", "(", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
converted_gate_set
Returns a new, equivalent circuit using the gate set {SingleQubitCliffordGate, CZ/PauliInteractionGate, PauliStringPhasor}.
cirq/contrib/paulistring/convert_gate_set.py
def converted_gate_set(circuit: circuits.Circuit, no_clifford_gates: bool = False, atol: float = 1e-8, ) -> circuits.Circuit: """Returns a new, equivalent circuit using the gate set {SingleQubitCliffordGate, CZ/PauliInteractionGate, PauliS...
def converted_gate_set(circuit: circuits.Circuit, no_clifford_gates: bool = False, atol: float = 1e-8, ) -> circuits.Circuit: """Returns a new, equivalent circuit using the gate set {SingleQubitCliffordGate, CZ/PauliInteractionGate, PauliS...
[ "Returns", "a", "new", "equivalent", "circuit", "using", "the", "gate", "set", "{", "SingleQubitCliffordGate", "CZ", "/", "PauliInteractionGate", "PauliStringPhasor", "}", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/paulistring/convert_gate_set.py#L21-L37
[ "def", "converted_gate_set", "(", "circuit", ":", "circuits", ".", "Circuit", ",", "no_clifford_gates", ":", "bool", "=", "False", ",", "atol", ":", "float", "=", "1e-8", ",", ")", "->", "circuits", ".", "Circuit", ":", "conv_circuit", "=", "circuits", "."...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
optimized_for_xmon
Optimizes a circuit with XmonDevice in mind. Starts by converting the circuit's operations to the xmon gate set, then begins merging interactions and rotations, ejecting pi-rotations and phasing operations, dropping unnecessary operations, and pushing operations earlier. Args: circuit: The cir...
cirq/google/optimize.py
def optimized_for_xmon( circuit: circuits.Circuit, new_device: Optional[xmon_device.XmonDevice] = None, qubit_map: Callable[[ops.Qid], devices.GridQubit] = lambda e: cast(devices.GridQubit, e), allow_partial_czs: bool = False, ) -> circuits.Circuit: """Optimizes a circuit...
def optimized_for_xmon( circuit: circuits.Circuit, new_device: Optional[xmon_device.XmonDevice] = None, qubit_map: Callable[[ops.Qid], devices.GridQubit] = lambda e: cast(devices.GridQubit, e), allow_partial_czs: bool = False, ) -> circuits.Circuit: """Optimizes a circuit...
[ "Optimizes", "a", "circuit", "with", "XmonDevice", "in", "mind", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/optimize.py#L55-L89
[ "def", "optimized_for_xmon", "(", "circuit", ":", "circuits", ".", "Circuit", ",", "new_device", ":", "Optional", "[", "xmon_device", ".", "XmonDevice", "]", "=", "None", ",", "qubit_map", ":", "Callable", "[", "[", "ops", ".", "Qid", "]", ",", "devices", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
apply_channel
High performance evolution under a channel evolution. If `val` defines an `_apply_channel_` method, that method will be used to apply `val`'s channel effect to the target tensor. Otherwise, if `val` defines an `_apply_unitary_` method, that method will be used to apply `val`s channel effect to the targ...
cirq/protocols/apply_channel.py
def apply_channel(val: Any, args: ApplyChannelArgs, default: TDefault = RaiseTypeErrorIfNotProvided ) -> Union[np.ndarray, TDefault]: """High performance evolution under a channel evolution. If `val` defines an `_apply_channel_` method, that method will be used to apply `val`'s channel effe...
def apply_channel(val: Any, args: ApplyChannelArgs, default: TDefault = RaiseTypeErrorIfNotProvided ) -> Union[np.ndarray, TDefault]: """High performance evolution under a channel evolution. If `val` defines an `_apply_channel_` method, that method will be used to apply `val`'s channel effe...
[ "High", "performance", "evolution", "under", "a", "channel", "evolution", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/apply_channel.py#L160-L241
[ "def", "apply_channel", "(", "val", ":", "Any", ",", "args", ":", "ApplyChannelArgs", ",", "default", ":", "TDefault", "=", "RaiseTypeErrorIfNotProvided", ")", "->", "Union", "[", "np", ".", "ndarray", ",", "TDefault", "]", ":", "# Check if the specialized metho...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_apply_unitary
Attempt to use `apply_unitary` and return the result. If `val` does not support `apply_unitary` returns None.
cirq/protocols/apply_channel.py
def _apply_unitary(val: Any, args: 'ApplyChannelArgs') -> Optional[np.ndarray]: """Attempt to use `apply_unitary` and return the result. If `val` does not support `apply_unitary` returns None. """ left_args = ApplyUnitaryArgs(target_tensor=args.target_tensor, available_...
def _apply_unitary(val: Any, args: 'ApplyChannelArgs') -> Optional[np.ndarray]: """Attempt to use `apply_unitary` and return the result. If `val` does not support `apply_unitary` returns None. """ left_args = ApplyUnitaryArgs(target_tensor=args.target_tensor, available_...
[ "Attempt", "to", "use", "apply_unitary", "and", "return", "the", "result", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/apply_channel.py#L244-L261
[ "def", "_apply_unitary", "(", "val", ":", "Any", ",", "args", ":", "'ApplyChannelArgs'", ")", "->", "Optional", "[", "np", ".", "ndarray", "]", ":", "left_args", "=", "ApplyUnitaryArgs", "(", "target_tensor", "=", "args", ".", "target_tensor", ",", "availabl...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_apply_krauss
Directly apply the kraus operators to the target tensor.
cirq/protocols/apply_channel.py
def _apply_krauss(krauss: Union[Tuple[np.ndarray], Sequence[Any]], args: 'ApplyChannelArgs') -> np.ndarray: """Directly apply the kraus operators to the target tensor.""" # Initialize output. args.out_buffer[:] = 0 # Stash initial state into buffer0. np.copyto(dst=args.auxiliary_buffer0, src...
def _apply_krauss(krauss: Union[Tuple[np.ndarray], Sequence[Any]], args: 'ApplyChannelArgs') -> np.ndarray: """Directly apply the kraus operators to the target tensor.""" # Initialize output. args.out_buffer[:] = 0 # Stash initial state into buffer0. np.copyto(dst=args.auxiliary_buffer0, src...
[ "Directly", "apply", "the", "kraus", "operators", "to", "the", "target", "tensor", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/apply_channel.py#L264-L276
[ "def", "_apply_krauss", "(", "krauss", ":", "Union", "[", "Tuple", "[", "np", ".", "ndarray", "]", ",", "Sequence", "[", "Any", "]", "]", ",", "args", ":", "'ApplyChannelArgs'", ")", "->", "np", ".", "ndarray", ":", "# Initialize output.", "args", ".", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_apply_krauss_single_qubit
Use slicing to apply single qubit channel.
cirq/protocols/apply_channel.py
def _apply_krauss_single_qubit(krauss: Union[Tuple[Any], Sequence[Any]], args: 'ApplyChannelArgs') -> np.ndarray: """Use slicing to apply single qubit channel.""" zero_left = linalg.slice_for_qubits_equal_to(args.left_axes, 0) one_left = linalg.slice_for_qubits_equal_to(args.left_axes, 1) zero_r...
def _apply_krauss_single_qubit(krauss: Union[Tuple[Any], Sequence[Any]], args: 'ApplyChannelArgs') -> np.ndarray: """Use slicing to apply single qubit channel.""" zero_left = linalg.slice_for_qubits_equal_to(args.left_axes, 0) one_left = linalg.slice_for_qubits_equal_to(args.left_axes, 1) zero_r...
[ "Use", "slicing", "to", "apply", "single", "qubit", "channel", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/apply_channel.py#L279-L302
[ "def", "_apply_krauss_single_qubit", "(", "krauss", ":", "Union", "[", "Tuple", "[", "Any", "]", ",", "Sequence", "[", "Any", "]", "]", ",", "args", ":", "'ApplyChannelArgs'", ")", "->", "np", ".", "ndarray", ":", "zero_left", "=", "linalg", ".", "slice_...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_apply_krauss_multi_qubit
Use numpy's einsum to apply a multi-qubit channel.
cirq/protocols/apply_channel.py
def _apply_krauss_multi_qubit(krauss: Union[Tuple[Any], Sequence[Any]], args: 'ApplyChannelArgs') -> np.ndarray: """Use numpy's einsum to apply a multi-qubit channel.""" for krauss_op in krauss: np.copyto(dst=args.target_tensor, src=args.auxiliary_buffer0) krauss_tensor = np.reshape( ...
def _apply_krauss_multi_qubit(krauss: Union[Tuple[Any], Sequence[Any]], args: 'ApplyChannelArgs') -> np.ndarray: """Use numpy's einsum to apply a multi-qubit channel.""" for krauss_op in krauss: np.copyto(dst=args.target_tensor, src=args.auxiliary_buffer0) krauss_tensor = np.reshape( ...
[ "Use", "numpy", "s", "einsum", "to", "apply", "a", "multi", "-", "qubit", "channel", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/apply_channel.py#L305-L326
[ "def", "_apply_krauss_multi_qubit", "(", "krauss", ":", "Union", "[", "Tuple", "[", "Any", "]", ",", "Sequence", "[", "Any", "]", "]", ",", "args", ":", "'ApplyChannelArgs'", ")", "->", "np", ".", "ndarray", ":", "for", "krauss_op", "in", "krauss", ":", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
convert_and_separate_circuit
Converts any circuit into two circuits where (circuit_left+circuit_right) is equivalent to the given circuit. Args: circuit: Any Circuit that cirq.google.optimized_for_xmon() supports. All gates should either provide a decomposition or have a known one or two qubit unitary matri...
cirq/contrib/paulistring/separate.py
def convert_and_separate_circuit(circuit: circuits.Circuit, leave_cliffords: bool = True, atol: float = 1e-8, ) -> Tuple[circuits.Circuit, circuits.Circuit]: """Converts any circuit into two circuits where (circuit_le...
def convert_and_separate_circuit(circuit: circuits.Circuit, leave_cliffords: bool = True, atol: float = 1e-8, ) -> Tuple[circuits.Circuit, circuits.Circuit]: """Converts any circuit into two circuits where (circuit_le...
[ "Converts", "any", "circuit", "into", "two", "circuits", "where", "(", "circuit_left", "+", "circuit_right", ")", "is", "equivalent", "to", "the", "given", "circuit", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/paulistring/separate.py#L22-L47
[ "def", "convert_and_separate_circuit", "(", "circuit", ":", "circuits", ".", "Circuit", ",", "leave_cliffords", ":", "bool", "=", "True", ",", "atol", ":", "float", "=", "1e-8", ",", ")", "->", "Tuple", "[", "circuits", ".", "Circuit", ",", "circuits", "."...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
regular_half
Return only the Clifford part of a circuit. See convert_and_separate_circuit(). Args: circuit: A Circuit with the gate set {SingleQubitCliffordGate, PauliInteractionGate, PauliStringPhasor}. Returns: A Circuit with SingleQubitCliffordGate and PauliInteractionGate gates. ...
cirq/contrib/paulistring/separate.py
def regular_half(circuit: circuits.Circuit) -> circuits.Circuit: """Return only the Clifford part of a circuit. See convert_and_separate_circuit(). Args: circuit: A Circuit with the gate set {SingleQubitCliffordGate, PauliInteractionGate, PauliStringPhasor}. Returns: A Cir...
def regular_half(circuit: circuits.Circuit) -> circuits.Circuit: """Return only the Clifford part of a circuit. See convert_and_separate_circuit(). Args: circuit: A Circuit with the gate set {SingleQubitCliffordGate, PauliInteractionGate, PauliStringPhasor}. Returns: A Cir...
[ "Return", "only", "the", "Clifford", "part", "of", "a", "circuit", ".", "See", "convert_and_separate_circuit", "()", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/paulistring/separate.py#L50-L67
[ "def", "regular_half", "(", "circuit", ":", "circuits", ".", "Circuit", ")", "->", "circuits", ".", "Circuit", ":", "return", "circuits", ".", "Circuit", "(", "ops", ".", "Moment", "(", "op", "for", "op", "in", "moment", ".", "operations", "if", "not", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
pauli_string_half
Return only the non-Clifford part of a circuit. See convert_and_separate_circuit(). Args: circuit: A Circuit with the gate set {SingleQubitCliffordGate, PauliInteractionGate, PauliStringPhasor}. Returns: A Circuit with only PauliStringPhasor operations.
cirq/contrib/paulistring/separate.py
def pauli_string_half(circuit: circuits.Circuit) -> circuits.Circuit: """Return only the non-Clifford part of a circuit. See convert_and_separate_circuit(). Args: circuit: A Circuit with the gate set {SingleQubitCliffordGate, PauliInteractionGate, PauliStringPhasor}. Returns: ...
def pauli_string_half(circuit: circuits.Circuit) -> circuits.Circuit: """Return only the non-Clifford part of a circuit. See convert_and_separate_circuit(). Args: circuit: A Circuit with the gate set {SingleQubitCliffordGate, PauliInteractionGate, PauliStringPhasor}. Returns: ...
[ "Return", "only", "the", "non", "-", "Clifford", "part", "of", "a", "circuit", ".", "See", "convert_and_separate_circuit", "()", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/contrib/paulistring/separate.py#L70-L83
[ "def", "pauli_string_half", "(", "circuit", ":", "circuits", ".", "Circuit", ")", "->", "circuits", ".", "Circuit", ":", "return", "circuits", ".", "Circuit", ".", "from_ops", "(", "_pull_non_clifford_before", "(", "circuit", ")", ",", "strategy", "=", "circui...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
to_valid_density_matrix
Verifies the density_matrix_rep is valid and converts it to ndarray form. This method is used to support passing a matrix, a vector (wave function), or a computational basis state as a representation of a state. Args: density_matrix_rep: If an numpy array, if it is of rank 2 (a matrix), ...
cirq/sim/density_matrix_utils.py
def to_valid_density_matrix( density_matrix_rep: Union[int, np.ndarray], num_qubits: int, dtype: Type[np.number] = np.complex64) -> np.ndarray: """Verifies the density_matrix_rep is valid and converts it to ndarray form. This method is used to support passing a matrix, a vector (wave function), ...
def to_valid_density_matrix( density_matrix_rep: Union[int, np.ndarray], num_qubits: int, dtype: Type[np.number] = np.complex64) -> np.ndarray: """Verifies the density_matrix_rep is valid and converts it to ndarray form. This method is used to support passing a matrix, a vector (wave function), ...
[ "Verifies", "the", "density_matrix_rep", "is", "valid", "and", "converts", "it", "to", "ndarray", "form", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/density_matrix_utils.py#L24-L74
[ "def", "to_valid_density_matrix", "(", "density_matrix_rep", ":", "Union", "[", "int", ",", "np", ".", "ndarray", "]", ",", "num_qubits", ":", "int", ",", "dtype", ":", "Type", "[", "np", ".", "number", "]", "=", "np", ".", "complex64", ")", "->", "np"...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
measure_density_matrix
Performs a measurement of the density matrix in the computational basis. This does not modify `density_matrix` unless the optional `out` is `density_matrix`. Args: density_matrix: The density matrix to be measured. This matrix is assumed to be positive semidefinite and trace one. The m...
cirq/sim/density_matrix_utils.py
def measure_density_matrix( density_matrix: np.ndarray, indices: List[int], out: np.ndarray = None) -> Tuple[List[bool], np.ndarray]: """Performs a measurement of the density matrix in the computational basis. This does not modify `density_matrix` unless the optional `out` is `density_matrix`. ...
def measure_density_matrix( density_matrix: np.ndarray, indices: List[int], out: np.ndarray = None) -> Tuple[List[bool], np.ndarray]: """Performs a measurement of the density matrix in the computational basis. This does not modify `density_matrix` unless the optional `out` is `density_matrix`. ...
[ "Performs", "a", "measurement", "of", "the", "density", "matrix", "in", "the", "computational", "basis", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/density_matrix_utils.py#L129-L208
[ "def", "measure_density_matrix", "(", "density_matrix", ":", "np", ".", "ndarray", ",", "indices", ":", "List", "[", "int", "]", ",", "out", ":", "np", ".", "ndarray", "=", "None", ")", "->", "Tuple", "[", "List", "[", "bool", "]", ",", "np", ".", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_probs
Returns the probabilities for a measurement on the given indices.
cirq/sim/density_matrix_utils.py
def _probs(density_matrix: np.ndarray, indices: List[int], num_qubits: int) -> List[float]: """Returns the probabilities for a measurement on the given indices.""" # Only diagonal elements matter. all_probs = np.diagonal( np.reshape(density_matrix, (2 ** num_qubits, 2 ** num_qubits))) # Shap...
def _probs(density_matrix: np.ndarray, indices: List[int], num_qubits: int) -> List[float]: """Returns the probabilities for a measurement on the given indices.""" # Only diagonal elements matter. all_probs = np.diagonal( np.reshape(density_matrix, (2 ** num_qubits, 2 ** num_qubits))) # Shap...
[ "Returns", "the", "probabilities", "for", "a", "measurement", "on", "the", "given", "indices", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/density_matrix_utils.py#L211-L227
[ "def", "_probs", "(", "density_matrix", ":", "np", ".", "ndarray", ",", "indices", ":", "List", "[", "int", "]", ",", "num_qubits", ":", "int", ")", "->", "List", "[", "float", "]", ":", "# Only diagonal elements matter.", "all_probs", "=", "np", ".", "d...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_validate_num_qubits
Validates that matrix's shape is a valid shape for qubits.
cirq/sim/density_matrix_utils.py
def _validate_num_qubits(density_matrix: np.ndarray) -> int: """Validates that matrix's shape is a valid shape for qubits. """ shape = density_matrix.shape half_index = len(shape) // 2 row_size = np.prod(shape[:half_index]) if len(shape) != 0 else 0 col_size = np.prod(shape[half_index:]) if len(...
def _validate_num_qubits(density_matrix: np.ndarray) -> int: """Validates that matrix's shape is a valid shape for qubits. """ shape = density_matrix.shape half_index = len(shape) // 2 row_size = np.prod(shape[:half_index]) if len(shape) != 0 else 0 col_size = np.prod(shape[half_index:]) if len(...
[ "Validates", "that", "matrix", "s", "shape", "is", "a", "valid", "shape", "for", "qubits", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/sim/density_matrix_utils.py#L230-L250
[ "def", "_validate_num_qubits", "(", "density_matrix", ":", "np", ".", "ndarray", ")", "->", "int", ":", "shape", "=", "density_matrix", ".", "shape", "half_index", "=", "len", "(", "shape", ")", "//", "2", "row_size", "=", "np", ".", "prod", "(", "shape"...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_apply_unitary_circuit
Applies a circuit's unitary effect to the given vector or matrix. This method assumes that the caller wants to ignore measurements. Args: circuit: The circuit to simulate. All operations must have a known matrix or decompositions leading to known matrices. Measurements are allo...
cirq/circuits/circuit.py
def _apply_unitary_circuit(circuit: Circuit, state: np.ndarray, qubits: Tuple[ops.Qid, ...], dtype: Type[np.number]) -> np.ndarray: """Applies a circuit's unitary effect to the given vector or matrix. This method assumes that the ...
def _apply_unitary_circuit(circuit: Circuit, state: np.ndarray, qubits: Tuple[ops.Qid, ...], dtype: Type[np.number]) -> np.ndarray: """Applies a circuit's unitary effect to the given vector or matrix. This method assumes that the ...
[ "Applies", "a", "circuit", "s", "unitary", "effect", "to", "the", "given", "vector", "or", "matrix", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1745-L1793
[ "def", "_apply_unitary_circuit", "(", "circuit", ":", "Circuit", ",", "state", ":", "np", ".", "ndarray", ",", "qubits", ":", "Tuple", "[", "ops", ".", "Qid", ",", "...", "]", ",", "dtype", ":", "Type", "[", "np", ".", "number", "]", ")", "->", "np...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_group_until_different
Groups runs of items that are identical according to a keying function. Args: items: The items to group. key: If two adjacent items produce the same output from this function, they will be grouped. value: Maps each item into a value to put in the group. Defaults to the ...
cirq/circuits/circuit.py
def _group_until_different(items: Iterable[TIn], key: Callable[[TIn], TKey], value=lambda e: e): """Groups runs of items that are identical according to a keying function. Args: items: The items to group. key: If two adjacent items produce t...
def _group_until_different(items: Iterable[TIn], key: Callable[[TIn], TKey], value=lambda e: e): """Groups runs of items that are identical according to a keying function. Args: items: The items to group. key: If two adjacent items produce t...
[ "Groups", "runs", "of", "items", "that", "are", "identical", "according", "to", "a", "keying", "function", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1829-L1854
[ "def", "_group_until_different", "(", "items", ":", "Iterable", "[", "TIn", "]", ",", "key", ":", "Callable", "[", "[", "TIn", "]", ",", "TKey", "]", ",", "value", "=", "lambda", "e", ":", "e", ")", ":", "return", "(", "(", "k", ",", "[", "value"...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.from_ops
Creates an empty circuit and appends the given operations. Args: operations: The operations to append to the new circuit. strategy: How to append the operations. device: Hardware that the circuit should be able to run on. Returns: The constructed circuit...
cirq/circuits/circuit.py
def from_ops(*operations: ops.OP_TREE, strategy: InsertStrategy = InsertStrategy.EARLIEST, device: devices.Device = devices.UnconstrainedDevice ) -> 'Circuit': """Creates an empty circuit and appends the given operations. Args: operations: ...
def from_ops(*operations: ops.OP_TREE, strategy: InsertStrategy = InsertStrategy.EARLIEST, device: devices.Device = devices.UnconstrainedDevice ) -> 'Circuit': """Creates an empty circuit and appends the given operations. Args: operations: ...
[ "Creates", "an", "empty", "circuit", "and", "appends", "the", "given", "operations", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L118-L134
[ "def", "from_ops", "(", "*", "operations", ":", "ops", ".", "OP_TREE", ",", "strategy", ":", "InsertStrategy", "=", "InsertStrategy", ".", "EARLIEST", ",", "device", ":", "devices", ".", "Device", "=", "devices", ".", "UnconstrainedDevice", ")", "->", "'Circ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit._approx_eq_
See `cirq.protocols.SupportsApproximateEquality`.
cirq/circuits/circuit.py
def _approx_eq_(self, other: Any, atol: Union[int, float]) -> bool: """See `cirq.protocols.SupportsApproximateEquality`.""" if not isinstance(other, type(self)): return NotImplemented return cirq.protocols.approx_eq( self._moments, other._moments, ...
def _approx_eq_(self, other: Any, atol: Union[int, float]) -> bool: """See `cirq.protocols.SupportsApproximateEquality`.""" if not isinstance(other, type(self)): return NotImplemented return cirq.protocols.approx_eq( self._moments, other._moments, ...
[ "See", "cirq", ".", "protocols", ".", "SupportsApproximateEquality", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L150-L158
[ "def", "_approx_eq_", "(", "self", ",", "other", ":", "Any", ",", "atol", ":", "Union", "[", "int", ",", "float", "]", ")", "->", "bool", ":", "if", "not", "isinstance", "(", "other", ",", "type", "(", "self", ")", ")", ":", "return", "NotImplement...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.with_device
Maps the current circuit onto a new device, and validates. Args: new_device: The new device that the circuit should be on. qubit_mapping: How to translate qubits from the old device into qubits on the new device. Returns: The translated circuit.
cirq/circuits/circuit.py
def with_device( self, new_device: devices.Device, qubit_mapping: Callable[[ops.Qid], ops.Qid] = lambda e: e, ) -> 'Circuit': """Maps the current circuit onto a new device, and validates. Args: new_device: The new device that the circuit should be on....
def with_device( self, new_device: devices.Device, qubit_mapping: Callable[[ops.Qid], ops.Qid] = lambda e: e, ) -> 'Circuit': """Maps the current circuit onto a new device, and validates. Args: new_device: The new device that the circuit should be on....
[ "Maps", "the", "current", "circuit", "onto", "a", "new", "device", "and", "validates", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L309-L329
[ "def", "with_device", "(", "self", ",", "new_device", ":", "devices", ".", "Device", ",", "qubit_mapping", ":", "Callable", "[", "[", "ops", ".", "Qid", "]", ",", "ops", ".", "Qid", "]", "=", "lambda", "e", ":", "e", ",", ")", "->", "'Circuit'", ":...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit._repr_pretty_
Print ASCII diagram in Jupyter.
cirq/circuits/circuit.py
def _repr_pretty_(self, p: Any, cycle: bool) -> None: """Print ASCII diagram in Jupyter.""" if cycle: # There should never be a cycle. This is just in case. p.text('Circuit(...)') else: p.text(self.to_text_diagram())
def _repr_pretty_(self, p: Any, cycle: bool) -> None: """Print ASCII diagram in Jupyter.""" if cycle: # There should never be a cycle. This is just in case. p.text('Circuit(...)') else: p.text(self.to_text_diagram())
[ "Print", "ASCII", "diagram", "in", "Jupyter", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L331-L337
[ "def", "_repr_pretty_", "(", "self", ",", "p", ":", "Any", ",", "cycle", ":", "bool", ")", "->", "None", ":", "if", "cycle", ":", "# There should never be a cycle. This is just in case.", "p", ".", "text", "(", "'Circuit(...)'", ")", "else", ":", "p", ".", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.next_moment_operating_on
Finds the index of the next moment that touches the given qubits. Args: qubits: We're looking for operations affecting any of these qubits. start_moment_index: The starting point of the search. max_distance: The number of moments (starting from the start index ...
cirq/circuits/circuit.py
def next_moment_operating_on(self, qubits: Iterable[ops.Qid], start_moment_index: int = 0, max_distance: int = None) -> Optional[int]: """Finds the index of the next moment that touches the given qubits. ...
def next_moment_operating_on(self, qubits: Iterable[ops.Qid], start_moment_index: int = 0, max_distance: int = None) -> Optional[int]: """Finds the index of the next moment that touches the given qubits. ...
[ "Finds", "the", "index", "of", "the", "next", "moment", "that", "touches", "the", "given", "qubits", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L354-L383
[ "def", "next_moment_operating_on", "(", "self", ",", "qubits", ":", "Iterable", "[", "ops", ".", "Qid", "]", ",", "start_moment_index", ":", "int", "=", "0", ",", "max_distance", ":", "int", "=", "None", ")", "->", "Optional", "[", "int", "]", ":", "ma...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.next_moments_operating_on
Finds the index of the next moment that touches each qubit. Args: qubits: The qubits to find the next moments acting on. start_moment_index: The starting point of the search. Returns: The index of the next moment that touches each qubit. If there is no s...
cirq/circuits/circuit.py
def next_moments_operating_on(self, qubits: Iterable[ops.Qid], start_moment_index: int = 0 ) -> Dict[ops.Qid, int]: """Finds the index of the next moment that touches each qubit. Args: qubi...
def next_moments_operating_on(self, qubits: Iterable[ops.Qid], start_moment_index: int = 0 ) -> Dict[ops.Qid, int]: """Finds the index of the next moment that touches each qubit. Args: qubi...
[ "Finds", "the", "index", "of", "the", "next", "moment", "that", "touches", "each", "qubit", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L385-L408
[ "def", "next_moments_operating_on", "(", "self", ",", "qubits", ":", "Iterable", "[", "ops", ".", "Qid", "]", ",", "start_moment_index", ":", "int", "=", "0", ")", "->", "Dict", "[", "ops", ".", "Qid", ",", "int", "]", ":", "next_moments", "=", "{", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.prev_moment_operating_on
Finds the index of the next moment that touches the given qubits. Args: qubits: We're looking for operations affecting any of these qubits. end_moment_index: The moment index just after the starting point of the reverse search. Defaults to the length of the list of ...
cirq/circuits/circuit.py
def prev_moment_operating_on( self, qubits: Sequence[ops.Qid], end_moment_index: Optional[int] = None, max_distance: Optional[int] = None) -> Optional[int]: """Finds the index of the next moment that touches the given qubits. Args: qubits: We'...
def prev_moment_operating_on( self, qubits: Sequence[ops.Qid], end_moment_index: Optional[int] = None, max_distance: Optional[int] = None) -> Optional[int]: """Finds the index of the next moment that touches the given qubits. Args: qubits: We'...
[ "Finds", "the", "index", "of", "the", "next", "moment", "that", "touches", "the", "given", "qubits", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L410-L452
[ "def", "prev_moment_operating_on", "(", "self", ",", "qubits", ":", "Sequence", "[", "ops", ".", "Qid", "]", ",", "end_moment_index", ":", "Optional", "[", "int", "]", "=", "None", ",", "max_distance", ":", "Optional", "[", "int", "]", "=", "None", ")", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.reachable_frontier_from
Determines how far can be reached into a circuit under certain rules. The location L = (qubit, moment_index) is *reachable* if and only if: a) L is one of the items in `start_frontier`. OR b) There is no operation at L and prev(L) = (qubit, moment_index-1) ...
cirq/circuits/circuit.py
def reachable_frontier_from( self, start_frontier: Dict[ops.Qid, int], *, is_blocker: Callable[[ops.Operation], bool] = lambda op: False ) -> Dict[ops.Qid, int]: """Determines how far can be reached into a circuit under certain rules. The location L =...
def reachable_frontier_from( self, start_frontier: Dict[ops.Qid, int], *, is_blocker: Callable[[ops.Operation], bool] = lambda op: False ) -> Dict[ops.Qid, int]: """Determines how far can be reached into a circuit under certain rules. The location L =...
[ "Determines", "how", "far", "can", "be", "reached", "into", "a", "circuit", "under", "certain", "rules", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L468-L621
[ "def", "reachable_frontier_from", "(", "self", ",", "start_frontier", ":", "Dict", "[", "ops", ".", "Qid", ",", "int", "]", ",", "*", ",", "is_blocker", ":", "Callable", "[", "[", "ops", ".", "Operation", "]", ",", "bool", "]", "=", "lambda", "op", "...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.findall_operations_between
Finds operations between the two given frontiers. If a qubit is in `start_frontier` but not `end_frontier`, its end index defaults to the end of the circuit. If a qubit is in `end_frontier` but not `start_frontier`, its start index defaults to the start of the circuit. Operations on qub...
cirq/circuits/circuit.py
def findall_operations_between(self, start_frontier: Dict[ops.Qid, int], end_frontier: Dict[ops.Qid, int], omit_crossing_operations: bool = False ) -> List[Tuple[int, ops.Operation...
def findall_operations_between(self, start_frontier: Dict[ops.Qid, int], end_frontier: Dict[ops.Qid, int], omit_crossing_operations: bool = False ) -> List[Tuple[int, ops.Operation...
[ "Finds", "operations", "between", "the", "two", "given", "frontiers", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L623-L671
[ "def", "findall_operations_between", "(", "self", ",", "start_frontier", ":", "Dict", "[", "ops", ".", "Qid", ",", "int", "]", ",", "end_frontier", ":", "Dict", "[", "ops", ".", "Qid", ",", "int", "]", ",", "omit_crossing_operations", ":", "bool", "=", "...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.findall_operations_until_blocked
Finds all operations until a blocking operation is hit. This returns a list of all operations from the starting frontier until a blocking operation is encountered. An operation is part of the list if it is involves a qubit in the start_frontier dictionary, comes after the moment listed...
cirq/circuits/circuit.py
def findall_operations_until_blocked( self, start_frontier: Dict[ops.Qid, int], is_blocker: Callable[[ops.Operation], bool] = lambda op: False ) -> List[Tuple[int, ops.Operation]]: """ Finds all operations until a blocking operation is hit. This returns a...
def findall_operations_until_blocked( self, start_frontier: Dict[ops.Qid, int], is_blocker: Callable[[ops.Operation], bool] = lambda op: False ) -> List[Tuple[int, ops.Operation]]: """ Finds all operations until a blocking operation is hit. This returns a...
[ "Finds", "all", "operations", "until", "a", "blocking", "operation", "is", "hit", ".", "This", "returns", "a", "list", "of", "all", "operations", "from", "the", "starting", "frontier", "until", "a", "blocking", "operation", "is", "encountered", ".", "An", "o...
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L673-L717
[ "def", "findall_operations_until_blocked", "(", "self", ",", "start_frontier", ":", "Dict", "[", "ops", ".", "Qid", ",", "int", "]", ",", "is_blocker", ":", "Callable", "[", "[", "ops", ".", "Operation", "]", ",", "bool", "]", "=", "lambda", "op", ":", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.operation_at
Finds the operation on a qubit within a moment, if any. Args: qubit: The qubit to check for an operation on. moment_index: The index of the moment to check for an operation within. Allowed to be beyond the end of the circuit. Returns: None if there i...
cirq/circuits/circuit.py
def operation_at(self, qubit: ops.Qid, moment_index: int) -> Optional[ops.Operation]: """Finds the operation on a qubit within a moment, if any. Args: qubit: The qubit to check for an operation on. moment_index: The index of the moment t...
def operation_at(self, qubit: ops.Qid, moment_index: int) -> Optional[ops.Operation]: """Finds the operation on a qubit within a moment, if any. Args: qubit: The qubit to check for an operation on. moment_index: The index of the moment t...
[ "Finds", "the", "operation", "on", "a", "qubit", "within", "a", "moment", "if", "any", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L719-L738
[ "def", "operation_at", "(", "self", ",", "qubit", ":", "ops", ".", "Qid", ",", "moment_index", ":", "int", ")", "->", "Optional", "[", "ops", ".", "Operation", "]", ":", "if", "not", "0", "<=", "moment_index", "<", "len", "(", "self", ".", "_moments"...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.findall_operations
Find the locations of all operations that satisfy a given condition. This returns an iterator of (index, operation) tuples where each operation satisfies op_cond(operation) is truthy. The indices are in order of the moments and then order of the ops within that moment. Args: ...
cirq/circuits/circuit.py
def findall_operations(self, predicate: Callable[[ops.Operation], bool] ) -> Iterable[Tuple[int, ops.Operation]]: """Find the locations of all operations that satisfy a given condition. This returns an iterator of (index, operation) tuples where each operation satisfi...
def findall_operations(self, predicate: Callable[[ops.Operation], bool] ) -> Iterable[Tuple[int, ops.Operation]]: """Find the locations of all operations that satisfy a given condition. This returns an iterator of (index, operation) tuples where each operation satisfi...
[ "Find", "the", "locations", "of", "all", "operations", "that", "satisfy", "a", "given", "condition", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L740-L758
[ "def", "findall_operations", "(", "self", ",", "predicate", ":", "Callable", "[", "[", "ops", ".", "Operation", "]", ",", "bool", "]", ")", "->", "Iterable", "[", "Tuple", "[", "int", ",", "ops", ".", "Operation", "]", "]", ":", "for", "index", ",", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.findall_operations_with_gate_type
Find the locations of all gate operations of a given type. Args: gate_type: The type of gate to find, e.g. XPowGate or MeasurementGate. Returns: An iterator (index, operation, gate)'s for operations with the given gate type.
cirq/circuits/circuit.py
def findall_operations_with_gate_type( self, gate_type: Type[T_DESIRED_GATE_TYPE] ) -> Iterable[Tuple[int, ops.GateOperation, T_DESIRED_GATE_TYPE]]: """Find the locations of all gate operations of a given type. Args: ...
def findall_operations_with_gate_type( self, gate_type: Type[T_DESIRED_GATE_TYPE] ) -> Iterable[Tuple[int, ops.GateOperation, T_DESIRED_GATE_TYPE]]: """Find the locations of all gate operations of a given type. Args: ...
[ "Find", "the", "locations", "of", "all", "gate", "operations", "of", "a", "given", "type", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L760-L780
[ "def", "findall_operations_with_gate_type", "(", "self", ",", "gate_type", ":", "Type", "[", "T_DESIRED_GATE_TYPE", "]", ")", "->", "Iterable", "[", "Tuple", "[", "int", ",", "ops", ".", "GateOperation", ",", "T_DESIRED_GATE_TYPE", "]", "]", ":", "result", "="...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.are_all_matches_terminal
Check whether all of the ops that satisfy a predicate are terminal. Args: predicate: A predicate on ops.Operations which is being checked. Returns: Whether or not all `Operation` s in a circuit that satisfy the given predicate are terminal.
cirq/circuits/circuit.py
def are_all_matches_terminal(self, predicate: Callable[[ops.Operation], bool]): """Check whether all of the ops that satisfy a predicate are terminal. Args: predicate: A predicate on ops.Operations which is being checked. Returns: Whether or not all `Operati...
def are_all_matches_terminal(self, predicate: Callable[[ops.Operation], bool]): """Check whether all of the ops that satisfy a predicate are terminal. Args: predicate: A predicate on ops.Operations which is being checked. Returns: Whether or not all `Operati...
[ "Check", "whether", "all", "of", "the", "ops", "that", "satisfy", "a", "predicate", "are", "terminal", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L786-L800
[ "def", "are_all_matches_terminal", "(", "self", ",", "predicate", ":", "Callable", "[", "[", "ops", ".", "Operation", "]", ",", "bool", "]", ")", ":", "return", "all", "(", "self", ".", "next_moment_operating_on", "(", "op", ".", "qubits", ",", "i", "+",...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit._pick_or_create_inserted_op_moment_index
Determines and prepares where an insertion will occur. Args: splitter_index: The index to insert at. op: The operation that will be inserted. strategy: The insertion strategy. Returns: The index of the (possibly new) moment where the insertion should ...
cirq/circuits/circuit.py
def _pick_or_create_inserted_op_moment_index( self, splitter_index: int, op: ops.Operation, strategy: InsertStrategy) -> int: """Determines and prepares where an insertion will occur. Args: splitter_index: The index to insert at. op: The operation that wi...
def _pick_or_create_inserted_op_moment_index( self, splitter_index: int, op: ops.Operation, strategy: InsertStrategy) -> int: """Determines and prepares where an insertion will occur. Args: splitter_index: The index to insert at. op: The operation that wi...
[ "Determines", "and", "prepares", "where", "an", "insertion", "will", "occur", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L802-L841
[ "def", "_pick_or_create_inserted_op_moment_index", "(", "self", ",", "splitter_index", ":", "int", ",", "op", ":", "ops", ".", "Operation", ",", "strategy", ":", "InsertStrategy", ")", "->", "int", ":", "if", "(", "strategy", "is", "InsertStrategy", ".", "NEW"...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.insert
Inserts operations into the circuit. Operations are inserted into the moment specified by the index and 'InsertStrategy'. Moments within the operation tree are inserted intact. Args: index: The index to insert all of the operations at. moment_or_opera...
cirq/circuits/circuit.py
def insert( self, index: int, moment_or_operation_tree: Union[ops.Moment, ops.OP_TREE], strategy: InsertStrategy = InsertStrategy.EARLIEST) -> int: """ Inserts operations into the circuit. Operations are inserted into the moment specified by the index ...
def insert( self, index: int, moment_or_operation_tree: Union[ops.Moment, ops.OP_TREE], strategy: InsertStrategy = InsertStrategy.EARLIEST) -> int: """ Inserts operations into the circuit. Operations are inserted into the moment specified by the index ...
[ "Inserts", "operations", "into", "the", "circuit", ".", "Operations", "are", "inserted", "into", "the", "moment", "specified", "by", "the", "index", "and", "InsertStrategy", ".", "Moments", "within", "the", "operation", "tree", "are", "inserted", "intact", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L863-L915
[ "def", "insert", "(", "self", ",", "index", ":", "int", ",", "moment_or_operation_tree", ":", "Union", "[", "ops", ".", "Moment", ",", "ops", ".", "OP_TREE", "]", ",", "strategy", ":", "InsertStrategy", "=", "InsertStrategy", ".", "EARLIEST", ")", "->", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.insert_into_range
Writes operations inline into an area of the circuit. Args: start: The start of the range (inclusive) to write the given operations into. end: The end of the range (exclusive) to write the given operations into. If there are still operations remaining, ...
cirq/circuits/circuit.py
def insert_into_range(self, operations: ops.OP_TREE, start: int, end: int) -> int: """Writes operations inline into an area of the circuit. Args: start: The start of the range (inclusive) to write the ...
def insert_into_range(self, operations: ops.OP_TREE, start: int, end: int) -> int: """Writes operations inline into an area of the circuit. Args: start: The start of the range (inclusive) to write the ...
[ "Writes", "operations", "inline", "into", "an", "area", "of", "the", "circuit", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L917-L961
[ "def", "insert_into_range", "(", "self", ",", "operations", ":", "ops", ".", "OP_TREE", ",", "start", ":", "int", ",", "end", ":", "int", ")", "->", "int", ":", "if", "not", "0", "<=", "start", "<=", "end", "<=", "len", "(", "self", ")", ":", "ra...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit._pick_inserted_ops_moment_indices
Greedily assigns operations to moments. Args: operations: The operations to assign to moments. start: The first moment to consider assignment to. frontier: The first moment to which an operation acting on a qubit can be assigned. Updated in place as operation...
cirq/circuits/circuit.py
def _pick_inserted_ops_moment_indices(operations: Sequence[ops.Operation], start: int = 0, frontier: Dict[ops.Qid, int] = None ) -> Tuple...
def _pick_inserted_ops_moment_indices(operations: Sequence[ops.Operation], start: int = 0, frontier: Dict[ops.Qid, int] = None ) -> Tuple...
[ "Greedily", "assigns", "operations", "to", "moments", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L964-L992
[ "def", "_pick_inserted_ops_moment_indices", "(", "operations", ":", "Sequence", "[", "ops", ".", "Operation", "]", ",", "start", ":", "int", "=", "0", ",", "frontier", ":", "Dict", "[", "ops", ".", "Qid", ",", "int", "]", "=", "None", ")", "->", "Tuple...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit._push_frontier
Inserts moments to separate two frontiers. After insertion n_new moments, the following holds: for q in late_frontier: early_frontier[q] <= late_frontier[q] + n_new for q in update_qubits: early_frontier[q] the identifies the same moment as before ...
cirq/circuits/circuit.py
def _push_frontier(self, early_frontier: Dict[ops.Qid, int], late_frontier: Dict[ops.Qid, int], update_qubits: Iterable[ops.Qid] = None ) -> Tuple[int, int]: """Inserts moments to separate two frontiers. After i...
def _push_frontier(self, early_frontier: Dict[ops.Qid, int], late_frontier: Dict[ops.Qid, int], update_qubits: Iterable[ops.Qid] = None ) -> Tuple[int, int]: """Inserts moments to separate two frontiers. After i...
[ "Inserts", "moments", "to", "separate", "two", "frontiers", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L994-L1035
[ "def", "_push_frontier", "(", "self", ",", "early_frontier", ":", "Dict", "[", "ops", ".", "Qid", ",", "int", "]", ",", "late_frontier", ":", "Dict", "[", "ops", ".", "Qid", ",", "int", "]", ",", "update_qubits", ":", "Iterable", "[", "ops", ".", "Qi...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit._insert_operations
Inserts operations at the specified moments. Appends new moments if necessary. Args: operations: The operations to insert. insertion_indices: Where to insert them, i.e. operations[i] is inserted into moments[insertion_indices[i]. Raises: Valu...
cirq/circuits/circuit.py
def _insert_operations(self, operations: Sequence[ops.Operation], insertion_indices: Sequence[int]) -> None: """Inserts operations at the specified moments. Appends new moments if necessary. Args: operations: The operations to in...
def _insert_operations(self, operations: Sequence[ops.Operation], insertion_indices: Sequence[int]) -> None: """Inserts operations at the specified moments. Appends new moments if necessary. Args: operations: The operations to in...
[ "Inserts", "operations", "at", "the", "specified", "moments", ".", "Appends", "new", "moments", "if", "necessary", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1037-L1066
[ "def", "_insert_operations", "(", "self", ",", "operations", ":", "Sequence", "[", "ops", ".", "Operation", "]", ",", "insertion_indices", ":", "Sequence", "[", "int", "]", ")", "->", "None", ":", "if", "len", "(", "operations", ")", "!=", "len", "(", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.insert_at_frontier
Inserts operations inline at frontier. Args: operations: the operations to insert start: the moment at which to start inserting the operations frontier: frontier[q] is the earliest moment in which an operation acting on qubit q can be placed.
cirq/circuits/circuit.py
def insert_at_frontier(self, operations: ops.OP_TREE, start: int, frontier: Dict[ops.Qid, int] = None ) -> Dict[ops.Qid, int]: """Inserts operations inline at frontier. Args: operatio...
def insert_at_frontier(self, operations: ops.OP_TREE, start: int, frontier: Dict[ops.Qid, int] = None ) -> Dict[ops.Qid, int]: """Inserts operations inline at frontier. Args: operatio...
[ "Inserts", "operations", "inline", "at", "frontier", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1068-L1100
[ "def", "insert_at_frontier", "(", "self", ",", "operations", ":", "ops", ".", "OP_TREE", ",", "start", ":", "int", ",", "frontier", ":", "Dict", "[", "ops", ".", "Qid", ",", "int", "]", "=", "None", ")", "->", "Dict", "[", "ops", ".", "Qid", ",", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.batch_remove
Removes several operations from a circuit. Args: removals: A sequence of (moment_index, operation) tuples indicating operations to delete from the moments that are present. All listed operations must actually be present or the edit will fail (without ...
cirq/circuits/circuit.py
def batch_remove(self, removals: Iterable[Tuple[int, ops.Operation]]) -> None: """Removes several operations from a circuit. Args: removals: A sequence of (moment_index, operation) tuples indicating operations to delete from the moments that are present....
def batch_remove(self, removals: Iterable[Tuple[int, ops.Operation]]) -> None: """Removes several operations from a circuit. Args: removals: A sequence of (moment_index, operation) tuples indicating operations to delete from the moments that are present....
[ "Removes", "several", "operations", "from", "a", "circuit", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1102-L1129
[ "def", "batch_remove", "(", "self", ",", "removals", ":", "Iterable", "[", "Tuple", "[", "int", ",", "ops", ".", "Operation", "]", "]", ")", "->", "None", ":", "copy", "=", "self", ".", "copy", "(", ")", "for", "i", ",", "op", "in", "removals", "...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.batch_insert_into
Inserts operations into empty spaces in existing moments. If any of the insertions fails (due to colliding with an existing operation), this method fails without making any changes to the circuit. Args: insert_intos: A sequence of (moment_index, new_operation) pairs...
cirq/circuits/circuit.py
def batch_insert_into(self, insert_intos: Iterable[Tuple[int, ops.Operation]] ) -> None: """Inserts operations into empty spaces in existing moments. If any of the insertions fails (due to colliding with an existing operation), this method fai...
def batch_insert_into(self, insert_intos: Iterable[Tuple[int, ops.Operation]] ) -> None: """Inserts operations into empty spaces in existing moments. If any of the insertions fails (due to colliding with an existing operation), this method fai...
[ "Inserts", "operations", "into", "empty", "spaces", "in", "existing", "moments", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1131-L1153
[ "def", "batch_insert_into", "(", "self", ",", "insert_intos", ":", "Iterable", "[", "Tuple", "[", "int", ",", "ops", ".", "Operation", "]", "]", ")", "->", "None", ":", "copy", "=", "self", ".", "copy", "(", ")", "for", "i", ",", "op", "in", "inser...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.batch_insert
Applies a batched insert operation to the circuit. Transparently handles the fact that earlier insertions may shift the index that later insertions should occur at. For example, if you insert an operation at index 2 and at index 4, but the insert at index 2 causes a new moment to be cre...
cirq/circuits/circuit.py
def batch_insert(self, insertions: Iterable[Tuple[int, ops.OP_TREE]]) -> None: """Applies a batched insert operation to the circuit. Transparently handles the fact that earlier insertions may shift the index that later insertions should occur at. For example, if you ...
def batch_insert(self, insertions: Iterable[Tuple[int, ops.OP_TREE]]) -> None: """Applies a batched insert operation to the circuit. Transparently handles the fact that earlier insertions may shift the index that later insertions should occur at. For example, if you ...
[ "Applies", "a", "batched", "insert", "operation", "to", "the", "circuit", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1155-L1192
[ "def", "batch_insert", "(", "self", ",", "insertions", ":", "Iterable", "[", "Tuple", "[", "int", ",", "ops", ".", "OP_TREE", "]", "]", ")", "->", "None", ":", "# Work on a copy in case validation fails halfway through.", "copy", "=", "self", ".", "copy", "(",...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.append
Appends operations onto the end of the circuit. Moments within the operation tree are appended intact. Args: moment_or_operation_tree: The moment or operation tree to append. strategy: How to pick/create the moment to put operations into.
cirq/circuits/circuit.py
def append( self, moment_or_operation_tree: Union[ops.Moment, ops.OP_TREE], strategy: InsertStrategy = InsertStrategy.EARLIEST): """Appends operations onto the end of the circuit. Moments within the operation tree are appended intact. Args: momen...
def append( self, moment_or_operation_tree: Union[ops.Moment, ops.OP_TREE], strategy: InsertStrategy = InsertStrategy.EARLIEST): """Appends operations onto the end of the circuit. Moments within the operation tree are appended intact. Args: momen...
[ "Appends", "operations", "onto", "the", "end", "of", "the", "circuit", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1194-L1206
[ "def", "append", "(", "self", ",", "moment_or_operation_tree", ":", "Union", "[", "ops", ".", "Moment", ",", "ops", ".", "OP_TREE", "]", ",", "strategy", ":", "InsertStrategy", "=", "InsertStrategy", ".", "EARLIEST", ")", ":", "self", ".", "insert", "(", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.clear_operations_touching
Clears operations that are touching given qubits at given moments. Args: qubits: The qubits to check for operations on. moment_indices: The indices of moments to check for operations within.
cirq/circuits/circuit.py
def clear_operations_touching(self, qubits: Iterable[ops.Qid], moment_indices: Iterable[int]): """Clears operations that are touching given qubits at given moments. Args: qubits: The qubits to check for operations on. ...
def clear_operations_touching(self, qubits: Iterable[ops.Qid], moment_indices: Iterable[int]): """Clears operations that are touching given qubits at given moments. Args: qubits: The qubits to check for operations on. ...
[ "Clears", "operations", "that", "are", "touching", "given", "qubits", "at", "given", "moments", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1208-L1222
[ "def", "clear_operations_touching", "(", "self", ",", "qubits", ":", "Iterable", "[", "ops", ".", "Qid", "]", ",", "moment_indices", ":", "Iterable", "[", "int", "]", ")", ":", "qubits", "=", "frozenset", "(", "qubits", ")", "for", "k", "in", "moment_ind...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.all_qubits
Returns the qubits acted upon by Operations in this circuit.
cirq/circuits/circuit.py
def all_qubits(self) -> FrozenSet[ops.Qid]: """Returns the qubits acted upon by Operations in this circuit.""" return frozenset(q for m in self._moments for q in m.qubits)
def all_qubits(self) -> FrozenSet[ops.Qid]: """Returns the qubits acted upon by Operations in this circuit.""" return frozenset(q for m in self._moments for q in m.qubits)
[ "Returns", "the", "qubits", "acted", "upon", "by", "Operations", "in", "this", "circuit", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1224-L1226
[ "def", "all_qubits", "(", "self", ")", "->", "FrozenSet", "[", "ops", ".", "Qid", "]", ":", "return", "frozenset", "(", "q", "for", "m", "in", "self", ".", "_moments", "for", "q", "in", "m", ".", "qubits", ")" ]
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.all_operations
Iterates over the operations applied by this circuit. Operations from earlier moments will be iterated over first. Operations within a moment are iterated in the order they were given to the moment's constructor.
cirq/circuits/circuit.py
def all_operations(self) -> Iterator[ops.Operation]: """Iterates over the operations applied by this circuit. Operations from earlier moments will be iterated over first. Operations within a moment are iterated in the order they were given to the moment's constructor. """ ...
def all_operations(self) -> Iterator[ops.Operation]: """Iterates over the operations applied by this circuit. Operations from earlier moments will be iterated over first. Operations within a moment are iterated in the order they were given to the moment's constructor. """ ...
[ "Iterates", "over", "the", "operations", "applied", "by", "this", "circuit", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1228-L1235
[ "def", "all_operations", "(", "self", ")", "->", "Iterator", "[", "ops", ".", "Operation", "]", ":", "return", "(", "op", "for", "moment", "in", "self", "for", "op", "in", "moment", ".", "operations", ")" ]
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit._unitary_
Converts the circuit into a unitary matrix, if possible. If the circuit contains any non-terminal measurements, the conversion into a unitary matrix fails (i.e. returns NotImplemented). Terminal measurements are ignored when computing the unitary matrix. The unitary matrix is the produc...
cirq/circuits/circuit.py
def _unitary_(self) -> Union[np.ndarray, NotImplementedType]: """Converts the circuit into a unitary matrix, if possible. If the circuit contains any non-terminal measurements, the conversion into a unitary matrix fails (i.e. returns NotImplemented). Terminal measurements are ignored wh...
def _unitary_(self) -> Union[np.ndarray, NotImplementedType]: """Converts the circuit into a unitary matrix, if possible. If the circuit contains any non-terminal measurements, the conversion into a unitary matrix fails (i.e. returns NotImplemented). Terminal measurements are ignored wh...
[ "Converts", "the", "circuit", "into", "a", "unitary", "matrix", "if", "possible", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1248-L1259
[ "def", "_unitary_", "(", "self", ")", "->", "Union", "[", "np", ".", "ndarray", ",", "NotImplementedType", "]", ":", "if", "not", "self", ".", "_has_unitary_", "(", ")", ":", "return", "NotImplemented", "return", "self", ".", "to_unitary_matrix", "(", "ign...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.to_unitary_matrix
Converts the circuit into a unitary matrix, if possible. Args: qubit_order: Determines how qubits are ordered when passing matrices into np.kron. qubits_that_should_be_present: Qubits that may or may not appear in operations within the circuit, but that s...
cirq/circuits/circuit.py
def to_unitary_matrix( self, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, qubits_that_should_be_present: Iterable[ops.Qid] = (), ignore_terminal_measurements: bool = True, dtype: Type[np.number] = np.complex128) -> np.ndarray: """Convert...
def to_unitary_matrix( self, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, qubits_that_should_be_present: Iterable[ops.Qid] = (), ignore_terminal_measurements: bool = True, dtype: Type[np.number] = np.complex128) -> np.ndarray: """Convert...
[ "Converts", "the", "circuit", "into", "a", "unitary", "matrix", "if", "possible", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1261-L1311
[ "def", "to_unitary_matrix", "(", "self", ",", "qubit_order", ":", "ops", ".", "QubitOrderOrList", "=", "ops", ".", "QubitOrder", ".", "DEFAULT", ",", "qubits_that_should_be_present", ":", "Iterable", "[", "ops", ".", "Qid", "]", "=", "(", ")", ",", "ignore_t...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.to_text_diagram
Returns text containing a diagram describing the circuit. Args: use_unicode_characters: Determines if unicode characters are allowed (as opposed to ascii-only diagrams). transpose: Arranges qubit wires vertically instead of horizontally. precision: Number of ...
cirq/circuits/circuit.py
def to_text_diagram( self, *, use_unicode_characters: bool = True, transpose: bool = False, precision: Optional[int] = 3, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT) -> str: """Returns text containing a diagram describing th...
def to_text_diagram( self, *, use_unicode_characters: bool = True, transpose: bool = False, precision: Optional[int] = 3, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT) -> str: """Returns text containing a diagram describing th...
[ "Returns", "text", "containing", "a", "diagram", "describing", "the", "circuit", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1389-L1419
[ "def", "to_text_diagram", "(", "self", ",", "*", ",", "use_unicode_characters", ":", "bool", "=", "True", ",", "transpose", ":", "bool", "=", "False", ",", "precision", ":", "Optional", "[", "int", "]", "=", "3", ",", "qubit_order", ":", "ops", ".", "Q...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.to_text_diagram_drawer
Returns a TextDiagramDrawer with the circuit drawn into it. Args: use_unicode_characters: Determines if unicode characters are allowed (as opposed to ascii-only diagrams). qubit_namer: Names qubits in diagram. Defaults to str. transpose: Arranges qubit wires ...
cirq/circuits/circuit.py
def to_text_diagram_drawer( self, *, use_unicode_characters: bool = True, qubit_namer: Optional[Callable[[ops.Qid], str]] = None, transpose: bool = False, precision: Optional[int] = 3, qubit_order: ops.QubitOrderOrList = ops.QubitOrder....
def to_text_diagram_drawer( self, *, use_unicode_characters: bool = True, qubit_namer: Optional[Callable[[ops.Qid], str]] = None, transpose: bool = False, precision: Optional[int] = 3, qubit_order: ops.QubitOrderOrList = ops.QubitOrder....
[ "Returns", "a", "TextDiagramDrawer", "with", "the", "circuit", "drawn", "into", "it", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1421-L1481
[ "def", "to_text_diagram_drawer", "(", "self", ",", "*", ",", "use_unicode_characters", ":", "bool", "=", "True", ",", "qubit_namer", ":", "Optional", "[", "Callable", "[", "[", "ops", ".", "Qid", "]", ",", "str", "]", "]", "=", "None", ",", "transpose", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit._to_qasm_output
Returns a QASM object equivalent to the circuit. Args: header: A multi-line string that is placed in a comment at the top of the QASM. Defaults to a cirq version specifier. precision: Number of digits to use when representing numbers. qubit_order: Determines ...
cirq/circuits/circuit.py
def _to_qasm_output( self, header: Optional[str] = None, precision: int = 10, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, ) -> QasmOutput: """Returns a QASM object equivalent to the circuit. Args: header: A multi-line strin...
def _to_qasm_output( self, header: Optional[str] = None, precision: int = 10, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, ) -> QasmOutput: """Returns a QASM object equivalent to the circuit. Args: header: A multi-line strin...
[ "Returns", "a", "QASM", "object", "equivalent", "to", "the", "circuit", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1502-L1526
[ "def", "_to_qasm_output", "(", "self", ",", "header", ":", "Optional", "[", "str", "]", "=", "None", ",", "precision", ":", "int", "=", "10", ",", "qubit_order", ":", "ops", ".", "QubitOrderOrList", "=", "ops", ".", "QubitOrder", ".", "DEFAULT", ",", "...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.to_qasm
Returns QASM equivalent to the circuit. Args: header: A multi-line string that is placed in a comment at the top of the QASM. Defaults to a cirq version specifier. precision: Number of digits to use when representing numbers. qubit_order: Determines how qubit...
cirq/circuits/circuit.py
def to_qasm(self, header: Optional[str] = None, precision: int = 10, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, ) -> str: """Returns QASM equivalent to the circuit. Args: header: A multi-line string that is pla...
def to_qasm(self, header: Optional[str] = None, precision: int = 10, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, ) -> str: """Returns QASM equivalent to the circuit. Args: header: A multi-line string that is pla...
[ "Returns", "QASM", "equivalent", "to", "the", "circuit", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1528-L1542
[ "def", "to_qasm", "(", "self", ",", "header", ":", "Optional", "[", "str", "]", "=", "None", ",", "precision", ":", "int", "=", "10", ",", "qubit_order", ":", "ops", ".", "QubitOrderOrList", "=", "ops", ".", "QubitOrder", ".", "DEFAULT", ",", ")", "-...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
Circuit.save_qasm
Save a QASM file equivalent to the circuit. Args: file_path: The location of the file where the qasm will be written. header: A multi-line string that is placed in a comment at the top of the QASM. Defaults to a cirq version specifier. precision: Number of di...
cirq/circuits/circuit.py
def save_qasm(self, file_path: Union[str, bytes, int], header: Optional[str] = None, precision: int = 10, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, ) -> None: """Save a QASM file equivalent to the circuit...
def save_qasm(self, file_path: Union[str, bytes, int], header: Optional[str] = None, precision: int = 10, qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT, ) -> None: """Save a QASM file equivalent to the circuit...
[ "Save", "a", "QASM", "file", "equivalent", "to", "the", "circuit", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/circuits/circuit.py#L1544-L1560
[ "def", "save_qasm", "(", "self", ",", "file_path", ":", "Union", "[", "str", ",", "bytes", ",", "int", "]", ",", "header", ":", "Optional", "[", "str", "]", "=", "None", ",", "precision", ":", "int", "=", "10", ",", "qubit_order", ":", "ops", ".", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
qasm
Returns QASM code for the given value, if possible. Different values require different sets of arguments. The general rule of thumb is that circuits don't need any, operations need a `QasmArgs`, and gates need both a `QasmArgs` and `qubits`. Args: val: The value to turn into QASM code. ...
cirq/protocols/qasm.py
def qasm(val: Any, *, args: Optional[QasmArgs] = None, qubits: Optional[Iterable['cirq.Qid']] = None, default: TDefault = RaiseTypeErrorIfNotProvided ) -> Union[str, TDefault]: """Returns QASM code for the given value, if possible. Different values require different...
def qasm(val: Any, *, args: Optional[QasmArgs] = None, qubits: Optional[Iterable['cirq.Qid']] = None, default: TDefault = RaiseTypeErrorIfNotProvided ) -> Union[str, TDefault]: """Returns QASM code for the given value, if possible. Different values require different...
[ "Returns", "QASM", "code", "for", "the", "given", "value", "if", "possible", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/qasm.py#L117-L170
[ "def", "qasm", "(", "val", ":", "Any", ",", "*", ",", "args", ":", "Optional", "[", "QasmArgs", "]", "=", "None", ",", "qubits", ":", "Optional", "[", "Iterable", "[", "'cirq.Qid'", "]", "]", "=", "None", ",", "default", ":", "TDefault", "=", "Rais...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
QasmArgs.format_field
Method of string.Formatter that specifies the output of format().
cirq/protocols/qasm.py
def format_field(self, value: Any, spec: str) -> str: """Method of string.Formatter that specifies the output of format().""" from cirq import ops # HACK: avoids cyclic dependency. if isinstance(value, (float, int)): if isinstance(value, float): value = round(value, ...
def format_field(self, value: Any, spec: str) -> str: """Method of string.Formatter that specifies the output of format().""" from cirq import ops # HACK: avoids cyclic dependency. if isinstance(value, (float, int)): if isinstance(value, float): value = round(value, ...
[ "Method", "of", "string", ".", "Formatter", "that", "specifies", "the", "output", "of", "format", "()", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/qasm.py#L55-L69
[ "def", "format_field", "(", "self", ",", "value", ":", "Any", ",", "spec", ":", "str", ")", "->", "str", ":", "from", "cirq", "import", "ops", "# HACK: avoids cyclic dependency.", "if", "isinstance", "(", "value", ",", "(", "float", ",", "int", ")", ")",...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
make_oracle
Gates implementing the function f(a) = a·factors + bias (mod 2).
examples/bernstein_vazirani.py
def make_oracle(input_qubits, output_qubit, secret_factor_bits, secret_bias_bit): """Gates implementing the function f(a) = a·factors + bias (mod 2).""" if secret_bias_bit: yield cirq.X(output_qubit) for qubit, bit in zip(input_qubits, secret_factor_...
def make_oracle(input_qubits, output_qubit, secret_factor_bits, secret_bias_bit): """Gates implementing the function f(a) = a·factors + bias (mod 2).""" if secret_bias_bit: yield cirq.X(output_qubit) for qubit, bit in zip(input_qubits, secret_factor_...
[ "Gates", "implementing", "the", "function", "f", "(", "a", ")", "=", "a·factors", "+", "bias", "(", "mod", "2", ")", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/examples/bernstein_vazirani.py#L82-L93
[ "def", "make_oracle", "(", "input_qubits", ",", "output_qubit", ",", "secret_factor_bits", ",", "secret_bias_bit", ")", ":", "if", "secret_bias_bit", ":", "yield", "cirq", ".", "X", "(", "output_qubit", ")", "for", "qubit", ",", "bit", "in", "zip", "(", "inp...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
make_bernstein_vazirani_circuit
Solves for factors in f(a) = a·factors + bias (mod 2) with one query.
examples/bernstein_vazirani.py
def make_bernstein_vazirani_circuit(input_qubits, output_qubit, oracle): """Solves for factors in f(a) = a·factors + bias (mod 2) with one query.""" c = cirq.Circuit() # Initialize qubits. c.append([ cirq.X(output_qubit), cirq.H(output_qubit), cirq.H.on_each(*input_qubits), ...
def make_bernstein_vazirani_circuit(input_qubits, output_qubit, oracle): """Solves for factors in f(a) = a·factors + bias (mod 2) with one query.""" c = cirq.Circuit() # Initialize qubits. c.append([ cirq.X(output_qubit), cirq.H(output_qubit), cirq.H.on_each(*input_qubits), ...
[ "Solves", "for", "factors", "in", "f", "(", "a", ")", "=", "a·factors", "+", "bias", "(", "mod", "2", ")", "with", "one", "query", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/examples/bernstein_vazirani.py#L96-L117
[ "def", "make_bernstein_vazirani_circuit", "(", "input_qubits", ",", "output_qubit", ",", "oracle", ")", ":", "c", "=", "cirq", ".", "Circuit", "(", ")", "# Initialize qubits.", "c", ".", "append", "(", "[", "cirq", ".", "X", "(", "output_qubit", ")", ",", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_tuple_of_big_endian_int
Returns the big-endian integers specified by groups of bits. Args: bit_groups: Groups of descending bits, each specifying a big endian integer with the 1s bit at the end. Returns: A tuple containing the integer for each group.
cirq/study/trial_result.py
def _tuple_of_big_endian_int(bit_groups: Tuple[np.ndarray, ...] ) -> Tuple[int, ...]: """Returns the big-endian integers specified by groups of bits. Args: bit_groups: Groups of descending bits, each specifying a big endian integer with the 1s bit at the end. ...
def _tuple_of_big_endian_int(bit_groups: Tuple[np.ndarray, ...] ) -> Tuple[int, ...]: """Returns the big-endian integers specified by groups of bits. Args: bit_groups: Groups of descending bits, each specifying a big endian integer with the 1s bit at the end. ...
[ "Returns", "the", "big", "-", "endian", "integers", "specified", "by", "groups", "of", "bits", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/study/trial_result.py#L35-L46
[ "def", "_tuple_of_big_endian_int", "(", "bit_groups", ":", "Tuple", "[", "np", ".", "ndarray", ",", "...", "]", ")", "->", "Tuple", "[", "int", ",", "...", "]", ":", "return", "tuple", "(", "_big_endian_int", "(", "bits", ")", "for", "bits", "in", "bit...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_big_endian_int
Returns the big-endian integer specified by the given bits. For example, [True, False, False, True, False] becomes binary 10010 which is 18 in decimal. Args: bits: Descending bits of the integer, with the 1s bit at the end. Returns: The integer.
cirq/study/trial_result.py
def _big_endian_int(bits: np.ndarray) -> int: """Returns the big-endian integer specified by the given bits. For example, [True, False, False, True, False] becomes binary 10010 which is 18 in decimal. Args: bits: Descending bits of the integer, with the 1s bit at the end. Returns: ...
def _big_endian_int(bits: np.ndarray) -> int: """Returns the big-endian integer specified by the given bits. For example, [True, False, False, True, False] becomes binary 10010 which is 18 in decimal. Args: bits: Descending bits of the integer, with the 1s bit at the end. Returns: ...
[ "Returns", "the", "big", "-", "endian", "integer", "specified", "by", "the", "given", "bits", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/study/trial_result.py#L49-L66
[ "def", "_big_endian_int", "(", "bits", ":", "np", ".", "ndarray", ")", "->", "int", ":", "result", "=", "0", "for", "e", "in", "bits", ":", "result", "<<=", "1", "if", "e", ":", "result", "|=", "1", "return", "result" ]
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
make_oracle
Gates implementing the secret function f(x).
examples/deutsch.py
def make_oracle(q0, q1, secret_function): """ Gates implementing the secret function f(x).""" # coverage: ignore if secret_function[0]: yield [CNOT(q0, q1), X(q1)] if secret_function[1]: yield CNOT(q0, q1)
def make_oracle(q0, q1, secret_function): """ Gates implementing the secret function f(x).""" # coverage: ignore if secret_function[0]: yield [CNOT(q0, q1), X(q1)] if secret_function[1]: yield CNOT(q0, q1)
[ "Gates", "implementing", "the", "secret", "function", "f", "(", "x", ")", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/examples/deutsch.py#L56-L64
[ "def", "make_oracle", "(", "q0", ",", "q1", ",", "secret_function", ")", ":", "# coverage: ignore", "if", "secret_function", "[", "0", "]", ":", "yield", "[", "CNOT", "(", "q0", ",", "q1", ")", ",", "X", "(", "q1", ")", "]", "if", "secret_function", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
chip_as_adjacency_list
Gives adjacency list representation of a chip. The adjacency list is constructed in order of above, left_of, below and right_of consecutively. Args: device: Chip to be converted. Returns: Map from nodes to list of qubits which represent all the neighbours of given qubit.
cirq/google/line/placement/chip.py
def chip_as_adjacency_list(device: 'cirq.google.XmonDevice', ) -> Dict[GridQubit, List[GridQubit]]: """Gives adjacency list representation of a chip. The adjacency list is constructed in order of above, left_of, below and right_of consecutively. Args: device: Chip to...
def chip_as_adjacency_list(device: 'cirq.google.XmonDevice', ) -> Dict[GridQubit, List[GridQubit]]: """Gives adjacency list representation of a chip. The adjacency list is constructed in order of above, left_of, below and right_of consecutively. Args: device: Chip to...
[ "Gives", "adjacency", "list", "representation", "of", "a", "chip", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/line/placement/chip.py#L75-L96
[ "def", "chip_as_adjacency_list", "(", "device", ":", "'cirq.google.XmonDevice'", ",", ")", "->", "Dict", "[", "GridQubit", ",", "List", "[", "GridQubit", "]", "]", ":", "c_set", "=", "set", "(", "device", ".", "qubits", ")", "c_adj", "=", "{", "}", "# ty...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
hhl_circuit
Constructs the HHL circuit. A is the input Hermitian matrix. C and t are tunable parameters for the algorithm. register_size is the size of the eigenvalue register. input_prep_gates is a list of gates to be applied to |0> to generate the desired input state |b>.
examples/hhl.py
def hhl_circuit(A, C, t, register_size, *input_prep_gates): """ Constructs the HHL circuit. A is the input Hermitian matrix. C and t are tunable parameters for the algorithm. register_size is the size of the eigenvalue register. input_prep_gates is a list of gates to be applied to |0> to genera...
def hhl_circuit(A, C, t, register_size, *input_prep_gates): """ Constructs the HHL circuit. A is the input Hermitian matrix. C and t are tunable parameters for the algorithm. register_size is the size of the eigenvalue register. input_prep_gates is a list of gates to be applied to |0> to genera...
[ "Constructs", "the", "HHL", "circuit", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/examples/hhl.py#L228-L276
[ "def", "hhl_circuit", "(", "A", ",", "C", ",", "t", ",", "register_size", ",", "*", "input_prep_gates", ")", ":", "ancilla", "=", "cirq", ".", "GridQubit", "(", "0", ",", "0", ")", "# to store eigenvalues of the matrix", "register", "=", "[", "cirq", ".", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
main
Simulates HHL with matrix input, and outputs Pauli observables of the resulting qubit state |x>. Expected observables are calculated from the expected solution |x>.
examples/hhl.py
def main(): """ Simulates HHL with matrix input, and outputs Pauli observables of the resulting qubit state |x>. Expected observables are calculated from the expected solution |x>. """ # Eigendecomposition: # (4.537, [-0.971555, -0.0578339+0.229643j]) # (0.349, [-0.236813, 0.237270-...
def main(): """ Simulates HHL with matrix input, and outputs Pauli observables of the resulting qubit state |x>. Expected observables are calculated from the expected solution |x>. """ # Eigendecomposition: # (4.537, [-0.971555, -0.0578339+0.229643j]) # (0.349, [-0.236813, 0.237270-...
[ "Simulates", "HHL", "with", "matrix", "input", "and", "outputs", "Pauli", "observables", "of", "the", "resulting", "qubit", "state", "|x", ">", ".", "Expected", "observables", "are", "calculated", "from", "the", "expected", "solution", "|x", ">", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/examples/hhl.py#L294-L325
[ "def", "main", "(", ")", ":", "# Eigendecomposition:", "# (4.537, [-0.971555, -0.0578339+0.229643j])", "# (0.349, [-0.236813, 0.237270-0.942137j])", "# |b> = (0.64510-0.47848j, 0.35490-0.47848j)", "# |x> = (-0.0662724-0.214548j, 0.784392-0.578192j)", "A", "=", "np", ".", "array", "...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
XmonSimulator._run
See definition in `cirq.SimulatesSamples`.
cirq/google/sim/xmon_simulator.py
def _run( self, circuit: circuits.Circuit, param_resolver: study.ParamResolver, repetitions: int, ) -> Dict[str, List[np.ndarray]]: """See definition in `cirq.SimulatesSamples`.""" circuit = protocols.resolve_parameters(circuit, param_resolver) _verify_xmon_c...
def _run( self, circuit: circuits.Circuit, param_resolver: study.ParamResolver, repetitions: int, ) -> Dict[str, List[np.ndarray]]: """See definition in `cirq.SimulatesSamples`.""" circuit = protocols.resolve_parameters(circuit, param_resolver) _verify_xmon_c...
[ "See", "definition", "in", "cirq", ".", "SimulatesSamples", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/sim/xmon_simulator.py#L144-L159
[ "def", "_run", "(", "self", ",", "circuit", ":", "circuits", ".", "Circuit", ",", "param_resolver", ":", "study", ".", "ParamResolver", ",", "repetitions", ":", "int", ",", ")", "->", "Dict", "[", "str", ",", "List", "[", "np", ".", "ndarray", "]", "...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
XmonSimulator._base_iterator
See definition in `cirq.SimulatesIntermediateState`. If the initial state is an int, the state is set to the computational basis state corresponding to this state. Otherwise if the initial state is a np.ndarray it is the full initial state. In this case it must be the correct size, be ...
cirq/google/sim/xmon_simulator.py
def _base_iterator( self, circuit: circuits.Circuit, qubit_order: ops.QubitOrderOrList, initial_state: Union[int, np.ndarray], perform_measurements: bool=True, ) -> Iterator['XmonStepResult']: """See definition in `cirq.SimulatesIntermediateState`. If the ini...
def _base_iterator( self, circuit: circuits.Circuit, qubit_order: ops.QubitOrderOrList, initial_state: Union[int, np.ndarray], perform_measurements: bool=True, ) -> Iterator['XmonStepResult']: """See definition in `cirq.SimulatesIntermediateState`. If the ini...
[ "See", "definition", "in", "cirq", ".", "SimulatesIntermediateState", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/sim/xmon_simulator.py#L211-L290
[ "def", "_base_iterator", "(", "self", ",", "circuit", ":", "circuits", ".", "Circuit", ",", "qubit_order", ":", "ops", ".", "QubitOrderOrList", ",", "initial_state", ":", "Union", "[", "int", ",", "np", ".", "ndarray", "]", ",", "perform_measurements", ":", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
XmonStepResult.set_state_vector
Updates the state of the simulator to the given new state. Args: state: If this is an int, then this is the state to reset the stepper to, expressed as an integer of the computational basis. Integer to bitwise indices is little endian. Otherwise if this is a np.n...
cirq/google/sim/xmon_simulator.py
def set_state_vector(self, state: Union[int, np.ndarray]): """Updates the state of the simulator to the given new state. Args: state: If this is an int, then this is the state to reset the stepper to, expressed as an integer of the computational basis. Integer to bit...
def set_state_vector(self, state: Union[int, np.ndarray]): """Updates the state of the simulator to the given new state. Args: state: If this is an int, then this is the state to reset the stepper to, expressed as an integer of the computational basis. Integer to bit...
[ "Updates", "the", "state", "of", "the", "simulator", "to", "the", "given", "new", "state", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/sim/xmon_simulator.py#L356-L370
[ "def", "set_state_vector", "(", "self", ",", "state", ":", "Union", "[", "int", ",", "np", ".", "ndarray", "]", ")", ":", "self", ".", "_stepper", ".", "reset_state", "(", "state", ")" ]
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
XmonStepResult.sample
Samples from the wave function at this point in the computation. Note that this does not collapse the wave function. Returns: Measurement results with True corresponding to the `|1>` state. The outer list is for repetitions, and the inner corresponds to measurements...
cirq/google/sim/xmon_simulator.py
def sample(self, qubits: List[ops.Qid], repetitions: int=1): """Samples from the wave function at this point in the computation. Note that this does not collapse the wave function. Returns: Measurement results with True corresponding to the `|1>` state. The outer list i...
def sample(self, qubits: List[ops.Qid], repetitions: int=1): """Samples from the wave function at this point in the computation. Note that this does not collapse the wave function. Returns: Measurement results with True corresponding to the `|1>` state. The outer list i...
[ "Samples", "from", "the", "wave", "function", "at", "this", "point", "in", "the", "computation", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/sim/xmon_simulator.py#L372-L384
[ "def", "sample", "(", "self", ",", "qubits", ":", "List", "[", "ops", ".", "Qid", "]", ",", "repetitions", ":", "int", "=", "1", ")", ":", "return", "self", ".", "_stepper", ".", "sample_measurements", "(", "indices", "=", "[", "self", ".", "qubit_ma...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
NoiseModel.noisy_moments
Adds possibly stateful noise to a series of moments. Args: moments: The moments to add noise to. system_qubits: A list of all qubits in the system. Returns: A sequence of OP_TREEs, with the k'th tree corresponding to the noisy operations for the k'th mom...
cirq/devices/noise_model.py
def noisy_moments(self, moments: 'Iterable[cirq.Moment]', system_qubits: Sequence['cirq.Qid'] ) -> Sequence['cirq.OP_TREE']: """Adds possibly stateful noise to a series of moments. Args: moments: The moments to add noise to. system_qubi...
def noisy_moments(self, moments: 'Iterable[cirq.Moment]', system_qubits: Sequence['cirq.Qid'] ) -> Sequence['cirq.OP_TREE']: """Adds possibly stateful noise to a series of moments. Args: moments: The moments to add noise to. system_qubi...
[ "Adds", "possibly", "stateful", "noise", "to", "a", "series", "of", "moments", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/devices/noise_model.py#L48-L73
[ "def", "noisy_moments", "(", "self", ",", "moments", ":", "'Iterable[cirq.Moment]'", ",", "system_qubits", ":", "Sequence", "[", "'cirq.Qid'", "]", ")", "->", "Sequence", "[", "'cirq.OP_TREE'", "]", ":", "if", "not", "hasattr", "(", "self", ".", "noisy_moment"...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
NoiseModel.noisy_moment
Adds noise to the operations from a moment. Args: moment: The moment to add noise to. system_qubits: A list of all qubits in the system. Returns: An OP_TREE corresponding to the noisy operations for the moment.
cirq/devices/noise_model.py
def noisy_moment(self, moment: 'cirq.Moment', system_qubits: Sequence['cirq.Qid']) -> 'cirq.OP_TREE': """Adds noise to the operations from a moment. Args: moment: The moment to add noise to. system_qubits: A list of all qubits in the system. Returns...
def noisy_moment(self, moment: 'cirq.Moment', system_qubits: Sequence['cirq.Qid']) -> 'cirq.OP_TREE': """Adds noise to the operations from a moment. Args: moment: The moment to add noise to. system_qubits: A list of all qubits in the system. Returns...
[ "Adds", "noise", "to", "the", "operations", "from", "a", "moment", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/devices/noise_model.py#L75-L92
[ "def", "noisy_moment", "(", "self", ",", "moment", ":", "'cirq.Moment'", ",", "system_qubits", ":", "Sequence", "[", "'cirq.Qid'", "]", ")", "->", "'cirq.OP_TREE'", ":", "if", "not", "hasattr", "(", "self", ".", "noisy_moments", ",", "'_not_overridden'", ")", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
NoiseModel.noisy_operation
Adds noise to an individual operation. Args: operation: The operation to make noisy. Returns: An OP_TREE corresponding to the noisy operations implementing the noisy version of the given operation.
cirq/devices/noise_model.py
def noisy_operation(self, operation: 'cirq.Operation') -> 'cirq.OP_TREE': """Adds noise to an individual operation. Args: operation: The operation to make noisy. Returns: An OP_TREE corresponding to the noisy operations implementing the noisy version of the ...
def noisy_operation(self, operation: 'cirq.Operation') -> 'cirq.OP_TREE': """Adds noise to an individual operation. Args: operation: The operation to make noisy. Returns: An OP_TREE corresponding to the noisy operations implementing the noisy version of the ...
[ "Adds", "noise", "to", "an", "individual", "operation", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/devices/noise_model.py#L94-L111
[ "def", "noisy_operation", "(", "self", ",", "operation", ":", "'cirq.Operation'", ")", "->", "'cirq.OP_TREE'", ":", "if", "not", "hasattr", "(", "self", ".", "noisy_moments", ",", "'_not_overridden'", ")", ":", "return", "self", ".", "noisy_moments", "(", "[",...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
measurement_key
Get the measurement key for the given value. Args: val: The value which has the measurement key.. default: Determines the fallback behavior when `val` doesn't have a measurement key. If `default` is not set, a TypeError is raised. If default is set to a value, that value is ...
cirq/protocols/measurement_key.py
def measurement_key( val: Any, default: Any = RaiseTypeErrorIfNotProvided): """Get the measurement key for the given value. Args: val: The value which has the measurement key.. default: Determines the fallback behavior when `val` doesn't have a measurement key. If `d...
def measurement_key( val: Any, default: Any = RaiseTypeErrorIfNotProvided): """Get the measurement key for the given value. Args: val: The value which has the measurement key.. default: Determines the fallback behavior when `val` doesn't have a measurement key. If `d...
[ "Get", "the", "measurement", "key", "for", "the", "given", "value", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/measurement_key.py#L51-L86
[ "def", "measurement_key", "(", "val", ":", "Any", ",", "default", ":", "Any", "=", "RaiseTypeErrorIfNotProvided", ")", ":", "getter", "=", "getattr", "(", "val", ",", "'_measurement_key_'", ",", "None", ")", "result", "=", "NotImplemented", "if", "getter", "...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
generate_supremacy_circuit_google_v2
Generates Google Random Circuits v2 as in github.com/sboixo/GRCS cz_v2. See also https://arxiv.org/abs/1807.10749 Args: qubits: qubit grid in which to generate the circuit. cz_depth: number of layers with CZ gates. seed: seed for the random instance. Returns: A circuit corr...
cirq/experiments/google_v2_supremacy_circuit.py
def generate_supremacy_circuit_google_v2(qubits: Iterable[devices.GridQubit], cz_depth: int, seed: int) -> circuits.Circuit: """ Generates Google Random Circuits v2 as in github.com/sboixo/GRCS cz_v2. See also https://arxiv.or...
def generate_supremacy_circuit_google_v2(qubits: Iterable[devices.GridQubit], cz_depth: int, seed: int) -> circuits.Circuit: """ Generates Google Random Circuits v2 as in github.com/sboixo/GRCS cz_v2. See also https://arxiv.or...
[ "Generates", "Google", "Random", "Circuits", "v2", "as", "in", "github", ".", "com", "/", "sboixo", "/", "GRCS", "cz_v2", ".", "See", "also", "https", ":", "//", "arxiv", ".", "org", "/", "abs", "/", "1807", ".", "10749" ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/experiments/google_v2_supremacy_circuit.py#L22-L81
[ "def", "generate_supremacy_circuit_google_v2", "(", "qubits", ":", "Iterable", "[", "devices", ".", "GridQubit", "]", ",", "cz_depth", ":", "int", ",", "seed", ":", "int", ")", "->", "circuits", ".", "Circuit", ":", "non_diagonal_gates", "=", "[", "ops", "."...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
generate_supremacy_circuit_google_v2_grid
Generates Google Random Circuits v2 as in github.com/sboixo/GRCS cz_v2. See also https://arxiv.org/abs/1807.10749 Args: n_rows: number of rows of a 2D lattice. n_cols: number of columns. cz_depth: number of layers with CZ gates. seed: seed for the random instance. Returns: ...
cirq/experiments/google_v2_supremacy_circuit.py
def generate_supremacy_circuit_google_v2_grid(n_rows: int, n_cols: int, cz_depth: int, seed: int ) -> circuits.Circuit: """ Generates Google Random Circuits v2 as in github.com/sboixo/GRCS cz_v2. See also https://arx...
def generate_supremacy_circuit_google_v2_grid(n_rows: int, n_cols: int, cz_depth: int, seed: int ) -> circuits.Circuit: """ Generates Google Random Circuits v2 as in github.com/sboixo/GRCS cz_v2. See also https://arx...
[ "Generates", "Google", "Random", "Circuits", "v2", "as", "in", "github", ".", "com", "/", "sboixo", "/", "GRCS", "cz_v2", ".", "See", "also", "https", ":", "//", "arxiv", ".", "org", "/", "abs", "/", "1807", ".", "10749" ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/experiments/google_v2_supremacy_circuit.py#L84-L106
[ "def", "generate_supremacy_circuit_google_v2_grid", "(", "n_rows", ":", "int", ",", "n_cols", ":", "int", ",", "cz_depth", ":", "int", ",", "seed", ":", "int", ")", "->", "circuits", ".", "Circuit", ":", "qubits", "=", "[", "devices", ".", "GridQubit", "("...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
generate_supremacy_circuit_google_v2_bristlecone
Generates Google Random Circuits v2 in Bristlecone. See also https://arxiv.org/abs/1807.10749 Args: n_rows: number of rows in a Bristlecone lattice. Note that we do not include single qubit corners. cz_depth: number of layers with CZ gates. seed: seed for the random instance. ...
cirq/experiments/google_v2_supremacy_circuit.py
def generate_supremacy_circuit_google_v2_bristlecone(n_rows: int, cz_depth: int, seed: int ) -> circuits.Circuit: """ Generates Google Random Circuits v2 in Bristlecone. See also https://arxiv.org/abs/1...
def generate_supremacy_circuit_google_v2_bristlecone(n_rows: int, cz_depth: int, seed: int ) -> circuits.Circuit: """ Generates Google Random Circuits v2 in Bristlecone. See also https://arxiv.org/abs/1...
[ "Generates", "Google", "Random", "Circuits", "v2", "in", "Bristlecone", ".", "See", "also", "https", ":", "//", "arxiv", ".", "org", "/", "abs", "/", "1807", ".", "10749" ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/experiments/google_v2_supremacy_circuit.py#L109-L149
[ "def", "generate_supremacy_circuit_google_v2_bristlecone", "(", "n_rows", ":", "int", ",", "cz_depth", ":", "int", ",", "seed", ":", "int", ")", "->", "circuits", ".", "Circuit", ":", "def", "get_qubits", "(", "n_rows", ")", ":", "def", "count_neighbors", "(",...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_choice
Choose a random element from a non-empty sequence. Use this instead of random.choice, with random.random(), for reproducibility
cirq/experiments/google_v2_supremacy_circuit.py
def _choice(rand_gen: Callable[[], float], sequence: Sequence[T]) -> T: """Choose a random element from a non-empty sequence. Use this instead of random.choice, with random.random(), for reproducibility """ return sequence[int(rand_gen() * len(sequence))]
def _choice(rand_gen: Callable[[], float], sequence: Sequence[T]) -> T: """Choose a random element from a non-empty sequence. Use this instead of random.choice, with random.random(), for reproducibility """ return sequence[int(rand_gen() * len(sequence))]
[ "Choose", "a", "random", "element", "from", "a", "non", "-", "empty", "sequence", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/experiments/google_v2_supremacy_circuit.py#L155-L160
[ "def", "_choice", "(", "rand_gen", ":", "Callable", "[", "[", "]", ",", "float", "]", ",", "sequence", ":", "Sequence", "[", "T", "]", ")", "->", "T", ":", "return", "sequence", "[", "int", "(", "rand_gen", "(", ")", "*", "len", "(", "sequence", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_make_cz_layer
Each layer index corresponds to a shift/transpose of this CZ pattern: ●───● ● ● ●───● ● ● . . . ● ● ●───● ● ● ●───● . . . ●───● ● ● ●───● ● ● . . . ● ● ●───● ● ● ●───● . . . ●───● ● ● ●───● ● ● . . . ● ● ●───● ...
cirq/experiments/google_v2_supremacy_circuit.py
def _make_cz_layer(qubits: Iterable[devices.GridQubit], layer_index: int ) -> Iterable[ops.Operation]: """ Each layer index corresponds to a shift/transpose of this CZ pattern: ●───● ● ● ●───● ● ● . . . ● ● ●───● ● ● ●───● . . . ●───● ● ● ●...
def _make_cz_layer(qubits: Iterable[devices.GridQubit], layer_index: int ) -> Iterable[ops.Operation]: """ Each layer index corresponds to a shift/transpose of this CZ pattern: ●───● ● ● ●───● ● ● . . . ● ● ●───● ● ● ●───● . . . ●───● ● ● ●...
[ "Each", "layer", "index", "corresponds", "to", "a", "shift", "/", "transpose", "of", "this", "CZ", "pattern", ":" ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/experiments/google_v2_supremacy_circuit.py#L174-L229
[ "def", "_make_cz_layer", "(", "qubits", ":", "Iterable", "[", "devices", ".", "GridQubit", "]", ",", "layer_index", ":", "int", ")", "->", "Iterable", "[", "ops", ".", "Operation", "]", ":", "# map to an internal layer index to match the cycle order of public circuits...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
MergeInteractions._op_to_matrix
Determines the effect of an operation on the given qubits. If the operation is a 1-qubit operation on one of the given qubits, or a 2-qubit operation on both of the given qubits, and also the operation has a known matrix, then a matrix is returned. Otherwise None is returned. A...
cirq/optimizers/merge_interactions.py
def _op_to_matrix(self, op: Optional[ops.Operation], qubits: Tuple[ops.Qid, ...] ) -> Optional[np.ndarray]: """Determines the effect of an operation on the given qubits. If the operation is a 1-qubit operation on one of the given qubits,...
def _op_to_matrix(self, op: Optional[ops.Operation], qubits: Tuple[ops.Qid, ...] ) -> Optional[np.ndarray]: """Determines the effect of an operation on the given qubits. If the operation is a 1-qubit operation on one of the given qubits,...
[ "Determines", "the", "effect", "of", "an", "operation", "on", "the", "given", "qubits", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/optimizers/merge_interactions.py#L90-L125
[ "def", "_op_to_matrix", "(", "self", ",", "op", ":", "Optional", "[", "ops", ".", "Operation", "]", ",", "qubits", ":", "Tuple", "[", "ops", ".", "Qid", ",", "...", "]", ")", "->", "Optional", "[", "np", ".", "ndarray", "]", ":", "q1", ",", "q2",...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
MergeInteractions._scan_two_qubit_ops_into_matrix
Accumulates operations affecting the given pair of qubits. The scan terminates when it hits the end of the circuit, finds an operation without a known matrix, or finds an operation that interacts the given qubits with other qubits. Args: circuit: The circuit to scan for ope...
cirq/optimizers/merge_interactions.py
def _scan_two_qubit_ops_into_matrix( self, circuit: circuits.Circuit, index: Optional[int], qubits: Tuple[ops.Qid, ...] ) -> Tuple[List[ops.Operation], List[int], np.ndarray]: """Accumulates operations affecting the given pair of qubits. The scan term...
def _scan_two_qubit_ops_into_matrix( self, circuit: circuits.Circuit, index: Optional[int], qubits: Tuple[ops.Qid, ...] ) -> Tuple[List[ops.Operation], List[int], np.ndarray]: """Accumulates operations affecting the given pair of qubits. The scan term...
[ "Accumulates", "operations", "affecting", "the", "given", "pair", "of", "qubits", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/optimizers/merge_interactions.py#L127-L176
[ "def", "_scan_two_qubit_ops_into_matrix", "(", "self", ",", "circuit", ":", "circuits", ".", "Circuit", ",", "index", ":", "Optional", "[", "int", "]", ",", "qubits", ":", "Tuple", "[", "ops", ".", "Qid", ",", "...", "]", ")", "->", "Tuple", "[", "List...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
MergeInteractions._flip_kron_order
Given M = sum(kron(a_i, b_i)), returns M' = sum(kron(b_i, a_i)).
cirq/optimizers/merge_interactions.py
def _flip_kron_order(mat4x4: np.ndarray) -> np.ndarray: """Given M = sum(kron(a_i, b_i)), returns M' = sum(kron(b_i, a_i)).""" result = np.array([[0] * 4] * 4, dtype=np.complex128) order = [0, 2, 1, 3] for i in range(4): for j in range(4): result[order[i], ord...
def _flip_kron_order(mat4x4: np.ndarray) -> np.ndarray: """Given M = sum(kron(a_i, b_i)), returns M' = sum(kron(b_i, a_i)).""" result = np.array([[0] * 4] * 4, dtype=np.complex128) order = [0, 2, 1, 3] for i in range(4): for j in range(4): result[order[i], ord...
[ "Given", "M", "=", "sum", "(", "kron", "(", "a_i", "b_i", "))", "returns", "M", "=", "sum", "(", "kron", "(", "b_i", "a_i", "))", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/optimizers/merge_interactions.py#L179-L186
[ "def", "_flip_kron_order", "(", "mat4x4", ":", "np", ".", "ndarray", ")", "->", "np", ".", "ndarray", ":", "result", "=", "np", ".", "array", "(", "[", "[", "0", "]", "*", "4", "]", "*", "4", ",", "dtype", "=", "np", ".", "complex128", ")", "or...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
control
Returns a Controlled version of the given value, if defined. Controllees define how to be controlled by defining a method controlled_by(self, control_qubits). Note that the method may return NotImplemented to indicate a particular controlling can't be done. Args: controllee: The gate, operatio...
cirq/protocols/control.py
def control(controllee: Union['cirq.Gate', op_tree.OP_TREE], control_qubits: Sequence['cirq.Qid'] = None, default: Any = RaiseTypeErrorIfNotProvided) -> Any: """Returns a Controlled version of the given value, if defined. Controllees define how to be controlled by defining a method ...
def control(controllee: Union['cirq.Gate', op_tree.OP_TREE], control_qubits: Sequence['cirq.Qid'] = None, default: Any = RaiseTypeErrorIfNotProvided) -> Any: """Returns a Controlled version of the given value, if defined. Controllees define how to be controlled by defining a method ...
[ "Returns", "a", "Controlled", "version", "of", "the", "given", "value", "if", "defined", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/control.py#L33-L79
[ "def", "control", "(", "controllee", ":", "Union", "[", "'cirq.Gate'", ",", "op_tree", ".", "OP_TREE", "]", ",", "control_qubits", ":", "Sequence", "[", "'cirq.Qid'", "]", "=", "None", ",", "default", ":", "Any", "=", "RaiseTypeErrorIfNotProvided", ")", "->"...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
inverse
Returns the inverse `val**-1` of the given value, if defined. An object can define an inverse by defining a __pow__(self, exponent) method that returns something besides NotImplemented when given the exponent -1. The inverse of iterables is by default defined to be the iterable's items, each inverted, ...
cirq/protocols/inverse.py
def inverse(val: Any, default: Any = RaiseTypeErrorIfNotProvided) -> Any: """Returns the inverse `val**-1` of the given value, if defined. An object can define an inverse by defining a __pow__(self, exponent) method that returns something besides NotImplemented when given the exponent -1. The inverse o...
def inverse(val: Any, default: Any = RaiseTypeErrorIfNotProvided) -> Any: """Returns the inverse `val**-1` of the given value, if defined. An object can define an inverse by defining a __pow__(self, exponent) method that returns something besides NotImplemented when given the exponent -1. The inverse o...
[ "Returns", "the", "inverse", "val", "**", "-", "1", "of", "the", "given", "value", "if", "defined", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/inverse.py#L81-L131
[ "def", "inverse", "(", "val", ":", "Any", ",", "default", ":", "Any", "=", "RaiseTypeErrorIfNotProvided", ")", "->", "Any", ":", "from", "cirq", "import", "ops", "# HACK: avoid circular import", "# Check if object defines an inverse via __pow__.", "raiser", "=", "geta...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
two_qubit_matrix_to_ion_operations
Decomposes a two-qubit operation into MS/single-qubit rotation 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. tolerance: A limit on the amount of error introduced by the ...
cirq/ion/ion_decomposition.py
def two_qubit_matrix_to_ion_operations(q0: ops.Qid, q1: ops.Qid, mat: np.ndarray, atol: float = 1e-8 ) -> List[ops.Operation]: """Decomposes a two-qubit operati...
def two_qubit_matrix_to_ion_operations(q0: ops.Qid, q1: ops.Qid, mat: np.ndarray, atol: float = 1e-8 ) -> List[ops.Operation]: """Decomposes a two-qubit operati...
[ "Decomposes", "a", "two", "-", "qubit", "operation", "into", "MS", "/", "single", "-", "qubit", "rotation", "gates", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ion/ion_decomposition.py#L32-L52
[ "def", "two_qubit_matrix_to_ion_operations", "(", "q0", ":", "ops", ".", "Qid", ",", "q1", ":", "ops", ".", "Qid", ",", "mat", ":", "np", ".", "ndarray", ",", "atol", ":", "float", "=", "1e-8", ")", "->", "List", "[", "ops", ".", "Operation", "]", ...
0827da80dd7880e5b923eb69407e980ed9bc0bd2
train
_parity_interaction
Yields an XX interaction framed by the given operation.
cirq/ion/ion_decomposition.py
def _parity_interaction(q0: ops.Qid, q1: ops.Qid, rads: float, atol: float, gate: Optional[ops.Gate] = None): """Yields an XX interaction framed by the given operation.""" if abs(rads) < atol: return if...
def _parity_interaction(q0: ops.Qid, q1: ops.Qid, rads: float, atol: float, gate: Optional[ops.Gate] = None): """Yields an XX interaction framed by the given operation.""" if abs(rads) < atol: return if...
[ "Yields", "an", "XX", "interaction", "framed", "by", "the", "given", "operation", "." ]
quantumlib/Cirq
python
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ion/ion_decomposition.py#L93-L111
[ "def", "_parity_interaction", "(", "q0", ":", "ops", ".", "Qid", ",", "q1", ":", "ops", ".", "Qid", ",", "rads", ":", "float", ",", "atol", ":", "float", ",", "gate", ":", "Optional", "[", "ops", ".", "Gate", "]", "=", "None", ")", ":", "if", "...
0827da80dd7880e5b923eb69407e980ed9bc0bd2