Skip to content

Commit

Permalink
Rename QasmRange to Range
Browse files Browse the repository at this point in the history
  • Loading branch information
rmshaffer committed Dec 14, 2023
1 parent 9e77d40 commit 21c7dd8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/braket/experimental/autoqasm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ def my_program():
from .program import Program, build_program, verbatim # noqa: F401
from .transpiler import transpiler # noqa: F401
from .types import ArrayVar, BitVar, BoolVar, FloatVar, IntVar # noqa: F401
from .types import QasmRange as range # noqa: F401
from .types import Range as range # noqa: F401
4 changes: 2 additions & 2 deletions src/braket/experimental/autoqasm/program/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,12 +629,12 @@ def else_block(self) -> contextlib._GeneratorContextManager:
return self._control_flow_block(oqpy.Else(oqpy_program))

def for_in(
self, iterator: aq_types.QasmRange, iterator_name: Optional[str]
self, iterator: aq_types.Range, iterator_name: Optional[str]
) -> contextlib._GeneratorContextManager:
"""Sets the program conversion context into a for loop context.
Args:
iterator (QasmRange): The iterator of the for loop.
iterator (Range): The iterator of the for loop.
iterator_name (Optional[str]): The symbol to use as the name of the iterator.
Yields:
Expand Down
10 changes: 1 addition & 9 deletions src/braket/experimental/autoqasm/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,4 @@
"""

from .conversions import map_parameter_type, var_type_from_oqpy, wrap_value # noqa: F401
from .types import ( # noqa: F401
ArrayVar,
BitVar,
BoolVar,
FloatVar,
IntVar,
QasmRange,
is_qasm_type,
)
from .types import ArrayVar, BitVar, BoolVar, FloatVar, IntVar, Range, is_qasm_type # noqa: F401
4 changes: 2 additions & 2 deletions src/braket/experimental/autoqasm/types/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def is_qasm_type(val: Any) -> bool:
return isinstance(val, qasm_types)


class QasmRange(oqpy.Range):
class Range(oqpy.Range):
def __init__(
self,
start: int,
Expand All @@ -64,7 +64,7 @@ def __init__(
if stop is None:
stop = start
start = 0
super(QasmRange, self).__init__(start, stop, step)
super(Range, self).__init__(start, stop, step)
self.annotations = annotations or []


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def test_control_flow_for_loop_qasm() -> None:
"""Tests aq.operators.for_stmt with a QASM iterable."""
with aq.build_program(aq.program.UserConfig(num_qubits=10)) as program_conversion_context:
aq.operators.for_stmt(
iter=aq.types.QasmRange(3),
iter=aq.types.Range(3),
extra_test=None,
body=for_body,
get_state=None,
Expand Down
8 changes: 4 additions & 4 deletions test/unit_tests/braket/experimental/autoqasm/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import pytest

import braket.experimental.autoqasm as aq
from braket.experimental.autoqasm.types import QasmRange
from braket.experimental.autoqasm.types import Range


@pytest.mark.parametrize(
Expand All @@ -30,14 +30,14 @@
def test_range(
range_params: tuple[int, int, int], expected_range_params: tuple[int, int, int]
) -> None:
"""Test `QasmRange()` returning correct `QasmRange` object.
"""Test `Range()` returning correct `Range` object.
Args:
range_params (tuple[int, int, int]): Range parameters to instantiate `QasmRange`
range_params (tuple[int, int, int]): Range parameters to instantiate `Range`
expected_range_params (tuple[int, int, int]): Expected range parameters
"""
start, stop, step = range_params
qrange = QasmRange(start, stop, step)
qrange = Range(start, stop, step)
assert isinstance(qrange, oqpy.Range)
assert (qrange.start, qrange.stop, qrange.step) == expected_range_params

Expand Down

0 comments on commit 21c7dd8

Please sign in to comment.