Skip to content
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

Add segfaulting doctest to quantum/bb84.py for demo purposes #8841

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions DIRECTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* [Minmax](backtracking/minmax.py)
* [N Queens](backtracking/n_queens.py)
* [N Queens Math](backtracking/n_queens_math.py)
* [Power Sum](backtracking/power_sum.py)
* [Rat In Maze](backtracking/rat_in_maze.py)
* [Sudoku](backtracking/sudoku.py)
* [Sum Of Subsets](backtracking/sum_of_subsets.py)
Expand Down
10 changes: 6 additions & 4 deletions quantum/bb84.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ def bb84(key_len: int = 8, seed: int | None = None) -> str:

>>> bb84(8, seed=0)
'10110001'

# Example from
# https://learn.qiskit.org/course/ch-algorithms/quantum-key-distribution
>>> bb84(100, seed=0)
'011110100001000111010110100000010011000111100100'
"""
# Set up the random number generator.
rng = np.random.default_rng(seed=seed)
Expand Down Expand Up @@ -127,7 +132,4 @@ def bb84(key_len: int = 8, seed: int | None = None) -> str:


if __name__ == "__main__":
print(f"The generated key is : {bb84(8, seed=0)}")
from doctest import testmod

testmod()
print(bb84(100, seed=0))
Loading