def test_WireCut(self): """Test WireCut gets correct special call.""" with QuantumTape() as tape: qml.WireCut(wires=(0, 1)) _, ax = tape_mpl(tape) layer = 0 assert len(ax.lines) == 2 assert len(ax.collections) == 2 plt.close()
def test_wirecut_block(self): """Test the wirecut blocking operators""" ops = [qml.PauliX(0), qml.WireCut(wires=[0, 1]), qml.PauliX(1)] layers = drawable_layers(ops) assert layers == [{ops[0]}, {ops[1]}, {ops[2]}]
(qml.PauliZ(0), "Z", "Z"), (qml.S(wires=0), "S", "S⁻¹"), (qml.T(wires=0), "T", "T⁻¹"), (qml.SX(wires=0), "SX", "SX⁻¹"), (qml.CNOT(wires=(0, 1)), "⊕", "⊕"), (qml.CZ(wires=(0, 1)), "Z", "Z"), (qml.CY(wires=(0, 1)), "Y", "Y"), (qml.SWAP(wires=(0, 1)), "SWAP", "SWAP⁻¹"), (qml.ISWAP(wires=(0, 1)), "ISWAP", "ISWAP⁻¹"), (qml.SISWAP(wires=(0, 1)), "SISWAP", "SISWAP⁻¹"), (qml.SQISW(wires=(0, 1)), "SISWAP", "SISWAP⁻¹"), (qml.CSWAP(wires=(0, 1, 2)), "SWAP", "SWAP"), (qml.Toffoli(wires=(0, 1, 2)), "⊕", "⊕"), (qml.MultiControlledX(control_wires=(0, 1, 2), wires=(3)), "⊕", "⊕"), (qml.Barrier(0), "||", "||"), (qml.WireCut(wires=0), "//", "//"), ] @pytest.mark.parametrize("op, label1, label2", label_data) def test_label_method(op, label1, label2): assert op.label() == label1 assert op.label(decimals=2) == label1 op.inv() assert op.label() == label2 control_data = [ (qml.Identity(0), Wires([])), (qml.Hadamard(0), Wires([])),
def with_wirecut(): qml.PauliX(wires=0) qml.WireCut(wires=0) return qml.state()
"Rot": qml.Rot(0, 0, 0, wires=[0]), "S": qml.S(wires=[0]), "SWAP": qml.SWAP(wires=[0, 1]), "ISWAP": qml.ISWAP(wires=[0, 1]), "T": qml.T(wires=[0]), "SX": qml.SX(wires=[0]), "Barrier": qml.Barrier(wires=[0, 1, 2]), "WireCut": qml.WireCut(wires=[0]), "Toffoli": qml.Toffoli(wires=[0, 1, 2]), "QFT": qml.templates.QFT(wires=[0, 1, 2]), "IsingXX": qml.IsingXX(0, wires=[0, 1]), "IsingYY": qml.IsingYY(0, wires=[0, 1]), "IsingZZ": qml.IsingZZ(0, wires=[0, 1]), "SingleExcitation": qml.SingleExcitation(0, wires=[0, 1]), "SingleExcitationPlus": qml.SingleExcitationPlus(0, wires=[0, 1]), "SingleExcitationMinus":