From 67e1b3778446d01be78d68bee43cafaaa7195cbb Mon Sep 17 00:00:00 2001 From: Eric Hulburd Date: Mon, 6 Jan 2025 13:52:01 -0800 Subject: [PATCH] chore: format python files --- .../qcs_sdk/qpu/experimental/__init__.pyi | 12 +++++++ .../qcs_sdk/qpu/experimental/random.pyi | 6 ++++ .../experimental/randomized_measurements.pyi | 1 + .../tests/qpu/experimental/test_random.py | 35 ++++++++++++++----- 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/crates/python/qcs_sdk/qpu/experimental/__init__.pyi b/crates/python/qcs_sdk/qpu/experimental/__init__.pyi index fd3bd2c0..0184f245 100644 --- a/crates/python/qcs_sdk/qpu/experimental/__init__.pyi +++ b/crates/python/qcs_sdk/qpu/experimental/__init__.pyi @@ -1,3 +1,15 @@ +""" +This module supports experimental features that meet the following criteria: + +* They support recent and compelling research in quantum computing. +* Implementation is specific to Rigetti's QPUs; implementation may + not othewrise be expressed through a generalized quantum computing + language, such as Quil or QASM. + +As such, the features contained herein should be considered unstable, possibly +ephemeral, and subject to specific authorization checks. +""" + from qcs_sdk.qpu.experimental import ( random as random, randomized_measurements as randomized_measurements, diff --git a/crates/python/qcs_sdk/qpu/experimental/random.pyi b/crates/python/qcs_sdk/qpu/experimental/random.pyi index 403256f1..6fb2e825 100644 --- a/crates/python/qcs_sdk/qpu/experimental/random.pyi +++ b/crates/python/qcs_sdk/qpu/experimental/random.pyi @@ -1,3 +1,9 @@ +""" +This module supports low-level primitives for randomization on Rigetti's QPUs. +For an example application of this functionality see +`qcs_sdk.qpu.experimental.randomized_measurements`. +""" + from typing import List, final from typing_extensions import Self diff --git a/crates/python/qcs_sdk/qpu/experimental/randomized_measurements.pyi b/crates/python/qcs_sdk/qpu/experimental/randomized_measurements.pyi index 752035bf..27b55e0d 100644 --- a/crates/python/qcs_sdk/qpu/experimental/randomized_measurements.pyi +++ b/crates/python/qcs_sdk/qpu/experimental/randomized_measurements.pyi @@ -32,6 +32,7 @@ the `RandomizedMeasurements` class using a RZ-RX-RZ-RX-RZ unitary decomposition. .. include:: tests/qpu/experimental/test_randomized_measurements.py ``` """ + from qcs_sdk.qpu.experimental.random import PrngSeedValue from typing import Dict, List, Self, final diff --git a/crates/python/tests/qpu/experimental/test_random.py b/crates/python/tests/qpu/experimental/test_random.py index cdc6415c..92d5865c 100644 --- a/crates/python/tests/qpu/experimental/test_random.py +++ b/crates/python/tests/qpu/experimental/test_random.py @@ -1,5 +1,15 @@ from quil.program import Program -from quil.instructions import Declaration, Instruction, Pragma, Call, CallArgument, MemoryReference, Vector, ScalarType, PragmaArgument +from quil.instructions import ( + Declaration, + Instruction, + Pragma, + Call, + CallArgument, + MemoryReference, + Vector, + ScalarType, + PragmaArgument, +) from qcs_sdk.qpu.experimental.random import ChooseRandomRealSubRegions @@ -11,6 +21,7 @@ CALL choose_random_real_sub_regions destination source 3 seed[0] """ + def test_choose_random_real_subregions(): """Test that `ChooseRandomRealSubRegions` is correctly added to a Quil progrram.""" program = Program() @@ -20,14 +31,20 @@ def test_choose_random_real_subregions(): program.add_instruction(Instruction.from_declaration(source)) seed = Declaration("seed", Vector(ScalarType.Integer, 1), None) program.add_instruction(Instruction.from_declaration(seed)) - pragma_extern = Pragma("EXTERN", [PragmaArgument.from_identifier(ChooseRandomRealSubRegions.NAME)], ChooseRandomRealSubRegions.build_signature()) + pragma_extern = Pragma( + "EXTERN", + [PragmaArgument.from_identifier(ChooseRandomRealSubRegions.NAME)], + ChooseRandomRealSubRegions.build_signature(), + ) program.add_instruction(Instruction.from_pragma(pragma_extern)) - call = Call(ChooseRandomRealSubRegions.NAME, [ - CallArgument.from_identifier("destination"), - CallArgument.from_identifier("source"), - CallArgument.from_immediate(complex(3, 0)), - CallArgument.from_memory_reference(MemoryReference("seed", 0)), - ]) + call = Call( + ChooseRandomRealSubRegions.NAME, + [ + CallArgument.from_identifier("destination"), + CallArgument.from_identifier("source"), + CallArgument.from_immediate(complex(3, 0)), + CallArgument.from_memory_reference(MemoryReference("seed", 0)), + ], + ) program.add_instruction(Instruction.from_call(call)) assert program == Program.parse(EXPECTED_QUIL) -