You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following pytket/tket2 script (by @johnchildren) shows a mismatched encoding/decoding of diagonal boxes. The bug seems to originate from this crate, but we should write a reduced test case.
importjsonfrompytket.circuitimportDiagonalBox, QControlBoxfrompytketimportCircuitimportnumpyasnpfromtket2.circuitimportTk2Circuitfromdictdifferimportdiffu_diagonal=np.array([1, 1, np.e** (1j*np.pi/4), np.e** (1j*np.pi/8)])
d_box=DiagonalBox(u_diagonal)
controlled_d=QControlBox(d_box, n_controls=1)
circ=Circuit(3).add_gate(controlled_d, [0, 1, 2])
circ.get_unitary() # This works, circuit is unitarytket2_circ=Tk2Circuit.from_tket1_json(json.dumps(circ.to_dict()))
# Causes a different dictionary ot be output.postpostcirc=json.loads(tket2_circ.to_tket1_json())
# Dictionaries are differentprint(circ.to_dict())
print(postpostcirc)
print(list(diff(circ.to_dict(), postpostcirc)))
# ValueError: The input diagonal passed to DiagonalBox is not unitary.Circuit.from_dict(postpostcirc)
The following pytket/tket2 script (by @johnchildren) shows a mismatched encoding/decoding of diagonal boxes. The bug seems to originate from this crate, but we should write a reduced test case.
pytket circuit json:
The text was updated successfully, but these errors were encountered: