pytket.circuit.Circuit

Circuit objects provide an abstraction of quantum circuits. They consist of a set of qubits/quantum wires and a collection of operations applied to them in a given order. These wires have open inputs and outputs, rather than assuming any fixed input state.

See the pytket User Manual for a step-by-step tutorial on constructing circuits.

See also the notebook tutorials on circuit generation and circuit analysis.

Many of the Circuit methods described below append a gate or box to the end of the circuit. Where kwargs are indicated in these methods, the following keyword arguments are supported:

  • opgroup (str): name of the associated operation group, if any

  • condition (Bit, BitLogicExp or Predicate): classical condition for applying operation

  • condition_bits (list of Bit): classical bits on which to condition operation

  • condition_value (int): required value of condition bits (little-endian), defaulting to all-1s if not specified

(Thus there are two ways to express classical conditions: either using a general condition, or using the pair condition_bits and condition_value to condition on a specified set of bit values.)

class pytket.circuit.Circuit

Encapsulates a quantum circuit using a DAG representation.

>>> from pytket import Circuit
>>> c = Circuit(4,2) # Create a circuit with 4 qubits and 2 classical bits
>>> c.H(0) # Apply a gate to qubit 0
>>> c.Rx(0.5,1) # Angles of rotation are expressed in half-turns (i.e. 0.5 means PI/2)
>>> c.Measure(1,0) # Measure qubit 1, saving result in bit 0
__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pytket._tket.circuit.Circuit) -> None

Constructs a circuit with a completely empty DAG.

  1. __init__(self: pytket._tket.circuit.Circuit, name: str) -> None

Constructs a named circuit with a completely empty DAG.

Parameters:

name – name for the circuit

  1. __init__(self: pytket._tket.circuit.Circuit, n_qubits: int, name: Optional[str] = None) -> None

Constructs a circuit with a given number of qubits/blank wires.

>>> c = Circuit()
>>> c.add_blank_wires(3)

is equivalent to

>>> c = Circuit(3)
Parameters:
  • n_qubits – The number of qubits in the circuit

  • name – Optional name for the circuit.

  1. __init__(self: pytket._tket.circuit.Circuit, n_qubits: int, n_bits: int, name: Optional[str] = None) -> None

Constructs a circuit with a given number of quantum and classical bits

Parameters:
  • n_qubits – The number of qubits in the circuit

  • n_bits – The number of classical bits in the circuit

  • name – Optional name for the circuit.

__iter__(self: pytket._tket.circuit.Circuit) Iterator[pytket._tket.circuit.Command]

Iterate through the circuit, a Command at a time.

__rshift__(self: pytket._tket.circuit.Circuit, arg0: pytket._tket.circuit.Circuit) pytket._tket.circuit.Circuit

Creates a new Circuit, corresponding to the sequential composition of the given Circuits. Any qubits/bits with the same ids will be unified. Any ids without a match will be added in parallel.

add_gate(*args, **kwargs)

Overloaded function.

  1. add_gate(self: pytket._tket.circuit.Circuit, Op: pytket._tket.circuit.Op, args: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Appends a single operation to the end of the circuit on some particular qubits/bits. The number of qubits/bits specified must match the arity of the gate.

  1. add_gate(self: pytket._tket.circuit.Circuit, Op: pytket._tket.circuit.Op, args: Sequence[pytket._tket.unit_id.UnitID], **kwargs) -> pytket._tket.circuit.Circuit

Appends a single operation to the end of the circuit on some particular qubits/bits. The number of qubits/bits specified must match the arity of the gate.

  1. add_gate(self: pytket._tket.circuit.Circuit, type: pytket._tket.circuit.OpType, args: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Appends a single (non-parameterised) gate to the end of the circuit on some particular qubits from the default register (‘q’). The number of qubits specified must match the arity of the gate. For OpType.Measure operations the bit from the default register should follow the qubit.

>>> c.add_gate(OpType.H, [0]) # equivalent to c.H(0)
>>> c.add_gate(OpType.CX, [0,1]) # equivalent to c.CX(0,1)
Parameters:
  • type – The type of operation to add

  • args – The list of indices for the qubits/bits to which the operation is applied

  • kwargs – Additional properties for classical conditions

Returns:

the new Circuit

  1. add_gate(self: pytket._tket.circuit.Circuit, type: pytket._tket.circuit.OpType, args: Sequence[pytket._tket.unit_id.UnitID], **kwargs) -> pytket._tket.circuit.Circuit

Appends a single (non-parameterised) gate to the end of the circuit on some particular qubits from the default register (‘q’). The number of qubits specified must match the arity of the gate. For OpType.Measure operations the bit from the default register should follow the qubit.

>>> c.add_gate(OpType.H, [0]) # equivalent to c.H(0)
>>> c.add_gate(OpType.CX, [0,1]) # equivalent to c.CX(0,1)
Parameters:
  • type – The type of operation to add

  • args – The qubits/bits to apply the gate to

  • kwargs – Additional properties for classical conditions

Returns:

the new Circuit

  1. add_gate(self: pytket._tket.circuit.Circuit, type: pytket._tket.circuit.OpType, angle: typing.Union[sympy.Expr, float], args: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Appends a single gate, parameterised by an expression, to the end of circuit on some particular qubits from the default register (‘q’).

Parameters:
  • type – The type of gate to add

  • angle – The parameter for the gate in halfturns

  • args – The list of indices for the qubits to which the operation is applied

  • kwargs – Additional properties for classical conditions

Returns:

the new Circuit

  1. add_gate(self: pytket._tket.circuit.Circuit, type: pytket._tket.circuit.OpType, angle: typing.Union[sympy.Expr, float], args: Sequence[pytket._tket.unit_id.UnitID], **kwargs) -> pytket._tket.circuit.Circuit

Appends a single gate, parameterised by an expression, to the end of circuit on some particular qubits from the default register (‘q’).

Parameters:
  • type – The type of gate to add

  • angle – The parameter for the gate in halfturns

  • args – The qubits/bits to apply the gate to

  • kwargs – Additional properties for classical conditions

Returns:

the new Circuit

  1. add_gate(self: pytket._tket.circuit.Circuit, type: pytket._tket.circuit.OpType, angles: Sequence[typing.Union[sympy.Expr, float]], args: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Appends a single gate, parameterised with a vector of expressions corresponding to halfturns, to the end of circuit on some particular qubits from the default register (‘q’).

Parameters:
  • type – The type of gate to add

  • angles – The parameters for the gate in halfturns

  • args – The list of indices for the qubits to which the operation is applied

  • kwargs – Additional properties for classical conditions

Returns:

the new Circuit

  1. add_gate(self: pytket._tket.circuit.Circuit, type: pytket._tket.circuit.OpType, angles: Sequence[typing.Union[sympy.Expr, float]], args: Sequence[pytket._tket.unit_id.UnitID], **kwargs) -> pytket._tket.circuit.Circuit

Appends a single gate to the end of the circuit

Parameters:
  • type – The type of gate to add

  • params – The parameters for the gate in halfturns

  • args – The qubits/bits to apply the gate to

  • kwargs – Additional properties for classical conditions

Returns:

the new Circuit

append(self: pytket._tket.circuit.Circuit, circuit: pytket._tket.circuit.Circuit) None

In-place sequential composition of circuits, appending a copy of the argument onto the end of the circuit. Inputs and Outputs are unified if they share the same id, defaulting to parallel composition if there is no match.

Parameters:

circuit – The circuit to be appended to the end of self

add_circuit(*args, **kwargs)

Overloaded function.

  1. add_circuit(self: pytket._tket.circuit.Circuit, circuit: pytket._tket.circuit.Circuit, qubits: Sequence[pytket._tket.unit_id.Qubit], bits: Sequence[pytket._tket.unit_id.Bit] = []) -> pytket._tket.circuit.Circuit

In-place sequential composition of circuits, appending a copy of the argument onto the end of the circuit. Connects qubits and bits with the same behaviour as add_gate().

Parameters:
  • circuit – The circuit to be appended to the end of self

  • qubits – List mapping the (default register) qubits of circuit to the qubits of self

  • bits – List mapping the (default register) bits of circuit to the bits of self

Returns:

the new Circuit

  1. add_circuit(self: pytket._tket.circuit.Circuit, circuit: pytket._tket.circuit.Circuit, qubits: Sequence[int], bits: Sequence[int] = []) -> pytket._tket.circuit.Circuit

In-place sequential composition of circuits, appending a copy of the argument onto the end of the circuit. Connects qubits and bits with the same behaviour as add_gate().

Parameters:
  • circuit – The circuit to be appended to the end of self

  • qubits – List mapping the (default register) qubits of circuit to the (default register) qubits of self

  • bits – List mapping the (default register) bits of circuit to the (default register) bits of self

Returns:

the new Circuit

add_qubit(self: pytket._tket.circuit.Circuit, id: pytket._tket.unit_id.Qubit, reject_dups: bool = True) None

Constructs a single qubit with the given id.

Parameters:
  • id – Unique id for the qubit

  • reject_dups – Fail if there is already a qubit in this circuit with the id. Default to True

add_bit(self: pytket._tket.circuit.Circuit, id: pytket._tket.unit_id.Bit, reject_dups: bool = True) None

Constructs a single bit with the given id.

Parameters:
  • id – Unique id for the bit

  • reject_dups – Fail if there is already a bit in this circuit with the id. Default to True

add_phase(self: pytket._tket.circuit.Circuit, a: Union[sympy.Expr, float]) pytket._tket.circuit.Circuit

Add a global phase to the circuit.

Parameters:

a – Phase to add, in halfturns

Returns:

circuit with added phase

property name
property n_qubits

the number of qubits in the circuit

Type:

return

property n_bits

the number of classiclal bits in the circuit

Type:

return

property phase

the global phase applied to the circuit, in halfturns (not meaningful for circuits with classical interactions)

Type:

return

property qubits

A list of all qubit ids in the circuit

property bits

A list of all classical bit ids in the circuit

property n_gates

the number of gates in the Circuit

Type:

return

add_q_register(*args, **kwargs)

Overloaded function.

  1. add_q_register(self: pytket._tket.circuit.Circuit, name: str, size: int) -> pytket._tket.unit_id.QubitRegister

Constructs a new quantum register with a given name and number of qubits.

Parameters:
  • name – Unique readable name for the register

  • size – Number of qubits required

Returns:

a map from index to the corresponding UnitIDs

  1. add_q_register(self: pytket._tket.circuit.Circuit, register: pytket._tket.unit_id.QubitRegister) -> pytket._tket.unit_id.QubitRegister

Adds QubitRegister to Circuit

Parameters:

register – QubitRegister

get_q_register(self: pytket._tket.circuit.Circuit, name: str) pytket._tket.unit_id.QubitRegister

Get the quantum register with the given name.

Parameters:

name – name for the register

Returns:

the retrieved QubitRegister

add_c_register(*args, **kwargs)

Overloaded function.

  1. add_c_register(self: pytket._tket.circuit.Circuit, name: str, size: int) -> pytket._tket.unit_id.BitRegister

Constructs a new classical register with a given name and number of bits.

Parameters:
  • name – Unique readable name for the register

  • size – Number of bits required

Returns:

a map from index to the corresponding UnitIDs

  1. add_c_register(self: pytket._tket.circuit.Circuit, register: pytket._tket.unit_id.BitRegister) -> pytket._tket.unit_id.BitRegister

Adds BitRegister to Circuit

Parameters:

register – BitRegister

get_c_register(self: pytket._tket.circuit.Circuit, name: str) pytket._tket.unit_id.BitRegister

Get the classical register with the given name.

Parameters:

name – name for the register

Returns:

the retrieved BitRegister

property q_registers

Get all quantum registers.

The list only includes registers that are singly-indexed contiguously from zero.

Returns:

List of QubitRegister

property c_registers

Get all classical registers.

The list only includes registers that are singly-indexed contiguously from zero.

Returns:

List of BitRegister

rename_units(self: pytket._tket.circuit.Circuit, map: dict[pytket._tket.unit_id.UnitID | pytket._tket.unit_id.Qubit | pytket._tket.unit_id.Bit, pytket._tket.unit_id.UnitID | pytket._tket.unit_id.Qubit | pytket._tket.unit_id.Bit]) bool

Rename qubits and bits simultaneously according to the map of ids provided

Parameters:

map – Dictionary from current ids to new ids

add_blank_wires(self: pytket._tket.circuit.Circuit, number: int) None

Adds a number of new qubits to the circuit. These will be added to the default register (‘q’) if possible, filling out the unused indices from 0.

Parameters:

number – Number of qubits to add

remove_blank_wires(self: pytket._tket.circuit.Circuit, keep_blank_classical_wires: bool = False) None

Removes any Input-Output pairs in the DAG with no intervening operations, i.e. removes untouched qubits/bits from the circuit. This may occur when optimisations recognise that the operations on a qubit reduce to the identity, or when routing adds wires to “fill out” the architecture. This operation will only remove empty classical wires if there are no used bits with a higher index in the same register.

Parameters:

keep_blank_classical_wires – select if empty classical wires should not be removed

flatten_registers(self: pytket._tket.circuit.Circuit, relabel_classical_expression: bool = True) dict[pytket._tket.unit_id.UnitID, pytket._tket.unit_id.UnitID]

Combines all qubits into a single register namespace with the default name, and likewise for bits

Parameters:

relabel_classical_expression – Determines whether python classical expressions held in ClassicalExpBox have their expression relabelled to match relabelled Bit.

property qubit_readout

A map from qubit to its (left-to-right) index in readouts from backends. A qubit will feature in this map if it is measured and neither it nor the bit containing the measurement result is subsequently acted on

property bit_readout

A map from bit to its (left-to-right) index in readouts from backends (following the increasing lexicographic order convention)

property opgroups

A set of all opgroup names in the circuit

property is_simple

Checks that the circuit has only 1 quantum and 1 classic register using the default names (‘q’ and ‘c’). This means it is suitable to refer to qubits simply by their integer indices.

property qubit_to_bit_map

A map from qubit to the bit it is measured to. A qubit will feature in this map if it is measured and neither it nor the bit containing the measurement result is subsequently acted on

commands_of_type(self: pytket._tket.circuit.Circuit, optype: pytket._tket.circuit.OpType) list[pytket._tket.circuit.Command]

Get all commands in a circuit of a given type.

The order is consistent with the causal order of the operations in the circuit.

Parameters:

optype – operation type

Returns:

list of Command

ops_of_type(self: pytket._tket.circuit.Circuit, optype: pytket._tket.circuit.OpType) list[pytket._tket.circuit.Op]

Get all operations in the circuit of a given type.

The order is not guaranteed.

Parameters:

optype – operation type

Returns:

list of Op

n_gates_of_type(self: pytket._tket.circuit.Circuit, type: pytket._tket.circuit.OpType, include_conditional: bool = False) int

Returns the number of vertices in the dag of a given operation type.

>>> c.CX(0,1)
>>> c.H(0)
>>> c.CX(0,1)
>>> c.n_gates_of_type(OpType.CX)
2
Parameters:
  • type – The operation type to search for

  • include_conditional – if set to true, conditional gates will be counted, too

Returns:

the number of operations matching type

n_1qb_gates(self: pytket._tket.circuit.Circuit) int

Returns the number of vertices in the dag with one quantum edge.Ignores Input, Create, Output, Discard, Reset, Measure and Barrier vertices.

n_2qb_gates(self: pytket._tket.circuit.Circuit) int

Returns the number of vertices in the dag with two quantum edges.Ignores Input, Create, Output, Discard, Reset, Measure and Barrier vertices.

n_nqb_gates(self: pytket._tket.circuit.Circuit, size: int) int

Returns the number of vertices in the dag with given number of quantum edges.Ignores Input, Create, Output, Discard, Reset, Measure and Barrier vertices.

free_symbols(self: pytket._tket.circuit.Circuit) set[sympy.Symbol]
Returns:

set of symbolic parameters in the circuit

symbol_substitution(*args, **kwargs)

Overloaded function.

  1. symbol_substitution(self: pytket._tket.circuit.Circuit, symbol_map: dict[sympy.Symbol, typing.Union[sympy.Expr, float]]) -> None

In-place substitution for symbolic expressions; iterates through each parameterised gate/box and performs the substitution.

Parameters:

symbol_map – A map from SymPy symbols to SymPy expressions

  1. symbol_substitution(self: pytket._tket.circuit.Circuit, symbol_map: dict[sympy.Symbol, float]) -> None

In-place substitution for symbolic expressions; iterates through each gate/box and performs the substitution.

Parameters:

symbol_map – A map from SymPy symbols to floating-point values

substitute_named(*args, **kwargs)

Overloaded function.

  1. substitute_named(self: pytket._tket.circuit.Circuit, op: pytket._tket.circuit.Op, opgroup: str) -> bool

Substitute all ops with the given name for the given op.The replacement operations retain the same name.

Parameters:
  • op – the replacement operation

  • opgroup – the name of the operations group to replace

Returns:

whether any replacements were made

  1. substitute_named(self: pytket._tket.circuit.Circuit, repl: pytket._tket.circuit.Circuit, opgroup: str) -> bool

Substitute all ops with the given name for the given circuit.Named operations in the replacement circuit must not match any named operations in the circuit being modified.

Parameters:
  • repl – the replacement circuit

  • opgroup – the name of the operations group to replace

Returns:

whether any replacements were made

  1. substitute_named(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.CircBox, opgroup: str) -> bool

Substitute all ops with the given name for the given box.The replacement boxes retain the same name.

Parameters:
  • box – the replacement CircBox

  • opgroup – the name of the operations group to replace

Returns:

whether any replacements were made

  1. substitute_named(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.Unitary1qBox, opgroup: str) -> bool

Substitute all ops with the given name for the given box.The replacement boxes retain the same name.

Parameters:
  • box – the replacement Unitary1qBox

  • opgroup – the name of the operations group to replace

Returns:

whether any replacements were made

  1. substitute_named(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.Unitary2qBox, opgroup: str) -> bool

Substitute all ops with the given name for the given box.The replacement boxes retain the same name.

Parameters:
  • box – the replacement Unitary2qBox

  • opgroup – the name of the operations group to replace

Returns:

whether any replacements were made

  1. substitute_named(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.Unitary3qBox, opgroup: str) -> bool

Substitute all ops with the given name for the given box.The replacement boxes retain the same name.

Parameters:
  • box – the replacement Unitary3qBox

  • opgroup – the name of the operations group to replace

Returns:

whether any replacements were made

  1. substitute_named(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.ExpBox, opgroup: str) -> bool

Substitute all ops with the given name for the given box.The replacement boxes retain the same name.

Parameters:
  • box – the replacement ExpBox

  • opgroup – the name of the operations group to replace

Returns:

whether any replacements were made

  1. substitute_named(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.PauliExpBox, opgroup: str) -> bool

Substitute all ops with the given name for the given box.The replacement boxes retain the same name.

Parameters:
  • box – the replacement PauliExpBox

  • opgroup – the name of the operations group to replace

Returns:

whether any replacements were made

  1. substitute_named(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.ToffoliBox, opgroup: str) -> bool

Substitute all ops with the given name for the given box.The replacement boxes retain the same name.

Parameters:
  • box – the replacement ToffoliBox

  • opgroup – the name of the operations group to replace

Returns:

whether any replacements were made

  1. substitute_named(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.DummyBox, opgroup: str) -> bool

Substitute all ops with the given name for the given box.The replacement boxes retain the same name.

Parameters:
  • box – the replacement DummyBox

  • opgroup – the name of the operations group to replace

Returns:

whether any replacements were made

  1. substitute_named(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.QControlBox, opgroup: str) -> bool

Substitute all ops with the given name for the given box.The replacement boxes retain the same name.

Parameters:
  • box – the replacement QControlBox

  • opgroup – the name of the operations group to replace

Returns:

whether any replacements were made

  1. substitute_named(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.CustomGate, opgroup: str) -> bool

Substitute all ops with the given name for the given box.The replacement boxes retain the same name.

Parameters:
  • box – the replacement CustomGate

  • opgroup – the name of the operations group to replace

Returns:

whether any replacements were made

depth(self: pytket._tket.circuit.Circuit) int

Returns the number of interior vertices on the longest path through the DAG, excluding vertices representing barrier operations.

>>> c = Circuit(3)
>>> c.depth()
0
>>> c.CX(0,1)
>>> c.CX(1,2)
>>> c.CX(2,0)
>>> c.depth()
3
Returns:

the circuit depth

depth_2q(self: pytket._tket.circuit.Circuit) int

Returns the number of vertices in the longest path through the sub-DAG consisting of vertices with 2 quantum wires,excluding vertices representing barrier operations.

>>> c = Circuit(3)
>>> c.CZ(0,1)
>>> c.Z(0)
>>> c.Z(1)
>>> c.ZZMax(1,2)
>>> c.CX(1,2)
>>> c.depth_2q()
3
:return: the circuit depth with respect to 2-qubit operations.
depth_by_type(*args, **kwargs)

Overloaded function.

  1. depth_by_type(self: pytket._tket.circuit.Circuit, type: pytket._tket.circuit.OpType) -> int

Returns the number of vertices in the longest path through the sub-DAG consisting of vertices representing operations of the given type.

>>> c = Circuit(3)
>>> c.CX(0,1)
>>> c.Z(1)
>>> c.CX(1,2)
>>> c.depth_by_type(OpType.CX)
2
Parameters:

type – the operation type of interest

Returns:

the circuit depth with respect to operations matching type

  1. depth_by_type(self: pytket._tket.circuit.Circuit, types: set[pytket._tket.circuit.OpType]) -> int

Returns the number of vertices in the longest path through the sub-DAG consisting of vertices representing operations of the given types.

>>> c = Circuit(3)
>>> c.CZ(0,1)
>>> c.Z(1)
>>> c.CX(1,2)
>>> c.depth_by_type({OpType.CZ, OpType.CX})
2
Parameters:

types – the set of operation types of interest

Returns:

the circuit depth with respect to operations matching an element of types

get_commands(self: pytket._tket.circuit.Circuit) list[pytket._tket.circuit.Command]
Returns:

a list of all the Commands in the circuit

add_barrier(*args, **kwargs)

Overloaded function.

  1. add_barrier(self: pytket._tket.circuit.Circuit, qubits: Sequence[int], bits: Sequence[int] = [], data: str = ‘’) -> pytket._tket.circuit.Circuit

Append a Barrier on the given units

Parameters:

data – additional data stored in the barrier

Returns:

the new Circuit

  1. add_barrier(self: pytket._tket.circuit.Circuit, units: Sequence[pytket._tket.unit_id.UnitID], data: str = ‘’) -> pytket._tket.circuit.Circuit

Append a Barrier on the given units

Parameters:

data – additional data stored in the barrier

Returns:

the new Circuit

add_conditional_barrier(*args, **kwargs)

Overloaded function.

  1. add_conditional_barrier(self: pytket._tket.circuit.Circuit, barrier_qubits: Sequence[int], barrier_bits: Sequence[int], condition_bits: Sequence[int], value: int, data: str = ‘’) -> pytket._tket.circuit.Circuit

Append a Conditional Barrier on the given barrier qubits and barrier bits, conditioned on the given condition bits.

Parameters:
  • barrier_qubits – Qubit in Barrier operation.

  • barrier_bits – Bit in Barrier operation.

  • condition_bits – Bit covering classical control condition of barrier operation.

  • value – Value that classical condition must have to hold (little-endian).

  • data – Additional data stored in Barrier operation.

Returns:

the new Circuit

  1. add_conditional_barrier(self: pytket._tket.circuit.Circuit, barrier_args: Sequence[pytket._tket.unit_id.UnitID], condition_bits: Sequence[pytket._tket.unit_id.Bit], value: int, data: str = ‘’) -> pytket._tket.circuit.Circuit

Append a Conditional Barrier on the given barrier qubits and barrier bits, conditioned on the given condition bits.

Parameters:
  • barrier_args – Qubit and Bit in Barrier operation.

  • condition_bits – Bit covering classical control condition of barrier operation.

  • value – Value that classical condition must have to hold (little-endian).

  • data – Additional data stored in Barrier operation.

Returns:

the new Circuit

add_wasm(funcname, filehandler, list_i, list_o, args, args_wasm=None, **kwargs)

Add a classical function call from a wasm file to the circuit.

Parameters:
  • funcname (str) – name of the function that is called

  • filehandler (WasmModuleHandler) – wasm file or module handler to identify the wasm module

  • list_i (Sequence[int]) – list of the number of bits in the input variables

  • list_o (Sequence[int]) – list of the number of bits in the output variables

  • args (Union[Sequence[int], Sequence[Bit]]) – vector of circuit bits the wasm op should be added to

  • args_wasm (Optional[Sequence[int]]) – vector of wasmstates the wasm op should be added to

  • kwargs (Any) – additional arguments passed to add_gate_method . Allowed parameters are opgroup, condition , condition_bits, condition_value

Return type:

Circuit

Returns:

the new Circuit

add_wasm_to_reg(funcname, filehandler, list_i, list_o, args_wasm=None, **kwargs)

Add a classical function call from a wasm file to the circuit.

Parameters:
  • funcname (str) – name of the function that is called

  • filehandler (WasmModuleHandler) – wasm file or module handler to identify the wasm module

  • list_i (Sequence[BitRegister]) – list of the classical registers assigned to the input variables of the function call

  • list_o (Sequence[BitRegister]) – list of the classical registers assigned to the output variables of the function call

  • args_wasm (Optional[Sequence[int]]) – vector of wasmstates the wasm op should be added to

  • kwargs (Any) – additional arguments passed to add_gate_method . Allowed parameters are opgroup, condition , condition_bits, condition_value

Return type:

Circuit

Returns:

the new Circuit

static from_dict(arg0: dict) pytket._tket.circuit.Circuit

Construct Circuit instance from JSON serializable dictionary representation of the Circuit.

to_dict(self: pytket._tket.circuit.Circuit) dict
Returns:

a JSON serializable dictionary representation of the Circuit

get_statevector(self: pytket._tket.circuit.Circuit) numpy.ndarray[numpy.complex128[m, 1]]

Calculate the unitary matrix of the circuit, using ILO-BE convention, applied to the column vector (1,0,0…), which is thus another column vector. Due to pybind11 and numpy peculiarities, to treat the result as a genuine column vector and perform further matrix multiplication, you need to call .reshape(rows,1) to get a 2D matrix with the correct dimensions.

Returns:

The calculated vector.

get_unitary(self: pytket._tket.circuit.Circuit) numpy.ndarray[numpy.complex128[m, n]]
Returns:

The numerical unitary matrix of the circuit, using ILO-BE convention.

get_unitary_times_other(self: pytket._tket.circuit.Circuit, matr: numpy.ndarray[numpy.complex128[m, n]]) numpy.ndarray[numpy.complex128[m, n]]

Calculate UM, where U is the numerical unitary matrix of the circuit, with ILO-BE convention, and M is another matrix. This is more efficient than calculating U separately, if M has fewer columns than U.

Parameters:

matr – The matrix to be multiplied.

Returns:

The product of the circuit unitary and the given matrix.

dagger(self: pytket._tket.circuit.Circuit) pytket._tket.circuit.Circuit

Given a pure circuit (i.e. without any measurements or conditional gates), produces a new circuit for the inverse/adjoint operation.

Returns:

a new Circuit corresponding to the inverse operation

transpose(self: pytket._tket.circuit.Circuit) pytket._tket.circuit.Circuit

Given a pure circuit (i.e. without any measurements or conditional gates), produces a new circuit for the transpose operation.

Returns:

a new Circuit corresponding to the transpose operation

copy(self: pytket._tket.circuit.Circuit) pytket._tket.circuit.Circuit
Returns:

an identical copy of the circuit

get_resources(self: pytket._tket.circuit.Circuit) pytket._tket.circuit.ResourceData

Calculate the overall resources of the circuit.

This takes account of the data stored in each py:class:DummyBox within the circuit, as well as other gates, to compute upper and lower bounds.

Returns:

bounds on resources of the circuit

>>> resource_data0 = ResourceData(
...     op_type_count={
...         OpType.T: ResourceBounds(1, 2),
...         OpType.H: ResourceBounds(0, 1),
...         OpType.CX: ResourceBounds(1, 2),
...         OpType.CZ: ResourceBounds(3, 3),
...     },
...     gate_depth=ResourceBounds(5, 8),
...     op_type_depth={
...         OpType.T: ResourceBounds(0, 10),
...         OpType.H: ResourceBounds(0, 10),
...         OpType.CX: ResourceBounds(1, 2),
...         OpType.CZ: ResourceBounds(3, 3),
...     },
...     two_qubit_gate_depth=ResourceBounds(4, 5),
... )
>>> dbox0 = DummyBox(n_qubits=2, n_bits=0, resource_data=resource_data0)
>>> resource_data1 = ResourceData(
...     op_type_count={
...         OpType.T: ResourceBounds(2, 2),
...         OpType.H: ResourceBounds(1, 1),
...         OpType.CX: ResourceBounds(2, 3),
...         OpType.CZ: ResourceBounds(3, 5),
...     },
...     gate_depth=ResourceBounds(5, 10),
...     op_type_depth={
...         OpType.T: ResourceBounds(1, 2),
...         OpType.H: ResourceBounds(2, 4),
...         OpType.CX: ResourceBounds(1, 1),
...         OpType.CZ: ResourceBounds(3, 4),
...     },
...     two_qubit_gate_depth=ResourceBounds(3, 5),
... )
>>> dbox1 = DummyBox(n_qubits=3, n_bits=0, resource_data=resource_data1)
>>> c = (
...     Circuit(3)
...     .H(0)
...     .CX(1, 2)
...     .CX(0, 1)
...     .T(2)
...     .H(1)
...     .add_dummybox(dbox0, [0, 1], [])
...     .CZ(1, 2)
...     .add_dummybox(dbox1, [0, 1, 2], [])
...     .H(2)
... )
>>> resource_data = c.get_resources()
>>> print(resource_data)
ResourceData(op_type_count={OpType.T: ResourceBounds(4, 5), OpType.H: ResourceBounds(4, 5), OpType.CX: ResourceBounds(5, 7), OpType.CZ: ResourceBounds(7, 9), }, gate_depth=ResourceBounds(15, 23), op_type_depth={OpType.T: ResourceBounds(2, 12), OpType.H: ResourceBounds(5, 17), OpType.CX: ResourceBounds(4, 5), OpType.CZ: ResourceBounds(7, 8), }, two_qubit_gate_depth=ResourceBounds(10, 13))
add_c_and(*args, **kwargs)

Overloaded function.

  1. add_c_and(self: pytket._tket.circuit.Circuit, arg0_in: int, arg1_in: int, arg_out: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a binary AND operation to the end of the circuit.

Parameters:
  • arg0_in – first input bit

  • arg1_in – second input bit

  • arg_out – output bit

  • kwargs – additional arguments passed to add_gate_method . Allowed parameters are opgroup, condition , condition_bits, condition_value

Returns:

the new Circuit

  1. add_c_and(self: pytket._tket.circuit.Circuit, arg0_in: pytket._tket.unit_id.Bit, arg1_in: pytket._tket.unit_id.Bit, arg_out: pytket._tket.unit_id.Bit, **kwargs) -> pytket._tket.circuit.Circuit

See add_c_and().

add_c_not(*args, **kwargs)

Overloaded function.

  1. add_c_not(self: pytket._tket.circuit.Circuit, arg_in: int, arg_out: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a NOT operation to the end of the circuit.

Parameters:
  • arg_in – input bit

  • arg_out – output bit

  • kwargs – additional arguments passed to add_gate_method . Allowed parameters are opgroup, condition , condition_bits, condition_value

Returns:

the new Circuit

  1. add_c_not(self: pytket._tket.circuit.Circuit, arg_in: pytket._tket.unit_id.Bit, arg_out: pytket._tket.unit_id.Bit, **kwargs) -> pytket._tket.circuit.Circuit

See add_c_not().

add_c_or(*args, **kwargs)

Overloaded function.

  1. add_c_or(self: pytket._tket.circuit.Circuit, arg0_in: int, arg1_in: int, arg_out: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a binary OR operation to the end of the circuit.

Parameters:
  • arg0_in – first input bit

  • arg1_in – second input bit

  • arg_out – output bit

  • kwargs – additional arguments passed to add_gate_method . Allowed parameters are opgroup, condition , condition_bits, condition_value

Returns:

the new Circuit

  1. add_c_or(self: pytket._tket.circuit.Circuit, arg0_in: pytket._tket.unit_id.Bit, arg1_in: pytket._tket.unit_id.Bit, arg_out: pytket._tket.unit_id.Bit, **kwargs) -> pytket._tket.circuit.Circuit

See add_c_or().

add_c_xor(*args, **kwargs)

Overloaded function.

  1. add_c_xor(self: pytket._tket.circuit.Circuit, arg0_in: int, arg1_in: int, arg_out: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a binary XOR operation to the end of the circuit.

Parameters:
  • arg0_in – first input bit

  • arg1_in – second input bit

  • arg_out – output bit

  • kwargs – additional arguments passed to add_gate_method . Allowed parameters are opgroup, condition , condition_bits, condition_value

Returns:

the new Circuit

  1. add_c_xor(self: pytket._tket.circuit.Circuit, arg0_in: pytket._tket.unit_id.Bit, arg1_in: pytket._tket.unit_id.Bit, arg_out: pytket._tket.unit_id.Bit, **kwargs) -> pytket._tket.circuit.Circuit

See add_c_xor().

add_c_range_predicate(*args, **kwargs)

Overloaded function.

  1. add_c_range_predicate(self: pytket._tket.circuit.Circuit, minval: int, maxval: int, args_in: Sequence[int], arg_out: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a range-predicate operation to the end of the circuit.

Parameters:
  • minval – lower bound of input in little-endian encoding

  • maxval – upper bound of input in little-endian encoding

  • args_in – input bits

  • arg_out – output bit (distinct from input bits)

  • kwargs – additional arguments passed to add_gate_method . Allowed parameters are opgroup, condition , condition_bits, condition_value

Returns:

the new Circuit

  1. add_c_range_predicate(self: pytket._tket.circuit.Circuit, minval: int, maxval: int, args_in: Sequence[pytket._tket.unit_id.Bit], arg_out: pytket._tket.unit_id.Bit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a range-predicate operation to the end of the circuit.

Parameters:
  • minval – lower bound of input in little-endian encoding

  • maxval – upper bound of input in little-endian encoding

  • args_in – input bits

  • arg_out – output bit (distinct from input bits)

  • kwargs – additional arguments passed to add_gate_method . Allowed parameters are opgroup, condition , condition_bits, condition_value

Returns:

the new Circuit

add_c_and_to_registers(self: pytket._tket.circuit.Circuit, reg0_in: pytket._tket.unit_id.BitRegister, reg1_in: pytket._tket.unit_id.BitRegister, reg_out: pytket._tket.unit_id.BitRegister, **kwargs) pytket._tket.circuit.Circuit

Applies bitwise AND to linear registers.

The operation is applied to the bits with indices 0, 1, 2, … in each register, up to the size of the smallest register.

Parameters:
  • reg0_in – first input register

  • reg1_in – second input register

  • reg_out – output register

  • kwargs – additional arguments passed to add_gate_method . Allowed parameters are opgroup, condition , condition_bits, condition_value

Returns:

the new Circuit

add_c_or_to_registers(self: pytket._tket.circuit.Circuit, reg0_in: pytket._tket.unit_id.BitRegister, reg1_in: pytket._tket.unit_id.BitRegister, reg_out: pytket._tket.unit_id.BitRegister, **kwargs) pytket._tket.circuit.Circuit

Applies bitwise OR to linear registers.

The operation is applied to the bits with indices 0, 1, 2, … in each register, up to the size of the smallest register.

Parameters:
  • reg0_in – first input register

  • reg1_in – second input register

  • reg_out – output register

  • kwargs – additional arguments passed to add_gate_method . Allowed parameters are opgroup, condition , condition_bits, condition_value

Returns:

the new Circuit

add_c_xor_to_registers(self: pytket._tket.circuit.Circuit, reg0_in: pytket._tket.unit_id.BitRegister, reg1_in: pytket._tket.unit_id.BitRegister, reg_out: pytket._tket.unit_id.BitRegister, **kwargs) pytket._tket.circuit.Circuit

Applies bitwise XOR to linear registers.

The operation is applied to the bits with indices 0, 1, 2, … in each register, up to the size of the smallest register.

Parameters:
  • reg0_in – first input register

  • reg1_in – second input register

  • reg_out – output register

  • kwargs – additional arguments passed to add_gate_method . Allowed parameters are opgroup, condition , condition_bits, condition_value

Returns:

the new Circuit

add_c_not_to_registers(self: pytket._tket.circuit.Circuit, reg_in: pytket._tket.unit_id.BitRegister, reg_out: pytket._tket.unit_id.BitRegister, **kwargs) pytket._tket.circuit.Circuit

Applies bitwise NOT to linear registers.

The operation is applied to the bits with indices 0, 1, 2, … in each register, up to the size of the smallest register.

Parameters:
  • reg_in – input register

  • reg_out – name of output register

  • kwargs – additional arguments passed to add_gate_method . Allowed parameters are opgroup, condition , condition_bits, condition_value

Returns:

the new Circuit

add_c_copybits(*args, **kwargs)

Overloaded function.

  1. add_c_copybits(self: pytket._tket.circuit.Circuit, args_in: Sequence[int], args_out: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Appends a classical copy operation

Parameters:
  • args_in – source bits

  • args_out – destination bits

  • kwargs – additional arguments passed to add_gate_method . Allowed parameters are opgroup, condition , condition_bits, condition_value

Returns:

the new Circuit

  1. add_c_copybits(self: pytket._tket.circuit.Circuit, args_in: Sequence[pytket._tket.unit_id.Bit], args_out: Sequence[pytket._tket.unit_id.Bit], **kwargs) -> pytket._tket.circuit.Circuit

See add_c_copybits().

add_c_copyreg(self: pytket._tket.circuit.Circuit, input_reg: pytket._tket.unit_id.BitRegister, output_reg: pytket._tket.unit_id.BitRegister, **kwargs) pytket._tket.circuit.Circuit

Copy a classical register to another. Copying is truncated to the size of the smaller of the two registers.

add_c_setreg(self: pytket._tket.circuit.Circuit, value: int, arg: pytket._tket.unit_id.BitRegister, **kwargs) pytket._tket.circuit.Circuit

Set a classical register to an unsigned integer value. The little-endian bitwise representation of the integer is truncated to the register size, up to _TKET_REG_WIDTH bit width. It is zero-padded if the width of the register is greater than _TKET_REG_WIDTH.

add_c_setbits(*args, **kwargs)

Overloaded function.

  1. add_c_setbits(self: pytket._tket.circuit.Circuit, values: Sequence[bool], args: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Appends an operation to set some bit values.

Parameters:
  • values – values to set

  • args – bits to set

  • kwargs – additional arguments passed to add_gate_method . Allowed parameters are opgroup, condition , condition_bits, condition_value

Returns:

the new Circuit

  1. add_c_setbits(self: pytket._tket.circuit.Circuit, values: Sequence[bool], args: Sequence[pytket._tket.unit_id.Bit], **kwargs) -> pytket._tket.circuit.Circuit

See add_c_setbits().

add_c_transform(*args, **kwargs)

Overloaded function.

  1. add_c_transform(self: pytket._tket.circuit.Circuit, values: Sequence[int], args: Sequence[int], name: str = ‘ClassicalTransform’, **kwargs) -> pytket._tket.circuit.Circuit

Appends a purely classical transformation, defined by a table of values, to the end of the circuit.

Parameters:
  • values – table of values: bit \(j\) (in little-endian order) of the term indexed by \(sum_i a_i 2^i\) is output \(j\) of the transform applied to inputs \((a_i)\).

  • args – bits to which the transform is applied

  • name – operation name

  • kwargs – additional arguments passed to add_gate_method . Allowed parameters are opgroup, condition , condition_bits, condition_value

Returns:

the new Circuit

  1. add_c_transform(self: pytket._tket.circuit.Circuit, values: Sequence[int], args: Sequence[pytket._tket.unit_id.Bit], name: str = ‘ClassicalTransform’, **kwargs) -> pytket._tket.circuit.Circuit

See add_c_transform().

add_c_modifier(*args, **kwargs)

Overloaded function.

  1. add_c_modifier(self: pytket._tket.circuit.Circuit, values: Sequence[bool], args_in: Sequence[int], arg_inout: int, name: str = ‘ExplicitModifier’, **kwargs) -> pytket._tket.circuit.Circuit

Parameters:
  • name – operation name

  • kwargs – additional arguments passed to add_gate_method . Allowed parameters are opgroup, condition , condition_bits, condition_value

Returns:

the new Circuit

  1. add_c_modifier(self: pytket._tket.circuit.Circuit, values: Sequence[bool], args_in: Sequence[pytket._tket.unit_id.Bit], arg_inout: pytket._tket.unit_id.Bit, name: str = ‘ExplicitModifier’, **kwargs) -> pytket._tket.circuit.Circuit

See add_c_modifier().

add_c_predicate(*args, **kwargs)

Overloaded function.

  1. add_c_predicate(self: pytket._tket.circuit.Circuit, values: Sequence[bool], args_in: Sequence[int], arg_out: int, name: str = ‘ExplicitPredicate’, **kwargs) -> pytket._tket.circuit.Circuit

Parameters:
  • name – operation name

  • kwargs – additional arguments passed to add_gate_method . Allowed parameters are opgroup, condition , condition_bits, condition_value

Returns:

the new Circuit

  1. add_c_predicate(self: pytket._tket.circuit.Circuit, values: Sequence[bool], args_in: Sequence[pytket._tket.unit_id.Bit], arg_out: pytket._tket.unit_id.Bit, name: str = ‘ExplicitPredicate’, **kwargs) -> pytket._tket.circuit.Circuit

See add_c_predicate().

add_classicalexpbox_bit(self: pytket._tket.circuit.Circuit, expression: pytket.circuit.logic_exp.BitLogicExp, target: Sequence[pytket._tket.unit_id.Bit], **kwargs) pytket._tket.circuit.Circuit

Append a ClassicalExpBox over Bit to the circuit. DEPRECATED: Please use add_clexpr() instead. This method will be removed after pytket 1.40.

Parameters:
  • classicalexpbox – The box to append

  • args – Indices of the qubits to append the box to

Returns:

the new Circuit

add_classicalexpbox_register(self: pytket._tket.circuit.Circuit, expression: pytket.circuit.logic_exp.RegLogicExp, target: Sequence[pytket._tket.unit_id.Bit], **kwargs) pytket._tket.circuit.Circuit

Append a ClassicalExpBox over BitRegister to the circuit. DEPRECATED: Please use add_clexpr() instead. This method will be removed after pytket 1.40.

Parameters:
  • classicalexpbox – The box to append

  • args – Indices of the qubits to append the box to

Returns:

the new Circuit

add_clexpr(self: pytket._tket.circuit.Circuit, expr: pytket._tket.circuit.WiredClExpr, args: Sequence[pytket._tket.unit_id.Bit], **kwargs) pytket._tket.circuit.Circuit

Append a WiredClExpr to the circuit.

Parameters:
  • expr – The expression to append

  • args – The bits to apply the expression to

Returns:

the new Circuit

qubit_create(self: pytket._tket.circuit.Circuit, arg0: pytket._tket.unit_id.Qubit) None

Make a quantum input a Create operation (initialized to 0

qubit_create_all(self: pytket._tket.circuit.Circuit) None

Make all quantum inputs Create operations (initialized to 0)

qubit_discard(self: pytket._tket.circuit.Circuit, arg0: pytket._tket.unit_id.Qubit) None

Make a quantum output a Discard operation

qubit_discard_all(self: pytket._tket.circuit.Circuit) None

Make all quantum outputs Discard operations

qubit_is_created(self: pytket._tket.circuit.Circuit, arg0: pytket._tket.unit_id.Qubit) bool

Query whether a qubit has its initial state set to zero

qubit_is_discarded(self: pytket._tket.circuit.Circuit, arg0: pytket._tket.unit_id.Qubit) bool

Query whether a qubit has its final state discarded

property created_qubits

A list of qubits whose input is a Create operation

property discarded_qubits

A list of qubits whose output is a Discard operation

replace_SWAPs(self: pytket._tket.circuit.Circuit) None

Replace all SWAP gates with implicit wire swaps.

replace_implicit_wire_swaps(self: pytket._tket.circuit.Circuit) None

Replace all implicit wire swaps with SWAP gates.

implicit_qubit_permutation(self: pytket._tket.circuit.Circuit) dict[pytket._tket.unit_id.Qubit, pytket._tket.unit_id.Qubit]
Returns:

dictionary mapping input qubit to output qubit on the same path

to_latex_file(self: pytket._tket.circuit.Circuit, filename: str) None

Produces a latex file with a visualisation of the circuit using the Quantikz package.

Parameters:

filename – Name of file to write output to (must end in “.tex”)

Convenience methods for appending gates

Note

For adding gates to a circuit the Circuit.add_gate() method is sufficient to append any OpType to a Circuit. Some gates can only be added with Circuit.add_gate(). For other more commonly used operations these can be added to a Circuit directly using the convenience methods below.

H(*args, **kwargs)

Overloaded function.

  1. H(self: pytket._tket.circuit.Circuit, qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a Hadamard gate.

Returns:

the new Circuit

  1. H(self: pytket._tket.circuit.Circuit, qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a Hadamard gate.

Returns:

the new Circuit

X(*args, **kwargs)

Overloaded function.

  1. X(self: pytket._tket.circuit.Circuit, qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Returns:

the new Circuit

  1. X(self: pytket._tket.circuit.Circuit, qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends an X gate.

Returns:

the new Circuit

Y(*args, **kwargs)

Overloaded function.

  1. Y(self: pytket._tket.circuit.Circuit, qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Returns:

the new Circuit

  1. Y(self: pytket._tket.circuit.Circuit, qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a Y gate.

Returns:

the new Circuit

Z(*args, **kwargs)

Overloaded function.

  1. Z(self: pytket._tket.circuit.Circuit, qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Returns:

the new Circuit

  1. Z(self: pytket._tket.circuit.Circuit, qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a Z gate.

Returns:

the new Circuit

S(*args, **kwargs)

Overloaded function.

  1. S(self: pytket._tket.circuit.Circuit, qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends an S gate (equivalent to U1(0.5,-)).

Returns:

the new Circuit

  1. S(self: pytket._tket.circuit.Circuit, qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends an S gate (equivalent to Rz(0.5,-)).

Returns:

the new Circuit

Sdg(*args, **kwargs)

Overloaded function.

  1. Sdg(self: pytket._tket.circuit.Circuit, qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends an S-dagger gate (equivalent to U1(-0.5,-)).

Returns:

the new Circuit

  1. Sdg(self: pytket._tket.circuit.Circuit, qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends an S-dagger gate (equivalent to Rz(-0.5,-)).

Returns:

the new Circuit

SX(*args, **kwargs)

Overloaded function.

  1. SX(self: pytket._tket.circuit.Circuit, qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a SX gate (equivalent to Rx(0.5,-) up to a 0.25 global phase).

Returns:

the new Circuit

  1. SX(self: pytket._tket.circuit.Circuit, qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a SX gate (equivalent to Rx(0.5,-) up to a 0.25 global phase).

Returns:

the new Circuit

SXdg(*args, **kwargs)

Overloaded function.

  1. SXdg(self: pytket._tket.circuit.Circuit, qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a SXdg gate (equivalent to Rx(-0.5,-) up to a -0.25 global phase).

Returns:

the new Circuit

  1. SXdg(self: pytket._tket.circuit.Circuit, qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a SXdg gate (equivalent to Rx(-0.5,-) up to a -0.25 global phase).

Returns:

the new Circuit

T(*args, **kwargs)

Overloaded function.

  1. T(self: pytket._tket.circuit.Circuit, qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a T gate (equivalent to U1(0.25,-)).

Returns:

the new Circuit

  1. T(self: pytket._tket.circuit.Circuit, qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a T gate (equivalent to Rz(0.25,-)).

Returns:

the new Circuit

Tdg(*args, **kwargs)

Overloaded function.

  1. Tdg(self: pytket._tket.circuit.Circuit, qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a T-dagger gate (equivalent to U1(-0.25,-)).

Returns:

the new Circuit

  1. Tdg(self: pytket._tket.circuit.Circuit, qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a T-dagger gate (equivalent to Rz(-0.25,-)).

Returns:

the new Circuit

V(*args, **kwargs)

Overloaded function.

  1. V(self: pytket._tket.circuit.Circuit, qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a V gate (equivalent to Rx(0.5,-)).

Returns:

the new Circuit

  1. V(self: pytket._tket.circuit.Circuit, qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a V gate (equivalent to Rx(0.5,-)).

Returns:

the new Circuit

Vdg(*args, **kwargs)

Overloaded function.

  1. Vdg(self: pytket._tket.circuit.Circuit, qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a V-dagger gate (equivalent to Rx(-0.5,-)).

Returns:

the new Circuit

  1. Vdg(self: pytket._tket.circuit.Circuit, qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a V-dagger gate (equivalent to Rx(-0.5,-)).

Returns:

the new Circuit

Rx(*args, **kwargs)

Overloaded function.

  1. Rx(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends an Rx gate with a possibly symbolic angle (specified in half-turns).

Returns:

the new Circuit

  1. Rx(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends an Rx gate with a possibly symbolic angle (specified in half-turns).

Returns:

the new Circuit

Ry(*args, **kwargs)

Overloaded function.

  1. Ry(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends an Ry gate with a possibly symbolic angle (specified in half-turns).

Returns:

the new Circuit

  1. Ry(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends an Ry gate with a possibly symbolic angle (specified in half-turns).

Returns:

the new Circuit

Rz(*args, **kwargs)

Overloaded function.

  1. Rz(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends an Rz gate with a possibly symbolic angle (specified in half-turns).

Returns:

the new Circuit

  1. Rz(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends an Rz gate with a possibly symbolic angle (specified in half-turns).

Returns:

the new Circuit

PhasedX(*args, **kwargs)

Overloaded function.

  1. PhasedX(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a PhasedX gate with possibly symbolic angles (specified in half-turns) on the wires for the specified qubits.

Returns:

the new Circuit

  1. PhasedX(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a PhasedX gate with possibly symbolic angles (specified in half-turns) on the wires for the specified qubits.

Returns:

the new Circuit

TK1(*args, **kwargs)

Overloaded function.

  1. TK1(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], angle2: typing.Union[sympy.Expr, float], qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a TK1 gate with possibly symbolic angles (specified in half-turns).

Returns:

the new Circuit

  1. TK1(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], angle2: typing.Union[sympy.Expr, float], qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a TK1 gate with possibly symbolic angles (specified in half-turns).

Returns:

the new Circuit

TK2(*args, **kwargs)

Overloaded function.

  1. TK2(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], angle2: typing.Union[sympy.Expr, float], qubit0: int, qubit1: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a TK2 gate with possibly symbolic angles (specified in half-turns).

Returns:

the new Circuit

  1. TK2(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], angle2: typing.Union[sympy.Expr, float], qubit0: pytket._tket.unit_id.Qubit, qubit1: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a TK2 gate with possibly symbolic angles (specified in half-turns).

Returns:

the new Circuit

U1(*args, **kwargs)

Overloaded function.

  1. U1(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a U1 gate with a possibly symbolic angle (specified in half-turns).

Returns:

the new Circuit

  1. U1(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a U1 gate with a possibly symbolic angle (specified in half-turns).

Returns:

the new Circuit

U2(*args, **kwargs)

Overloaded function.

  1. U2(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a U2 gate with possibly symbolic angles (specified in half-turns).

Returns:

the new Circuit

  1. U2(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a U2 gate with possibly symbolic angles (specified in half-turns).

Returns:

the new Circuit

U3(*args, **kwargs)

Overloaded function.

  1. U3(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], angle2: typing.Union[sympy.Expr, float], qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a U3 gate with possibly symbolic angles (specified in half-turns).

Returns:

the new Circuit

  1. U3(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], angle2: typing.Union[sympy.Expr, float], qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a U3 gate with possibly symbolic angles (specified in half-turns).

Returns:

the new Circuit

CX(*args, **kwargs)

Overloaded function.

  1. CX(self: pytket._tket.circuit.Circuit, control_qubit: int, target_qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CX gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

  1. CX(self: pytket._tket.circuit.Circuit, control_qubit: pytket._tket.unit_id.Qubit, target_qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CX gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

CY(*args, **kwargs)

Overloaded function.

  1. CY(self: pytket._tket.circuit.Circuit, control_qubit: int, target_qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CY gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

  1. CY(self: pytket._tket.circuit.Circuit, control_qubit: pytket._tket.unit_id.Qubit, target_qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CY gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

CZ(*args, **kwargs)

Overloaded function.

  1. CZ(self: pytket._tket.circuit.Circuit, control_qubit: int, target_qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CZ gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

  1. CZ(self: pytket._tket.circuit.Circuit, control_qubit: pytket._tket.unit_id.Qubit, target_qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CZ gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

CS(*args, **kwargs)

Overloaded function.

  1. CS(self: pytket._tket.circuit.Circuit, control_qubit: int, target_qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CS gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

  1. CS(self: pytket._tket.circuit.Circuit, control_qubit: pytket._tket.unit_id.Qubit, target_qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CS gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

CSdg(*args, **kwargs)

Overloaded function.

  1. CSdg(self: pytket._tket.circuit.Circuit, control_qubit: int, target_qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CSdg gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

  1. CSdg(self: pytket._tket.circuit.Circuit, control_qubit: pytket._tket.unit_id.Qubit, target_qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CSdg gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

CV(*args, **kwargs)

Overloaded function.

  1. CV(self: pytket._tket.circuit.Circuit, control_qubit: int, target_qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CV gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

  1. CV(self: pytket._tket.circuit.Circuit, control_qubit: pytket._tket.unit_id.Qubit, target_qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CV gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

CVdg(*args, **kwargs)

Overloaded function.

  1. CVdg(self: pytket._tket.circuit.Circuit, control_qubit: int, target_qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CVdg gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

  1. CVdg(self: pytket._tket.circuit.Circuit, control_qubit: pytket._tket.unit_id.Qubit, target_qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CVdg gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

CSX(*args, **kwargs)

Overloaded function.

  1. CSX(self: pytket._tket.circuit.Circuit, control_qubit: int, target_qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CSX gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

  1. CSX(self: pytket._tket.circuit.Circuit, control_qubit: pytket._tket.unit_id.Qubit, target_qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CSX gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

CSXdg(*args, **kwargs)

Overloaded function.

  1. CSXdg(self: pytket._tket.circuit.Circuit, control_qubit: int, target_qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CSXdg gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

  1. CSXdg(self: pytket._tket.circuit.Circuit, control_qubit: pytket._tket.unit_id.Qubit, target_qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CSXdg gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

CH(*args, **kwargs)

Overloaded function.

  1. CH(self: pytket._tket.circuit.Circuit, control_qubit: int, target_qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CH gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

  1. CH(self: pytket._tket.circuit.Circuit, control_qubit: pytket._tket.unit_id.Qubit, target_qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CH gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

ECR(*args, **kwargs)

Overloaded function.

  1. ECR(self: pytket._tket.circuit.Circuit, qubit_0: int, qubit_1: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends an ECR gate on the wires for the specified qubits.

Returns:

the new Circuit

  1. ECR(self: pytket._tket.circuit.Circuit, qubit_0: pytket._tket.unit_id.Qubit, qubit_1: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends an ECR gate on the wires for the specified qubits.

Returns:

the new Circuit

CRx(*args, **kwargs)

Overloaded function.

  1. CRx(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], control_qubit: int, target_qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CRx gate with a possibly symbolic angle (specified in half-turns) on the wires for the specified control and target qubits.

Returns:

the new Circuit

  1. CRx(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], control_qubit: pytket._tket.unit_id.Qubit, target_qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CRx gate with a symbolic angle (specified in half-turns) on the wires for the specified control and target qubits.

Returns:

the new Circuit

CRy(*args, **kwargs)

Overloaded function.

  1. CRy(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], control_qubit: int, target_qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CRy gate with a possibly symbolic angle (specified in half-turns) on the wires for the specified control and target qubits.

Returns:

the new Circuit

  1. CRy(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], control_qubit: pytket._tket.unit_id.Qubit, target_qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CRy gate with a symbolic angle (specified in half-turns) on the wires for the specified control and target qubits.

Returns:

the new Circuit

CRz(*args, **kwargs)

Overloaded function.

  1. CRz(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], control_qubit: int, target_qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CRz gate with a possibly symbolic angle (specified in half-turns) on the wires for the specified control and target qubits.

Returns:

the new Circuit

  1. CRz(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], control_qubit: pytket._tket.unit_id.Qubit, target_qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CRz gate with a symbolic angle (specified in half-turns) on the wires for the specified control and target qubits.

Returns:

the new Circuit

CU1(*args, **kwargs)

Overloaded function.

  1. CU1(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], control_qubit: int, target_qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CU1 gate with a possibly symbolic angle (specified in half-turns) on the wires for the specified control and target qubits.

Returns:

the new Circuit

  1. CU1(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], control_qubit: pytket._tket.unit_id.Qubit, target_qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CU1 gate with a possibly symbolic angle (specified in half-turns) on the wires for the specified control and target qubits.

Returns:

the new Circuit

CU3(*args, **kwargs)

Overloaded function.

  1. CU3(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], angle2: typing.Union[sympy.Expr, float], control_qubit: int, target_qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CU3 gate with possibly symbolic angles (specified in half-turns) on the wires for the specified control and target qubits.

Returns:

the new Circuit

  1. CU3(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], angle2: typing.Union[sympy.Expr, float], control_qubit: pytket._tket.unit_id.Qubit, target_qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CU3 gate with possibly symbolic angles (specified in half-turns) on the wires for the specified control and target qubits.

Returns:

the new Circuit

Measure(*args, **kwargs)

Overloaded function.

  1. Measure(self: pytket._tket.circuit.Circuit, qubit: int, bit_index: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a single-qubit measurement in the computational (Z) basis.

Returns:

the new Circuit

  1. Measure(self: pytket._tket.circuit.Circuit, qubit: pytket._tket.unit_id.Qubit, bit: pytket._tket.unit_id.Bit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a single-qubit measurement in the computational (Z) basis.

Returns:

the new Circuit

measure_all(self: pytket._tket.circuit.Circuit) pytket._tket.circuit.Circuit

Appends a measure gate to all qubits, storing the results in the default classical register. Bits are added to the circuit if they do not already exist.

Returns:

the new Circuit

measure_register(self: pytket._tket.circuit.Circuit, arg0: pytket._tket.unit_id.QubitRegister, arg1: str) pytket._tket.circuit.Circuit

Appends a measure gate to all qubits in the given register, storing the results in the given classical register with matching indices.The classical register will be created if it doesn’t exist.

Parameters:
  • qreg – the QubitRegister to be measured

  • creg_name – the name of the BitRegister to store the results

Returns:

the new Circuit

Reset(*args, **kwargs)

Overloaded function.

  1. Reset(self: pytket._tket.circuit.Circuit, qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a Reset operation. Sets a qubit to the Z-basis 0 state. Non-unitary operation.

Returns:

the new Circuit

  1. Reset(self: pytket._tket.circuit.Circuit, qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a Reset operation. Sets a qubit to the Z-basis 0 state. Non-unitary operation.

Returns:

the new Circuit

Phase(self: pytket._tket.circuit.Circuit, arg0: Union[sympy.Expr, float], **kwargs) pytket._tket.circuit.Circuit
SWAP(*args, **kwargs)

Overloaded function.

  1. SWAP(self: pytket._tket.circuit.Circuit, qubit_0: int, qubit_1: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a SWAP gate on the wires for the specified qubits.

Returns:

the new Circuit

  1. SWAP(self: pytket._tket.circuit.Circuit, qubit_0: pytket._tket.unit_id.Qubit, qubit_1: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a SWAP gate on the wires for the specified qubits.

Returns:

the new Circuit

CCX(*args, **kwargs)

Overloaded function.

  1. CCX(self: pytket._tket.circuit.Circuit, control_0: int, control_1: int, target: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CCX gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

  1. CCX(self: pytket._tket.circuit.Circuit, control_0: pytket._tket.unit_id.Qubit, control_1: pytket._tket.unit_id.Qubit, target: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CCX gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

CSWAP(*args, **kwargs)

Overloaded function.

  1. CSWAP(self: pytket._tket.circuit.Circuit, control: int, target_0: int, target_1: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CSWAP gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

  1. CSWAP(self: pytket._tket.circuit.Circuit, control: pytket._tket.unit_id.Qubit, target_0: pytket._tket.unit_id.Qubit, target_1: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a CSWAP gate on the wires for the specified control and target qubits.

Returns:

the new Circuit

ESWAP(*args, **kwargs)

Overloaded function.

  1. ESWAP(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit0: int, qubit1: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends an ESWAP gate with a possibly symbolic angle (specified in half-turns) on the wires for the specified two qubits.

Returns:

the new Circuit

  1. ESWAP(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit0: pytket._tket.unit_id.Qubit, qubit1: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends an ESWAP gate with a possibly symbolic angle (specified in half-turns) on the wires for the specified two qubits.

Returns:

the new Circuit

ISWAP(*args, **kwargs)

Overloaded function.

  1. ISWAP(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit0: int, qubit1: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends an ISWAP gate with a possibly symbolic angle (specified in half-turns) on the wires for the specified qubits.

Returns:

the new Circuit

  1. ISWAP(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit0: pytket._tket.unit_id.Qubit, qubit1: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends an ISWAP gate with a possibly symbolic angle (specified in half-turns) on the wires for the specified qubits.

Returns:

the new Circuit

ISWAPMax(*args, **kwargs)

Overloaded function.

  1. ISWAPMax(self: pytket._tket.circuit.Circuit, qubit0: int, qubit1: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends an ISWAPMax gate on the wires for the specified qubits.

Returns:

the new Circuit

  1. ISWAPMax(self: pytket._tket.circuit.Circuit, qubit0: pytket._tket.unit_id.Qubit, qubit1: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends an ISWAPMax gate on the wires for the specified qubits.

Returns:

the new Circuit

PhasedISWAP(*args, **kwargs)

Overloaded function.

  1. PhasedISWAP(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], qubit0: int, qubit1: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a PhasedISWAP gate with possibly symbolic angles (specified in half-turns) on the wires for the specified qubits.

Returns:

the new Circuit

  1. PhasedISWAP(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], qubit0: pytket._tket.unit_id.Qubit, qubit1: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a PhasedISWAP gate with posisbly symbolic angles (specified in half-turns) on the wires for the specified qubits.

Returns:

the new Circuit

FSim(*args, **kwargs)

Overloaded function.

  1. FSim(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], qubit0: int, qubit1: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends an FSim gate with possibly symbolic angles (specified in half-turns) on the wires for the specified qubits.

Returns:

the new Circuit

  1. FSim(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], qubit0: pytket._tket.unit_id.Qubit, qubit1: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends an FSim gate with possibly symbolic angles (specified in half-turns) on the wires for the specified qubits.

Returns:

the new Circuit

Sycamore(*args, **kwargs)

Overloaded function.

  1. Sycamore(self: pytket._tket.circuit.Circuit, qubit0: int, qubit1: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a Sycamore gate on the wires for the specified qubits.

Returns:

the new Circuit

  1. Sycamore(self: pytket._tket.circuit.Circuit, qubit0: pytket._tket.unit_id.Qubit, qubit1: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a Sycamore gate on the wires for the specified qubits.

Returns:

the new Circuit

XXPhase(*args, **kwargs)

Overloaded function.

  1. XXPhase(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit0: int, qubit1: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a XX gate with a possibly symbolic angle (specified in half-turns) on the wires for the specified two qubits.

Returns:

the new Circuit

  1. XXPhase(self: pytket._tket.circuit.Circuit, qubit0: typing.Union[sympy.Expr, float], qubit1: pytket._tket.unit_id.Qubit, angle: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a XX gate with a symbolic angle (specified in half-turns) on the wires for the specified two qubits.

Returns:

the new Circuit

XXPhase3(*args, **kwargs)

Overloaded function.

  1. XXPhase3(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit0: int, qubit1: int, qubit2: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a 3-qubit XX gate with a possibly symbolic angle (specified in half-turns) on the wires for the specified three qubits.

Returns:

the new Circuit

  1. XXPhase3(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit0: pytket._tket.unit_id.Qubit, qubit1: pytket._tket.unit_id.Qubit, qubit2: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a 3-qubit XX gate with a symbolic angle (specified in half-turns) on the wires for the specified three qubits.

Returns:

the new Circuit

YYPhase(*args, **kwargs)

Overloaded function.

  1. YYPhase(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit0: int, qubit1: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a YY gate with a possibly symbolic angle (specified in half-turns) on the wires for the specified two qubits.

Returns:

the new Circuit

  1. YYPhase(self: pytket._tket.circuit.Circuit, qubit0: typing.Union[sympy.Expr, float], qubit1: pytket._tket.unit_id.Qubit, angle: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a YY gate with a symbolic angle (specified in half-turns) on the wires for the specified two qubits.

Returns:

the new Circuit

ZZPhase(*args, **kwargs)

Overloaded function.

  1. ZZPhase(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit0: int, qubit1: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a ZZ gate with a possibly symbolic angle (specified in half-turns) on the wires for the specified two qubits.

Returns:

the new Circuit

  1. ZZPhase(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit0: pytket._tket.unit_id.Qubit, qubit1: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a ZZ gate with a symbolic angle (specified in half-turns) on the wires for the specified two qubits.

Returns:

the new Circuit

ZZMax(*args, **kwargs)

Overloaded function.

  1. ZZMax(self: pytket._tket.circuit.Circuit, qubit0: int, qubit1: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a ZZMax gate on the wires for the specified two qubits.

Returns:

the new Circuit

  1. ZZMax(self: pytket._tket.circuit.Circuit, qubit0: pytket._tket.unit_id.Qubit, qubit1: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a ZZMax gate on the wires for the specified two qubits.

Returns:

the new Circuit

AAMS(*args, **kwargs)

Overloaded function.

  1. AAMS(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], angle2: typing.Union[sympy.Expr, float], qubit0: int, qubit1: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends an AAMS gate with possibly symbolic angles (specified in half-turns).

Returns:

the new Circuit

  1. AAMS(self: pytket._tket.circuit.Circuit, angle0: typing.Union[sympy.Expr, float], angle1: typing.Union[sympy.Expr, float], angle2: typing.Union[sympy.Expr, float], qubit0: pytket._tket.unit_id.Qubit, qubit1: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends an AAMS gate with possibly symbolic angles (specified in half-turns).

Returns:

the new Circuit

GPI(*args, **kwargs)

Overloaded function.

  1. GPI(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a GPI gate with a possibly symbolic angle (specified in half-turns).

Returns:

the new Circuit

  1. GPI(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a GPI gate with a possibly symbolic angle (specified in half-turns).

Returns:

the new Circuit

GPI2(*args, **kwargs)

Overloaded function.

  1. GPI2(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit: int, **kwargs) -> pytket._tket.circuit.Circuit

Appends a GPI2 gate with a possibly symbolic angle (specified in half-turns).

Returns:

the new Circuit

  1. GPI2(self: pytket._tket.circuit.Circuit, angle: typing.Union[sympy.Expr, float], qubit: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Appends a GPI2 gate with a possibly symbolic angle (specified in half-turns).

Returns:

the new Circuit

Methods for appending circuit boxes

Note

For adding boxes to a circuit the Circuit.add_gate() method is sufficient to append any OpType to a Circuit.

from pytket.circuit import Circuit, CircBox

sub_circ = Circuit(2).CX(0, 1).Rz(0.25, 1).CX(0, 1)

box = CircBox(sub_circ)

bigger_circ = Circuit(3)

# Equivalent to bigger_circ.add_circbox(box, [0, 1, 2])
bigger_circ.add_gate(box, [0, 1, 2])
add_circbox(*args, **kwargs)

Overloaded function.

  1. add_circbox(self: pytket._tket.circuit.Circuit, circbox: pytket._tket.circuit.CircBox, args: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Append a CircBox to the circuit.

The qubits and bits of the CircBox are wired into the circuit in lexicographic order. Bits follow qubits in the order of arguments.

Parameters:
  • circbox – The box to append

  • args – Indices of the (default-register) qubits/bits to append the box to

Returns:

the new Circuit

  1. add_circbox(self: pytket._tket.circuit.Circuit, circbox: pytket._tket.circuit.CircBox, args: Sequence[pytket._tket.unit_id.UnitID], **kwargs) -> pytket._tket.circuit.Circuit

Append a CircBox to the circuit.

The qubits and bits of the CircBox are wired into the circuit in lexicographic order. Bits follow qubits in the order of arguments.

Parameters:
  • circbox – The box to append

  • args – The qubits/bits to append the box to

Returns:

the new Circuit

add_circbox_regwise(self: pytket._tket.circuit.Circuit, circbox: pytket._tket.circuit.CircBox, qregs: Sequence[pytket._tket.unit_id.QubitRegister], cregs: Sequence[pytket._tket.unit_id.BitRegister], **kwargs) pytket._tket.circuit.Circuit

Append a CircBox to the circuit, wiring whole registers together.

Parameters:
  • circbox – The box to append

  • qregs – Sequence of QubitRegister from the outer Circuit, the order corresponding to the lexicographic order of corresponding registers in the CircBox

  • cregs – Sequence of BitRegister from the outer Circuit, the order corresponding to the lexicographic order of corresponding registers in the CircBox

Returns:

the new Circuit

add_circbox_with_regmap(self: pytket._tket.circuit.Circuit, circbox: pytket._tket.circuit.CircBox, qregmap: dict[str, str], cregmap: dict[str, str], **kwargs) pytket._tket.circuit.Circuit

Append a CircBox to the circuit, wiring whole registers together.

This method expects two maps (one for qubit registers and one for bit registers), which must have keys corresponding to all register names in the box. The box may not contain any qubits or bits that do not belong to a register, i.e. all must be single-indexed contiguously from zero.

Parameters:
  • circbox – The box to append

  • qregmap – Map specifying which qubit register in the CircBox (the map’s keys) matches which register in the outer circuit (the map’s values)

  • cregmap – Map specifying which bit register in the CircBox (the map’s keys) matches which register in the outer circuit (the map’s values)

Returns:

the new Circuit

add_unitary1qbox(*args, **kwargs)

Overloaded function.

  1. add_unitary1qbox(self: pytket._tket.circuit.Circuit, unitarybox: pytket._tket.circuit.Unitary1qBox, qubit_0: int, **kwargs) -> pytket._tket.circuit.Circuit

Append a Unitary1qBox to the circuit.

Parameters:
  • unitarybox – The box to append

  • qubit_0 – Index of the qubit to append the box to

Returns:

the new Circuit

  1. add_unitary1qbox(self: pytket._tket.circuit.Circuit, unitarybox: pytket._tket.circuit.Unitary1qBox, qubit_0: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Append a Unitary1qBox to the circuit.

Parameters:
  • unitarybox – The box to append

  • qubit_0 – The qubit to append the box to

Returns:

the new Circuit

add_unitary2qbox(*args, **kwargs)

Overloaded function.

  1. add_unitary2qbox(self: pytket._tket.circuit.Circuit, unitarybox: pytket._tket.circuit.Unitary2qBox, qubit_0: int, qubit_1: int, **kwargs) -> pytket._tket.circuit.Circuit

Append a Unitary2qBox to the circuit.

The matrix representation is ILO-BE.

Parameters:
  • unitarybox – The box to append

  • qubit_0 – Index of the first target qubit

  • qubit_1 – Index of the second target qubit

Returns:

the new Circuit

  1. add_unitary2qbox(self: pytket._tket.circuit.Circuit, unitarybox: pytket._tket.circuit.Unitary2qBox, qubit_0: pytket._tket.unit_id.Qubit, qubit_1: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Append a Unitary2qBox to the circuit.

The matrix representation is ILO-BE.

Parameters:
  • unitarybox – The box to append

  • qubit_0 – The first target qubit

  • qubit_1 – The second target qubit

Returns:

the new Circuit

add_unitary3qbox(*args, **kwargs)

Overloaded function.

  1. add_unitary3qbox(self: pytket._tket.circuit.Circuit, unitarybox: pytket._tket.circuit.Unitary3qBox, qubit_0: int, qubit_1: int, qubit_2: int, **kwargs) -> pytket._tket.circuit.Circuit

Append a Unitary3qBox to the circuit.

Parameters:
  • unitarybox – box to append

  • qubit_0 – index of target qubit 0

  • qubit_1 – index of target qubit 1

  • qubit_2 – index of target qubit 2

Returns:

the new Circuit

  1. add_unitary3qbox(self: pytket._tket.circuit.Circuit, unitarybox: pytket._tket.circuit.Unitary3qBox, qubit_0: pytket._tket.unit_id.Qubit, qubit_1: pytket._tket.unit_id.Qubit, qubit_2: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Append a Unitary3qBox to the circuit.

Parameters:
  • unitarybox – box to append

  • qubit_0 – index of target qubit 0

  • qubit_1 – index of target qubit 1

  • qubit_2 – index of target qubit 2

Returns:

the new Circuit

add_expbox(*args, **kwargs)

Overloaded function.

  1. add_expbox(self: pytket._tket.circuit.Circuit, expbox: pytket._tket.circuit.ExpBox, qubit_0: int, qubit_1: int, **kwargs) -> pytket._tket.circuit.Circuit

Append an ExpBox to the circuit.

The matrix representation is ILO-BE.

Parameters:
  • expbox – The box to append

  • qubit_0 – Index of the first target qubit

  • qubit_1 – Index of the second target qubit

Returns:

the new Circuit

  1. add_expbox(self: pytket._tket.circuit.Circuit, expbox: pytket._tket.circuit.ExpBox, qubit_0: pytket._tket.unit_id.Qubit, qubit_1: pytket._tket.unit_id.Qubit, **kwargs) -> pytket._tket.circuit.Circuit

Append an ExpBox to the circuit.

The matrix representation is ILO-BE.

Parameters:
  • expbox – The box to append

  • qubit_0 – The first target qubit

  • qubit_1 – The second target qubit

Returns:

the new Circuit

add_pauliexpbox(*args, **kwargs)

Overloaded function.

  1. add_pauliexpbox(self: pytket._tket.circuit.Circuit, pauliexpbox: pytket._tket.circuit.PauliExpBox, qubits: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Append a PauliExpBox to the circuit.

Parameters:
  • pauliexpbox – The box to append

  • qubits – Indices of the qubits to append the box to

Returns:

the new Circuit

  1. add_pauliexpbox(self: pytket._tket.circuit.Circuit, pauliexpbox: pytket._tket.circuit.PauliExpBox, qubits: Sequence[pytket._tket.unit_id.Qubit], **kwargs) -> pytket._tket.circuit.Circuit

Append a PauliExpBox to the circuit.

Parameters:
  • pauliexpbox – The box to append

  • qubits – The qubits to append the box to

Returns:

the new Circuit

add_pauliexppairbox(*args, **kwargs)

Overloaded function.

  1. add_pauliexppairbox(self: pytket._tket.circuit.Circuit, pauliexppairbox: pytket._tket.circuit.PauliExpPairBox, qubits: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Append a PauliExpPairBox to the circuit.

Parameters:
  • pauliexppairbox – The box to append

  • qubits – Indices of the qubits to append the box to

Returns:

the new Circuit

  1. add_pauliexppairbox(self: pytket._tket.circuit.Circuit, pauliexppairbox: pytket._tket.circuit.PauliExpPairBox, qubits: Sequence[pytket._tket.unit_id.Qubit], **kwargs) -> pytket._tket.circuit.Circuit

Append a PauliExpPairBox to the circuit.

Parameters:
  • pauliexppairbox – The box to append

  • qubits – The qubits to append the box to

Returns:

the new Circuit

add_pauliexpcommutingsetbox(*args, **kwargs)

Overloaded function.

  1. add_pauliexpcommutingsetbox(self: pytket._tket.circuit.Circuit, pauliexpcommutingsetbox: pytket._tket.circuit.PauliExpCommutingSetBox, qubits: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Append a PauliExpCommutingSetBox to the circuit.

Parameters:
  • pauliexpcommutingsetbox – The box to append

  • qubits – Indices of the qubits to append the box to

Returns:

the new Circuit

  1. add_pauliexpcommutingsetbox(self: pytket._tket.circuit.Circuit, pauliexpcommutingsetbox: pytket._tket.circuit.PauliExpCommutingSetBox, qubits: Sequence[pytket._tket.unit_id.Qubit], **kwargs) -> pytket._tket.circuit.Circuit

Append a PauliExpCommutingSetBox to the circuit.

Parameters:
  • pauliexpcommutingsetbox – The box to append

  • qubits – The qubits to append the box to

Returns:

the new Circuit

add_termsequencebox(*args, **kwargs)

Overloaded function.

  1. add_termsequencebox(self: pytket._tket.circuit.Circuit, termsequencebox: pytket._tket.circuit.TermSequenceBox, qubits: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Append a TermSequenceBox to the circuit.

Parameters:
  • termsequencebox – The box to append

  • qubits – Indices of the qubits to append the box to

Returns:

the new Circuit

  1. add_termsequencebox(self: pytket._tket.circuit.Circuit, termsequencebox: pytket._tket.circuit.TermSequenceBox, qubits: Sequence[pytket._tket.unit_id.Qubit], **kwargs) -> pytket._tket.circuit.Circuit

Append a TermSequenceBox to the circuit.

Parameters:
  • termsequencebox – The box to append

  • qubits – The qubits to append the box to

Returns:

the new Circuit

add_phasepolybox(*args, **kwargs)

Overloaded function.

  1. add_phasepolybox(self: pytket._tket.circuit.Circuit, phasepolybox: pytket._tket.circuit.PhasePolyBox, qubits: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Append a PhasePolyBox to the circuit.

Parameters:
  • phasepolybox – The box to append

  • qubits – Indices of the qubits to append the box to

Returns:

the new Circuit

  1. add_phasepolybox(self: pytket._tket.circuit.Circuit, phasepolybox: pytket._tket.circuit.PhasePolyBox, qubits: Sequence[pytket._tket.unit_id.Qubit], **kwargs) -> pytket._tket.circuit.Circuit

Append a PhasePolyBox to the circuit.

Parameters:
  • phasepolybox – The box to append

  • qubits – The qubits to append the box to

Returns:

the new Circuit

add_toffolibox(*args, **kwargs)

Overloaded function.

  1. add_toffolibox(self: pytket._tket.circuit.Circuit, toffolibox: pytket._tket.circuit.ToffoliBox, qubits: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Append a ToffoliBox to the circuit.

Parameters:
  • toffolibox – The box to append

  • qubits – Indices of the qubits to append the box to

Returns:

the new Circuit

  1. add_toffolibox(self: pytket._tket.circuit.Circuit, toffolibox: pytket._tket.circuit.ToffoliBox, qubits: Sequence[pytket._tket.unit_id.Qubit], **kwargs) -> pytket._tket.circuit.Circuit

Append a ToffoliBox to the circuit.

Parameters:
  • toffolibox – The box to append

  • qubits – Indices of the qubits to append the box to

Returns:

the new Circuit

add_dummybox(*args, **kwargs)

Overloaded function.

  1. add_dummybox(self: pytket._tket.circuit.Circuit, dummybox: pytket._tket.circuit.DummyBox, qubits: Sequence[int], bits: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Append a DummyBox to the circuit.

Parameters:
  • dummybox – The box to append

  • qubits – Indices (in the default register) of the qubits to append the box to

  • bits – Indices of the bits (in the default register) to append the box to

Returns:

the new Circuit

  1. add_dummybox(self: pytket._tket.circuit.Circuit, dummybox: pytket._tket.circuit.DummyBox, qubits: Sequence[pytket._tket.unit_id.Qubit], bits: Sequence[pytket._tket.unit_id.Bit], **kwargs) -> pytket._tket.circuit.Circuit

Append a DummyBox to the circuit.

Parameters:
  • dummybox – The box to append

  • qubits – Qubits to append the box to

  • bits – Bits to append the box to

Returns:

the new Circuit

add_qcontrolbox(*args, **kwargs)

Overloaded function.

  1. add_qcontrolbox(self: pytket._tket.circuit.Circuit, qcontrolbox: pytket._tket.circuit.QControlBox, args: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Append a QControlBox to the circuit.

Parameters:
  • qcontrolbox – The box to append

  • args – Indices of the qubits to append the box to

Returns:

the new Circuit

  1. add_qcontrolbox(self: pytket._tket.circuit.Circuit, qcontrolbox: pytket._tket.circuit.QControlBox, args: Sequence[pytket._tket.unit_id.UnitID], **kwargs) -> pytket._tket.circuit.Circuit

Append a QControlBox to the circuit.

Parameters:
  • qcontrolbox – The box to append

  • args – The qubits to append the box to

Returns:

the new Circuit

add_custom_gate(*args, **kwargs)

Overloaded function.

  1. add_custom_gate(self: pytket._tket.circuit.Circuit, definition: pytket._tket.circuit.CustomGateDef, params: Sequence[typing.Union[sympy.Expr, float]], qubits: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Append an instance of a CustomGateDef to the circuit.

Parameters:
  • def – The custom gate definition

  • params – List of parameters to instantiate the gate with, in halfturns

  • qubits – Indices of the qubits to append the box to

Returns:

the new Circuit

  1. add_custom_gate(self: pytket._tket.circuit.Circuit, definition: pytket._tket.circuit.CustomGateDef, params: Sequence[typing.Union[sympy.Expr, float]], qubits: Sequence[pytket._tket.unit_id.Qubit], **kwargs) -> pytket._tket.circuit.Circuit

Append an instance of a CustomGateDef to the circuit.

Parameters:
  • def – The custom gate definition

  • params – List of parameters to instantiate the gate with, in halfturns

  • qubits – The qubits to append the box to

Returns:

the new Circuit

add_assertion(*args, **kwargs)

Overloaded function.

  1. add_assertion(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.ProjectorAssertionBox, qubits: Sequence[int], ancilla: Optional[int] = None, name: Optional[str] = None) -> pytket._tket.circuit.Circuit

Append a ProjectorAssertionBox to the circuit.

Parameters:
  • box – ProjectorAssertionBox to append

  • qubits – indices of target qubits

  • ancilla – index of ancilla qubit

  • name – name used to identify this assertion

Returns:

the new Circuit

  1. add_assertion(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.ProjectorAssertionBox, qubits: Sequence[pytket._tket.unit_id.Qubit], ancilla: Optional[pytket._tket.unit_id.Qubit] = None, name: Optional[str] = None) -> pytket._tket.circuit.Circuit

Append a ProjectorAssertionBox to the circuit.

Parameters:
  • box – ProjectorAssertionBox to append

  • qubits – target qubits

  • ancilla – ancilla qubit

  • name – name used to identify this assertion

Returns:

the new Circuit

  1. add_assertion(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.StabiliserAssertionBox, qubits: Sequence[int], ancilla: int, name: Optional[str] = None) -> pytket._tket.circuit.Circuit

Append a StabiliserAssertionBox to the circuit.

Parameters:
  • box – StabiliserAssertionBox to append

  • qubits – indices of target qubits

  • ancilla – index of ancilla qubit

  • name – name used to identify this assertion

Returns:

the new Circuit

  1. add_assertion(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.StabiliserAssertionBox, qubits: Sequence[pytket._tket.unit_id.Qubit], ancilla: pytket._tket.unit_id.Qubit, name: Optional[str] = None) -> pytket._tket.circuit.Circuit

Append a StabiliserAssertionBox to the circuit.

Parameters:
  • box – StabiliserAssertionBox to append

  • qubits – target qubits

  • ancilla – ancilla qubit

  • name – name used to identify this assertion

Returns:

the new Circuit

add_multiplexor(*args, **kwargs)

Overloaded function.

  1. add_multiplexor(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.MultiplexorBox, args: Sequence[pytket._tket.unit_id.UnitID], **kwargs) -> pytket._tket.circuit.Circuit

Append a MultiplexorBox to the circuit.

Parameters:
  • box – The box to append

  • args – The qubits to append the box to

Returns:

the new Circuit

  1. add_multiplexor(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.MultiplexorBox, args: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Append a MultiplexorBox to the circuit.

Parameters:
  • box – The box to append

  • args – Indices of the qubits to append the box to

Returns:

the new Circuit

add_multiplexedrotation(*args, **kwargs)

Overloaded function.

  1. add_multiplexedrotation(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.MultiplexedRotationBox, args: Sequence[pytket._tket.unit_id.UnitID], **kwargs) -> pytket._tket.circuit.Circuit

Append a MultiplexedRotationBox to the circuit.

Parameters:
  • box – The box to append

  • args – The qubits to append the box to

Returns:

the new Circuit

  1. add_multiplexedrotation(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.MultiplexedRotationBox, args: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Append a MultiplexedRotationBox to the circuit.

Parameters:
  • box – The box to append

  • args – Indices of the qubits to append the box to

Returns:

the new Circuit

add_multiplexedu2(*args, **kwargs)

Overloaded function.

  1. add_multiplexedu2(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.MultiplexedU2Box, args: Sequence[pytket._tket.unit_id.UnitID], **kwargs) -> pytket._tket.circuit.Circuit

Append a MultiplexedU2Box to the circuit.

Parameters:
  • box – The box to append

  • args – The qubits to append the box to

Returns:

the new Circuit

  1. add_multiplexedu2(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.MultiplexedU2Box, args: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Append a MultiplexedU2Box to the circuit.

Parameters:
  • box – The box to append

  • args – Indices of the qubits to append the box to

Returns:

the new Circuit

add_multiplexed_tensored_u2(*args, **kwargs)

Overloaded function.

  1. add_multiplexed_tensored_u2(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.MultiplexedTensoredU2Box, args: Sequence[pytket._tket.unit_id.UnitID], **kwargs) -> pytket._tket.circuit.Circuit

Append a MultiplexedTensoredU2Box to the circuit.

Parameters:
  • box – The box to append

  • args – The qubits to append the box to

Returns:

the new Circuit

  1. add_multiplexed_tensored_u2(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.MultiplexedTensoredU2Box, args: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Append a MultiplexedTensoredU2Box to the circuit.

Parameters:
  • box – The box to append

  • args – Indices of the qubits to append the box to

Returns:

the new Circuit

add_state_preparation_box(*args, **kwargs)

Overloaded function.

  1. add_state_preparation_box(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.StatePreparationBox, args: Sequence[pytket._tket.unit_id.UnitID], **kwargs) -> pytket._tket.circuit.Circuit

Append a StatePreparationBox to the circuit.

Parameters:
  • box – The box to append

  • args – The qubits to append the box to

Returns:

the new Circuit

  1. add_state_preparation_box(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.StatePreparationBox, args: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Append a StatePreparationBox to the circuit.

Parameters:
  • box – The box to append

  • args – Indices of the qubits to append the box to

Returns:

the new Circuit

add_diagonal_box(*args, **kwargs)

Overloaded function.

  1. add_diagonal_box(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.DiagonalBox, args: Sequence[pytket._tket.unit_id.UnitID], **kwargs) -> pytket._tket.circuit.Circuit

Append a DiagonalBox to the circuit.

Parameters:
  • box – The box to append

  • args – The qubits to append the box to

Returns:

the new Circuit

  1. add_diagonal_box(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.DiagonalBox, args: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Append a DiagonalBox to the circuit.

Parameters:
  • box – The box to append

  • args – Indices of the qubits to append the box to

Returns:

the new Circuit

add_conjugation_box(*args, **kwargs)

Overloaded function.

  1. add_conjugation_box(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.ConjugationBox, args: Sequence[pytket._tket.unit_id.UnitID], **kwargs) -> pytket._tket.circuit.Circuit

Append a ConjugationBox to the circuit.

Parameters:
  • box – The box to append

  • args – The qubits to append the box to

Returns:

the new Circuit

  1. add_conjugation_box(self: pytket._tket.circuit.Circuit, box: pytket._tket.circuit.ConjugationBox, args: Sequence[int], **kwargs) -> pytket._tket.circuit.Circuit

Append a ConjugationBox to the circuit.

Parameters:
  • box – The box to append

  • args – Indices of the qubits to append the box to

Returns:

the new Circuit