Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/stable/0.3' into stable/0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
chensgit169 committed Oct 28, 2023
2 parents 081d001 + b17f3e8 commit 2efa95b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/quafu/circuits/quantum_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ def measures(self, measures):

@property
def gates(self):
warnings.warn('Deprecated warning: due to historical reason, ``gates`` contains not only instances of '
warnings.warn('Due to historical reason, ``gates`` contains not only instances of '
'QuantumGate, meanwhile not contains measurements. This attributes might be deprecated in'
' the future. Better to use ``instructions`` which contains all the instructions.')
' the future. Better to use ``instructions`` which contains all the instructions.',
category=DeprecationWarning)
return self._gates

@gates.setter
Expand Down
7 changes: 6 additions & 1 deletion src/quafu/tasks/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,12 @@ def send(self,
else:
self.submit_history[group].append(task_id)

return ExecResult(res_dict)
result = ExecResult(res_dict)
while wait and (self.shots > 0) and (not result.counts):
if verbose:
logging.warning('warning for quafu status: empty result.counts, retrieving task...')
result = self.retrieve(result.taskid)
return result

def retrieve(self, taskid: str) -> ExecResult:
"""
Expand Down
7 changes: 4 additions & 3 deletions src/quafu/visualisation/circuitPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,9 @@ def _process_ins(self, ins: Instruction, append: bool = True):
elif name in r2_gate_names:
# TODO: combine into one box
self._ctrl_wire_points.append([[depth, ins.pos[0]], [depth, ins.pos[1]]])
self._proc_su2(name[:-1], depth, ins.pos[0], paras)
self._proc_su2(name[:-1], depth, ins.pos[1], paras)

self._proc_su2(name[:-1], depth, min(ins.pos), None)
self._proc_su2(name[:-1], depth, max(ins.pos), paras)
elif isinstance(ins, ControlledGate):
self._proc_ctrl(depth, ins)
elif name == 'delay':
Expand Down Expand Up @@ -363,7 +364,7 @@ def _proc_su2(self, id_name, depth, pos, paras):

if id_name in ['rx', 'ry', 'rz', 'p']:
# too long to display: r'$\theta=$' + f'{paras:.3f}' (TODO)
para_txt = f'({paras:.3f})'
para_txt = f'({paras:.3f})' if paras else None
else:
para_txt = None

Expand Down

0 comments on commit 2efa95b

Please sign in to comment.