Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Process duration ast first
Browse files Browse the repository at this point in the history
jcjaskula-aws committed Nov 23, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent b616186 commit eec93ee
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion oqpy/program.py
Original file line number Diff line number Diff line change
@@ -348,6 +348,8 @@ def delay(
qubits_or_frames: AstConvertible | Iterable[AstConvertible] | None = None,
) -> Program:
"""Apply a delay to a set of qubits or frames."""
ast_duration = to_ast(self, make_duration(time))

if qubits_or_frames is None:
ast_qubits_or_frames = []
else:
@@ -358,7 +360,6 @@ def delay(
if len(qubits_or_frames) == 0:
return self
ast_qubits_or_frames = map_to_ast(self, qubits_or_frames)
ast_duration = to_ast(self, make_duration(time))
self._add_statement(ast.DelayInstruction(ast_duration, ast_qubits_or_frames))
return self

2 changes: 1 addition & 1 deletion tests/test_directives.py
Original file line number Diff line number Diff line change
@@ -970,8 +970,8 @@ def _to_oqpy_expression(self):
"""
OPENQASM 3.0;
duration a1 = 100.0ns;
frame f1;
duration a2 = 100.0ns;
frame f1;
a1 = 2;
delay[a2] f1;
"""

0 comments on commit eec93ee

Please sign in to comment.