cirq.Circuit¶

class
cirq.
Circuit
(*contents: Union[cirq.ops.raw_types.Operation, cirq.ops.op_tree.OpTree], strategy: cirq.circuits.insert_strategy.InsertStrategy = cirq.InsertStrategy.EARLIEST, device: cirq.devices.device.Device = cirq.UNCONSTRAINED_DEVICE)[source]¶ A mutable list of groups of operations to apply to some qubits.
Methods returning information about the circuit:next_moment_operating_onprev_moment_operating_onnext_moments_operating_onoperation_atall_qubitsall_operationsfindall_operationsfindall_operations_betweenfindall_operations_until_blockedfindall_operations_with_gate_typereachable_frontier_fromhas_measurementsare_all_matches_terminalare_all_measurements_terminalunitaryfinal_wavefunctionto_text_diagramto_text_diagram_drawerMethods for mutation:insertappendinsert_into_rangeclear_operations_touchingbatch_insertbatch_removebatch_insert_intoinsert_at_frontierCircuits can also be iterated over,for moment in circuit:…and sliced,circuit[1:3] is a new Circuit made up of two moments, the first beingcircuit[1] and the second being circuit[2];circuit[:, qubit] is a new Circuit with the same moments, but with onlythose operations which act on the given Qubit;circuit[:, qubits], where ‘qubits’ is list of Qubits, is a new Circuitwith the same moments, but only with those operations which touchany of the given qubits;circuit[1:3, qubit] is equivalent to circuit[1:3][:, qubit];circuit[1:3, qubits] is equivalent to circuit[1:3][:, qubits];and concatenated,circuit1 + circuit2 is a new Circuit made up of the moments in circuit1followed by the moments in circuit2;and multiplied by an integer,circuit * k is a new Circuit made up of the moments in circuit repeatedk times.and mutated,circuit[1:7] = [Moment(…)]
__init__
(*contents: Union[cirq.ops.raw_types.Operation, cirq.ops.op_tree.OpTree], strategy: cirq.circuits.insert_strategy.InsertStrategy = cirq.InsertStrategy.EARLIEST, device: cirq.devices.device.Device = cirq.UNCONSTRAINED_DEVICE) → None[source]¶ Initializes a circuit.
 Parameters
contents – The initial list of moments and operations defining the circuit. You can also pass in operations, lists of operations, or generally anything meeting the cirq.OP_TREE contract. Nonmoment entries will be inserted according to the specified insertion strategy.
strategy – When initializing the circuit with operations and moments from contents, this determines how the operations are packed together. This option does not affect later insertions into the circuit.
device – Hardware that the circuit should be able to run on.
