diff --git a/setup.py b/setup.py index 677d153..e45b277 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ package_dir={"": "src"}, install_requires=[ # Pin the latest commit of mcm-sim branch of amazon-braket/amazon-braket-sdk-python.git - "amazon-braket-sdk @ git+https://github.com/amazon-braket/amazon-braket-sdk-python.git@fe601096b7bba2a1bd8700896080d93672732c4c#egg=amazon-braket-sdk", # noqa E501 + "amazon-braket-sdk @ git+https://github.com/amazon-braket/amazon-braket-sdk-python.git@da74ee713c200ac0803704bb0b4c87f9d0100682#egg=amazon-braket-sdk", # noqa E501 "amazon-braket-default-simulator>=1.23.2", "oqpy~=0.3.5", "diastatic-malt", diff --git a/src/autoqasm/program/program.py b/src/autoqasm/program/program.py index c97c82a..97809db 100644 --- a/src/autoqasm/program/program.py +++ b/src/autoqasm/program/program.py @@ -121,7 +121,7 @@ def build(self, device: Device | str | None = None) -> Program: def to_ir( self, ir_type: IRType = IRType.OPENQASM, - allow_implicit_build: bool = False, + build_if_necessary: bool = False, serialization_properties: SerializationProperties = OpenQASMSerializationProperties(), ) -> str: """Serializes the program into an intermediate representation. @@ -129,20 +129,20 @@ def to_ir( Args: ir_type (IRType): The IRType to use for converting the program to its IR representation. Defaults to IRType.OPENQASM. - allow_implicit_build (bool): Whether to allow the program to be implicitly + build_if_necessary (bool): Whether to allow the program to be implicitly built as a side effect of calling this function. Defaults to False. serialization_properties (SerializationProperties): IR serialization configuration. Default to OpenQASMSerializationProperties(). Raises: ValueError: Raised if the supplied `ir_type` is not supported. - RuntimeError: Raised if `allow_implicit_build` is False, since a MainProgram object + RuntimeError: Raised if `build_if_necessary` is False, since a MainProgram object has not yet been built. Returns: str: A representation of the program in the `ir_type` format. """ - if not allow_implicit_build: + if not build_if_necessary: raise RuntimeError( "The AutoQASM program cannot be serialized because it has not yet been built. " "To serialize the program, first call build() to obtain a built Program object, " @@ -227,7 +227,7 @@ def make_bound_program(self, param_values: dict[str, float], strict: bool = Fals def to_ir( self, ir_type: IRType = IRType.OPENQASM, - allow_implicit_build: bool = True, + build_if_necessary: bool = True, serialization_properties: SerializationProperties = OpenQASMSerializationProperties(), ) -> str: """Serializes the program into an intermediate representation. @@ -235,7 +235,7 @@ def to_ir( Args: ir_type (IRType): The IRType to use for converting the program to its IR representation. Defaults to IRType.OPENQASM. - allow_implicit_build (bool): Whether to allow the program to be implicitly + build_if_necessary (bool): Whether to allow the program to be implicitly built as a side effect of calling this function. Defaults to True. This parameter is ignored for the Program class, since the program has already been built. diff --git a/test/unit_tests/autoqasm/test_api.py b/test/unit_tests/autoqasm/test_api.py index 3d7b331..3f4a584 100644 --- a/test/unit_tests/autoqasm/test_api.py +++ b/test/unit_tests/autoqasm/test_api.py @@ -952,11 +952,11 @@ def empty_program() -> None: def test_to_ir_implicit_build(empty_program) -> None: """Test that to_ir works as expected with and without implicit build.""" expected = """OPENQASM 3.0;""" - assert empty_program.build().to_ir(allow_implicit_build=False) == expected - assert empty_program.build().to_ir(allow_implicit_build=True) == expected - assert empty_program.to_ir(allow_implicit_build=True) == expected + assert empty_program.build().to_ir(build_if_necessary=False) == expected + assert empty_program.build().to_ir(build_if_necessary=True) == expected + assert empty_program.to_ir(build_if_necessary=True) == expected with pytest.raises(RuntimeError): - empty_program.to_ir(allow_implicit_build=False) + empty_program.to_ir(build_if_necessary=False) def test_main_no_return(): diff --git a/tox.ini b/tox.ini index c4ca0c6..572d24e 100644 --- a/tox.ini +++ b/tox.ini @@ -133,5 +133,5 @@ commands = [test-deps] deps = # If you need to test on a certain branch, add @ after .git - git+https://github.com/amazon-braket/amazon-braket-sdk-python.git@fe601096b7bba2a1bd8700896080d93672732c4c # mcm-sim branch + git+https://github.com/amazon-braket/amazon-braket-sdk-python.git@da74ee713c200ac0803704bb0b4c87f9d0100682 # mcm-sim branch git+https://github.com/amazon-braket/amazon-braket-default-simulator-python.git