Skip to content

Commit

Permalink
chore: format python files
Browse files Browse the repository at this point in the history
  • Loading branch information
erichulburd committed Jan 6, 2025
1 parent 2f25204 commit 67e1b37
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 9 deletions.
12 changes: 12 additions & 0 deletions crates/python/qcs_sdk/qpu/experimental/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
6 changes: 6 additions & 0 deletions crates/python/qcs_sdk/qpu/experimental/random.pyi
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 26 additions & 9 deletions crates/python/tests/qpu/experimental/test_random.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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()
Expand All @@ -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)

0 comments on commit 67e1b37

Please sign in to comment.