Skip to content

Commit

Permalink
Allow running trivial circuits on IBM Q, as long as there is at least…
Browse files Browse the repository at this point in the history
… one measurement. (#265)
  • Loading branch information
thomashaener committed Aug 26, 2018
1 parent e0917d1 commit 3eaab56
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions projectq/backends/_ibm/_ibm.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,16 @@ def _run(self):
Send the circuit via the IBM API (JSON QASM) using the provided user
data / ask for username & password.
"""
if self.qasm == "":
return
# finally: add measurements (no intermediate measurements are allowed)
for measured_id in self._measured_ids:
qb_loc = self.main_engine.mapper.current_mapping[measured_id]
self.qasm += "\nmeasure q[{}] -> c[{}];".format(qb_loc,
qb_loc)

# return if no operations / measurements have been performed.
if self.qasm == "":
return

max_qubit_id = max(self._allocated_qubits)
qasm = ("\ninclude \"qelib1.inc\";\nqreg q[{nq}];\ncreg c[{nq}];" +
self.qasm).format(nq=max_qubit_id + 1)
Expand Down

0 comments on commit 3eaab56

Please sign in to comment.