-
-
Notifications
You must be signed in to change notification settings - Fork 47k
Add quantum_random.py #7446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add quantum_random.py #7446
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
cfdebf3
Create quantum_random.py
Alanzz 345851d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0d7f911
Update quantum_random.py
Alanzz a11917e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 9c5babb
Update quantum_random.py
Alanzz c499f6c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 6c7589e
Update quantum/quantum_random.py
Alanzz b57bb45
Update quantum/quantum_random.py
Alanzz d9614fe
Update quantum/quantum_random.py
Alanzz 62db8d1
Update quantum_random.py
Alanzz 2819d05
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 572e22b
Update quantum_random.py
Alanzz 4286193
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 2d690ef
requirements.txt: Add projectq
cclauss 922ee2c
Update quantum_random.py
Alanzz d0258f0
Update quantum/quantum_random.py
Alanzz 8b052d1
Update quantum_random.py
Alanzz 84d794b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 757ac8a
Update quantum_random.py
Alanzz fce3736
Update quantum_random.py
Alanzz a6c2d90
Update quantum/quantum_random.py
cclauss c0f07bd
Update quantum/quantum_random.py
cclauss 4722451
Update quantum_random.py
Alanzz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import doctest | ||
|
||
import projectq | ||
from projectq.ops import H, Measure | ||
|
||
|
||
def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int: | ||
Alanzz marked this conversation as resolved.
Show resolved
Hide resolved
Alanzz marked this conversation as resolved.
Show resolved
Hide resolved
Alanzz marked this conversation as resolved.
Show resolved
Hide resolved
Alanzz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
>>> 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 | ||
cclauss marked this conversation as resolved.
Show resolved
Hide resolved
|
||
quantum_engine.flush() | ||
|
||
print("Random numbers", random_numbers_list) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ numpy | |
opencv-python | ||
pandas | ||
pillow | ||
projectq | ||
qiskit | ||
requests | ||
scikit-fuzzy | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.