Python/quantum/quantum_random.py.DISABLED.txt
Tianyi Zheng 0ef9306976
Disable quantum/quantum_random.py (attempt 2) (#8902)
* Disable quantum/quantum_random.py

Temporarily disable quantum/quantum_random.py because it produces an illegal instruction error that causes all builds to fail

* updating DIRECTORY.md

* Disable quantum/quantum_random.py attempt 2

---------

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
2023-07-28 22:08:40 +02:00

31 lines
726 B
Plaintext

import doctest
import projectq
from projectq.ops import H, Measure
def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int:
"""
>>> isinstance(get_random_number(projectq.MainEngine()), int)
True
"""
qubit = quantum_engine.allocate_qubit()
H | qubit
Measure | qubit
return int(qubit)
if __name__ == "__main__":
doctest.testmod()
# initialises a new quantum backend
quantum_engine = projectq.MainEngine()
# Generate a list of 10 random numbers
random_numbers_list = [get_random_number(quantum_engine) for _ in range(10)]
# Flushes the quantum engine from memory
quantum_engine.flush()
print("Random numbers", random_numbers_list)