Skip to content

Commit

Permalink
Update src/qibo/_openqasm.py
Browse files Browse the repository at this point in the history
Co-authored-by: Renato Mello <[email protected]>
  • Loading branch information
BrunoLiegiBastonLiegi and renatomello authored Feb 27, 2024
1 parent 20b74f2 commit 4585ed1
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/qibo/_openqasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,19 +246,17 @@ def _unroll_expression(self, expr):
if "name" in dir(expr):
return expr.name
# check whether the expression is a single value, e.g. `0.1234`
elif "value" in dir(expr):
if "value" in dir(expr):
return expr.value
# the expression is composite, e.g. `2*pi` or `3*theta/2`
else:
expr_dict = {}
for attr in ("lhs", "op", "expression", "rhs"):
expr_dict[attr] = ""
if attr in dir(expr):
val = self._unroll_expression(getattr(expr, attr))
else:
continue
expr_dict = {}
for attr in ("lhs", "op", "expression", "rhs"):
expr_dict[attr] = ""
if attr in dir(expr):
val = self._unroll_expression(getattr(expr, attr))
expr_dict[attr] += str(val)
return "".join(list(expr_dict.values()))

return "".join(list(expr_dict.values()))

def _def_gate(self, definition):
"""Converts a :class:`openqasm3.ast.QuantumGateDefinition` statement
Expand Down

0 comments on commit 4585ed1

Please sign in to comment.