Skip to content

Commit

Permalink
improve exporters
Browse files Browse the repository at this point in the history
  • Loading branch information
dakk committed Dec 30, 2023
1 parent 62d50c6 commit c104813
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 9 deletions.
5 changes: 1 addition & 4 deletions qlasskit/qcircuit/exporter_pennylane.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ def export(self, _selfqc, mode: Literal["circuit", "gate"]): # noqa: C901
elif isinstance(g, gates.CP):
ops.append(qml.CPhase(p, wires=w))

elif isinstance(g, gates.Barrier):
pass

elif isinstance(g, gates.NopGate):
elif issubclass(g.__class__, gates.NopGate):
pass

elif hasattr(qml, g_name):
Expand Down
2 changes: 1 addition & 1 deletion qlasskit/qcircuit/exporter_qasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def export(self, _selfqc, mode: Literal["circuit", "gate"]):
gate_qasm += " ".join(_selfqc.qubit_map.keys())
gate_qasm += " {\n"
for g, ws, p in _selfqc.gates:
if isinstance(g, gates.NopGate):
if issubclass(g.__class__, gates.NopGate):
continue

qbs = list(map(lambda gq: _selfqc.get_key_by_index(gq), ws))
Expand Down
2 changes: 1 addition & 1 deletion qlasskit/qcircuit/exporter_qiskit.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def export(self, _selfqc, mode: Literal["circuit", "gate"]): # noqa: C901
elif isinstance(g, gates.Barrier) and mode != "gate":
qc.barrier(label=p)

elif isinstance(g, gates.NopGate):
elif issubclass(g.__class__, gates.NopGate):
pass

elif hasattr(qc, g_name):
Expand Down
2 changes: 1 addition & 1 deletion qlasskit/qcircuit/exporter_sympy.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def export(self, _selfqc, mode: Literal["circuit", "gate"]): # noqa: C901
ga = mcx(w)
elif isinstance(g, gates.Barrier) and mode != "gate":
pass
elif isinstance(g, gates.NopGate):
elif issubclass(g.__class__, gates.NopGate):
pass
else:
raise Exception(f"Gate not handled for sympy exporter: {g_name}")
Expand Down
2 changes: 1 addition & 1 deletion qlasskit/qcircuit/qcircuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def append(self, gate: QGate, qubits: List[int], param: Any = None):
applied = gates.apply(gate, qubits, param)
self.gates.append(applied)

if not isinstance(gate, gates.NopGate):
if not issubclass(gate.__class__, gates.NopGate):
self.gates_computed.append(applied)

def barrier(self, label=None):
Expand Down
2 changes: 1 addition & 1 deletion test/test_qlassf_hybrid_quantum.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_h(self):
# print(qf.expressions)
# count = qiskit_measure_and_count(qf.circuit().export(), 128)
# [self.assertEqual(x in count, True) for x in ["00", "11", "01", "11"]]

def test_h_multi(self):
f = "def test(a: Qint2) -> Qint2:\n\treturn Q.H(a)"
qf = qlassf(f, to_compile=COMPILATION_ENABLED, uncompute=False)
Expand Down

0 comments on commit c104813

Please sign in to comment.