Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions guppylang-internals/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ dependencies = [
"hugr ~= 0.13.1",
]

[tool.uv.sources]
tket-exts = { git = "https://github.com/CQCL/tket2", subdirectory = "tket-exts", rev = "eed16e8" }

[project.optional-dependencies]
pytket = ["pytket>=1.34"]

Expand Down
10 changes: 10 additions & 0 deletions guppylang/src/guppylang/std/qsystem/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ def random_int_bounded(self: "RNG", bound: int) -> int:
bound: The upper bound of the range, needs to less than 2^31.
"""

@hugr_op(external_op("RandomAdvance", [], ext=QSYSTEM_RANDOM_EXTENSION))
@no_type_check
def random_advance(self: "RNG", delta: int) -> None:
"""Advance or backtrack the RNG state by a given number of steps.

Args:
delta: Number of steps to move the RNG state forward (if positive)
or backward (if negative).
"""

@guppy
@no_type_check
def shuffle(self: "RNG", array: array[SHUFFLE_T, SHUFFLE_N]) -> None:
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/test_qsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ def test() -> tuple[int, float, int, int, angle, angle]:
rint = rng.random_int()
rfloat = rng.random_float()
rint_bnd = rng.random_int_bounded(100)
rng.random_advance(-1)
rint_bnd = rng.random_int_bounded(100)
ar = array(qubit() for _ in range(5))
rng.shuffle(ar)
_ = measure_array(ar)
Expand Down
29 changes: 9 additions & 20 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading