Skip to content

Commit

Permalink
Combine retval variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
rmshaffer committed Jul 21, 2023
1 parent 8124a00 commit e968575
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
7 changes: 2 additions & 5 deletions src/braket/experimental/autoqasm/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,5 @@
QUBIT_REGISTER = "__qubits__"
"""Qubits are globally addressed, and so we can specify a single qubit register name."""

AUTOGRAPH_RETVAL_VARIABLE_NAME = "retval_"
"""A special name for variables assigned to the return values of AutoGraph function calls."""

AUTOQASM_RETVAL_VARIABLE_NAME = "__retval__"
"""A special name for variables assigned to the return values of AutoQASM function calls."""
RETVAL_VARIABLE_NAME = "retval_"
"""A special name for variables assigned to the return values of function calls."""
3 changes: 1 addition & 2 deletions src/braket/experimental/autoqasm/operators/assignments.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def assign_stmt(target_name: str, value: Any) -> Any:
if isinstance(value, UndefinedReturnValue):
return value

if target_name == constants.AUTOGRAPH_RETVAL_VARIABLE_NAME:
if target_name == constants.RETVAL_VARIABLE_NAME:
# AutoGraph transpiles return statements like
# return <return_value>
# into
Expand All @@ -58,7 +58,6 @@ def assign_stmt(target_name: str, value: Any) -> Any:
return value

value = types.wrap_value(value)
target_name = constants.AUTOQASM_RETVAL_VARIABLE_NAME

if isinstance(value, oqpy.base.Var):
oqpy_program = program.get_program_conversion_context().get_oqpy_program()
Expand Down
8 changes: 4 additions & 4 deletions test/unit_tests/braket/experimental/autoqasm/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,8 +807,8 @@ def caller() -> int:

expected_qasm = """OPENQASM 3.0;
def retval_test() -> int[32] {
int[32] __retval__ = 1;
return __retval__;
int[32] retval_ = 1;
return retval_;
}
int[32] __int_1__ = 0;
__int_1__ = retval_test();"""
Expand All @@ -829,8 +829,8 @@ def caller() -> aq.BitVar:

expected_qasm = """OPENQASM 3.0;
def retval_test() -> bit {
bit __retval__ = 1;
return __retval__;
bit retval_ = 1;
return retval_;
}
bit __bit_0__;
__bit_0__ = retval_test();"""
Expand Down

0 comments on commit e968575

Please sign in to comment.