from pytket.circuit import Circuit, CircBox
qpe_circ = Circuit()
a = qpe_circ.add_q_register("a", 2)
s = qpe_circ.add_q_register("s", 1)
qpe_circ.H(a[0])
qpe_circ.CU1(0.94, a[1], s[0])
qpe_box = CircBox(qpe_circ)
algorithm_circ = Circuit()
ancillas = algorithm_circ.add_q_register("ancillas", 2)
state = algorithm_circ.add_q_register("state", 1)
algorithm_circ.X(state[0])
algorithm_circ.add_circbox_with_regmap(qpe_box, qregmap={"a": "ancillas", "s": "state"})
This gives a TypeError and its not clear why based on the error message.
The way to fix this is to pass in an empty dictcregmap argument to specify how to map the classical registers inside and outside the box to be joined. This unnatural as my Circuit has no bits (only qubits). I think it'd be more user friendly to make these arguments optional.
The same is true for Circuit.add_circbox_regiwise. You need to pass in an empty list for the cregs arg adding a CircBox to a pure quantum circuit.
The following snippet works... (note the cregmap = {})
As it stands currently
cregmap
andcregs
are non-optional arguments to Circuit.add_circbox_with_regmap) and Circuit.add_circbox_regwiseSee the section of the user manual -> https://tket.quantinuum.com/user-manual/manual_circuit.html#circuit-boxes
Consider the following example...
This gives a
TypeError
and its not clear why based on the error message.The way to fix this is to pass in an empty
dict
cregmap
argument to specify how to map the classical registers inside and outside the box to be joined. This unnatural as myCircuit
has no bits (only qubits). I think it'd be more user friendly to make these arguments optional.The same is true for
Circuit.add_circbox_regiwise
. You need to pass in an empty list for thecregs
arg adding aCircBox
to a pure quantum circuit.The following snippet works... (note the
cregmap = {}
)