From cfdebf36c1e2e514712bc7ec20f66c30faa7a54d Mon Sep 17 00:00:00 2001 From: Alan Paul <57307037+Alanzz@users.noreply.github.com> Date: Thu, 20 Oct 2022 11:25:45 +0530 Subject: [PATCH 01/23] Create quantum_random.py --- quantum/quantum_random.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 quantum/quantum_random.py diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py new file mode 100644 index 000000000000..e7fcb6817ace --- /dev/null +++ b/quantum/quantum_random.py @@ -0,0 +1,21 @@ +from projectq.ops import H, Measure +from projectq import MainEngine + +def get_random_number(quantum_engine): + qubit = quantum_engine.allocate_qubit() + H | qubit + Measure | qubit + random_number = int(qubit) + return random_number + +# This list is used to store our random numbers +random_numbers_list = [] +# initialises a new quantum backend +quantum_engine = MainEngine() +# for loop to generate 10 random numbers +for i in range(10): + # calling the random number function and append the return to the list + random_numbers_list.append(get_random_number(quantum_engine)) +# Flushes the quantum engine from memory +quantum_engine.flush() +print('Random numbers', random_numbers_list) From 345851d91aa11a760960dae637438e053f2f450b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 20 Oct 2022 06:00:52 +0000 Subject: [PATCH 02/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- quantum/quantum_random.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index e7fcb6817ace..de7a4db00a6e 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -1,5 +1,6 @@ -from projectq.ops import H, Measure from projectq import MainEngine +from projectq.ops import H, Measure + def get_random_number(quantum_engine): qubit = quantum_engine.allocate_qubit() @@ -8,6 +9,7 @@ def get_random_number(quantum_engine): random_number = int(qubit) return random_number + # This list is used to store our random numbers random_numbers_list = [] # initialises a new quantum backend @@ -18,4 +20,4 @@ def get_random_number(quantum_engine): random_numbers_list.append(get_random_number(quantum_engine)) # Flushes the quantum engine from memory quantum_engine.flush() -print('Random numbers', random_numbers_list) +print("Random numbers", random_numbers_list) From 0d7f911c32f231abb531ac252b695cb101ef90af Mon Sep 17 00:00:00 2001 From: Alan Paul <57307037+Alanzz@users.noreply.github.com> Date: Thu, 20 Oct 2022 11:53:32 +0530 Subject: [PATCH 03/23] Update quantum_random.py --- quantum/quantum_random.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index de7a4db00a6e..0b9fa6d03451 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -1,8 +1,7 @@ from projectq import MainEngine from projectq.ops import H, Measure - -def get_random_number(quantum_engine): +def get_random_number(quantum_engine) -> int: qubit = quantum_engine.allocate_qubit() H | qubit Measure | qubit @@ -21,3 +20,8 @@ def get_random_number(quantum_engine): # Flushes the quantum engine from memory quantum_engine.flush() print("Random numbers", random_numbers_list) + +if __name__ == "__main__": + import doctest + doctest.testmod() + From a11917ee88389a581f562954204035188dca30e1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 20 Oct 2022 06:25:01 +0000 Subject: [PATCH 04/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- quantum/quantum_random.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index 0b9fa6d03451..fefb0b311f4b 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -1,6 +1,7 @@ from projectq import MainEngine from projectq.ops import H, Measure + def get_random_number(quantum_engine) -> int: qubit = quantum_engine.allocate_qubit() H | qubit @@ -23,5 +24,5 @@ def get_random_number(quantum_engine) -> int: if __name__ == "__main__": import doctest - doctest.testmod() + doctest.testmod() From 9c5babb2d21ca78ab0680eed59c3ef74100187a6 Mon Sep 17 00:00:00 2001 From: Alan Paul <57307037+Alanzz@users.noreply.github.com> Date: Thu, 20 Oct 2022 12:02:26 +0530 Subject: [PATCH 05/23] Update quantum_random.py --- quantum/quantum_random.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index fefb0b311f4b..48d378425edf 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -2,7 +2,7 @@ from projectq.ops import H, Measure -def get_random_number(quantum_engine) -> int: +def get_random_number(quantum_engine : projectq.cengines._main.MainEngine) -> int: qubit = quantum_engine.allocate_qubit() H | qubit Measure | qubit @@ -25,4 +25,4 @@ def get_random_number(quantum_engine) -> int: if __name__ == "__main__": import doctest - doctest.testmod() + doctest.testmod(name = "get_random_number") From c499f6c729704c3f40f5a68db12f9c8ba0f8df2d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 20 Oct 2022 06:33:30 +0000 Subject: [PATCH 06/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- quantum/quantum_random.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index 48d378425edf..232c230418b2 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -2,7 +2,7 @@ from projectq.ops import H, Measure -def get_random_number(quantum_engine : projectq.cengines._main.MainEngine) -> int: +def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int: qubit = quantum_engine.allocate_qubit() H | qubit Measure | qubit @@ -25,4 +25,4 @@ def get_random_number(quantum_engine : projectq.cengines._main.MainEngine) -> in if __name__ == "__main__": import doctest - doctest.testmod(name = "get_random_number") + doctest.testmod(name="get_random_number") From 6c7589e20e68dd87466c6162c44ee43bc851648f Mon Sep 17 00:00:00 2001 From: Alan Paul <57307037+Alanzz@users.noreply.github.com> Date: Thu, 20 Oct 2022 13:54:34 +0530 Subject: [PATCH 07/23] Update quantum/quantum_random.py Co-authored-by: Christian Clauss --- quantum/quantum_random.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index 232c230418b2..0db1f2f84c3d 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -3,6 +3,10 @@ def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int: + """ + >>> instance(get_random_number(MainEngine()), int) + True + """ qubit = quantum_engine.allocate_qubit() H | qubit Measure | qubit From b57bb45a4124f619b7b9071d234a9be4dca575b9 Mon Sep 17 00:00:00 2001 From: Alan Paul <57307037+Alanzz@users.noreply.github.com> Date: Thu, 20 Oct 2022 13:55:01 +0530 Subject: [PATCH 08/23] Update quantum/quantum_random.py Co-authored-by: Christian Clauss --- quantum/quantum_random.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index 0db1f2f84c3d..98735efac066 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -10,8 +10,7 @@ def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int qubit = quantum_engine.allocate_qubit() H | qubit Measure | qubit - random_number = int(qubit) - return random_number + return int(qubit) # This list is used to store our random numbers From d9614fea0944590d073293760ca9b587f4daebba Mon Sep 17 00:00:00 2001 From: Alan Paul <57307037+Alanzz@users.noreply.github.com> Date: Thu, 20 Oct 2022 13:55:12 +0530 Subject: [PATCH 09/23] Update quantum/quantum_random.py Co-authored-by: Christian Clauss --- quantum/quantum_random.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index 98735efac066..ab2c44951987 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -28,4 +28,4 @@ def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int if __name__ == "__main__": import doctest - doctest.testmod(name="get_random_number") + doctest.testmod() From 62db8d1f5db1b7a5f1a20deb62ab79d7f9655009 Mon Sep 17 00:00:00 2001 From: Alan Paul <57307037+Alanzz@users.noreply.github.com> Date: Thu, 20 Oct 2022 13:58:01 +0530 Subject: [PATCH 10/23] Update quantum_random.py --- quantum/quantum_random.py | 54 ++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index ab2c44951987..daa85611bacc 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -1,31 +1,33 @@ from projectq import MainEngine from projectq.ops import H, Measure - - -def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int: - """ - >>> instance(get_random_number(MainEngine()), int) - True - """ - qubit = quantum_engine.allocate_qubit() - H | qubit - Measure | qubit - return int(qubit) - - -# This list is used to store our random numbers -random_numbers_list = [] -# initialises a new quantum backend -quantum_engine = MainEngine() -# for loop to generate 10 random numbers -for i in range(10): - # calling the random number function and append the return to the list - random_numbers_list.append(get_random_number(quantum_engine)) -# Flushes the quantum engine from memory -quantum_engine.flush() -print("Random numbers", random_numbers_list) +import doctest if __name__ == "__main__": - import doctest - doctest.testmod() + + def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int: + """ + >>> instance(get_random_number(MainEngine()), int) + True + """ + qubit = quantum_engine.allocate_qubit() + H | qubit + Measure | qubit + return int(qubit) + + + # This list is used to store our random numbers + random_numbers_list = [] + + # initialises a new quantum backend + quantum_engine = MainEngine() + + # for loop to generate 10 random numbers + for i in range(10): + # calling the random number function and append the return to the list + random_numbers_list.append(get_random_number(quantum_engine)) + + # Flushes the quantum engine from memory + quantum_engine.flush() + + print("Random numbers", random_numbers_list) From 2819d05ebb798bdab9139bb0d005eb259409f5c7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 20 Oct 2022 08:30:54 +0000 Subject: [PATCH 11/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- quantum/quantum_random.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index daa85611bacc..7b0bad52672a 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -1,10 +1,11 @@ +import doctest + from projectq import MainEngine from projectq.ops import H, Measure -import doctest if __name__ == "__main__": doctest.testmod() - + def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int: """ >>> instance(get_random_number(MainEngine()), int) @@ -15,19 +16,18 @@ def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int Measure | qubit return int(qubit) - # This list is used to store our random numbers random_numbers_list = [] - + # initialises a new quantum backend quantum_engine = MainEngine() - + # for loop to generate 10 random numbers for i in range(10): # calling the random number function and append the return to the list random_numbers_list.append(get_random_number(quantum_engine)) - + # Flushes the quantum engine from memory quantum_engine.flush() - + print("Random numbers", random_numbers_list) From 572e22bb8bbf5bf54281b893491dffb97efb1b31 Mon Sep 17 00:00:00 2001 From: Alan Paul <57307037+Alanzz@users.noreply.github.com> Date: Thu, 20 Oct 2022 14:04:25 +0530 Subject: [PATCH 12/23] Update quantum_random.py --- quantum/quantum_random.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index 7b0bad52672a..b3cf6d8ef58c 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -1,12 +1,8 @@ import doctest - from projectq import MainEngine from projectq.ops import H, Measure -if __name__ == "__main__": - doctest.testmod() - - def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int: +def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int: """ >>> instance(get_random_number(MainEngine()), int) True @@ -16,6 +12,9 @@ def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int Measure | qubit return int(qubit) +if __name__ == "__main__": + doctest.testmod() + # This list is used to store our random numbers random_numbers_list = [] From 428619369743053b03709f7a0dc5994502d8d263 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 20 Oct 2022 08:35:30 +0000 Subject: [PATCH 13/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- quantum/quantum_random.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index b3cf6d8ef58c..5a4a7ca39611 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -1,20 +1,23 @@ import doctest + from projectq import MainEngine from projectq.ops import H, Measure + def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int: - """ - >>> instance(get_random_number(MainEngine()), int) - True - """ - qubit = quantum_engine.allocate_qubit() - H | qubit - Measure | qubit - return int(qubit) + """ + >>> instance(get_random_number(MainEngine()), int) + True + """ + qubit = quantum_engine.allocate_qubit() + H | qubit + Measure | qubit + return int(qubit) + if __name__ == "__main__": doctest.testmod() - + # This list is used to store our random numbers random_numbers_list = [] From 2d690efc2ddbae79164ee3f30f2c4f4e37cebc6f Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 20 Oct 2022 10:54:02 +0200 Subject: [PATCH 14/23] requirements.txt: Add projectq --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index b14a3eb0157c..25d2b4ef93d5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,6 +7,7 @@ numpy opencv-python pandas pillow +projectq qiskit requests scikit-fuzzy From 922ee2c1dbeb9154f4095182d9b2fb6d55862c9d Mon Sep 17 00:00:00 2001 From: Alan Paul <57307037+Alanzz@users.noreply.github.com> Date: Thu, 20 Oct 2022 14:34:36 +0530 Subject: [PATCH 15/23] Update quantum_random.py --- quantum/quantum_random.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index 5a4a7ca39611..a0d043821d6b 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -1,14 +1,13 @@ import doctest - -from projectq import MainEngine +import projectq from projectq.ops import H, Measure -def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int: - """ - >>> instance(get_random_number(MainEngine()), int) - True - """ +def get_random_number(quantum_engine : projectq.cengines._main.MainEngine) -> int: + # """ + # >>> instance(get_random_number(MainEngine()), int) + # True + # """ qubit = quantum_engine.allocate_qubit() H | qubit Measure | qubit From d0258f040aa0e2647080f085e8151a869a974e8b Mon Sep 17 00:00:00 2001 From: Alan Paul <57307037+Alanzz@users.noreply.github.com> Date: Thu, 20 Oct 2022 14:35:12 +0530 Subject: [PATCH 16/23] Update quantum/quantum_random.py Co-authored-by: Christian Clauss --- quantum/quantum_random.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index a0d043821d6b..3e2654288828 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -18,16 +18,11 @@ def get_random_number(quantum_engine : projectq.cengines._main.MainEngine) -> in doctest.testmod() # This list is used to store our random numbers - random_numbers_list = [] - # initialises a new quantum backend quantum_engine = MainEngine() - # for loop to generate 10 random numbers - for i in range(10): - # calling the random number function and append the return to the list - random_numbers_list.append(get_random_number(quantum_engine)) - + # 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() From 8b052d12fdf3029dbe28f17ad13a27ab6113642e Mon Sep 17 00:00:00 2001 From: Alan Paul <57307037+Alanzz@users.noreply.github.com> Date: Thu, 20 Oct 2022 14:36:01 +0530 Subject: [PATCH 17/23] Update quantum_random.py --- quantum/quantum_random.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index 3e2654288828..74bcce28864d 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -16,8 +16,7 @@ def get_random_number(quantum_engine : projectq.cengines._main.MainEngine) -> in if __name__ == "__main__": doctest.testmod() - - # This list is used to store our random numbers + # initialises a new quantum backend quantum_engine = MainEngine() From 84d794ba9257e7439fd7999be1bb001186e82f1c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 20 Oct 2022 09:11:03 +0000 Subject: [PATCH 18/23] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- quantum/quantum_random.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index 74bcce28864d..6b14762e911d 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -1,9 +1,10 @@ import doctest + import projectq from projectq.ops import H, Measure -def get_random_number(quantum_engine : projectq.cengines._main.MainEngine) -> int: +def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int: # """ # >>> instance(get_random_number(MainEngine()), int) # True @@ -16,7 +17,7 @@ def get_random_number(quantum_engine : projectq.cengines._main.MainEngine) -> in if __name__ == "__main__": doctest.testmod() - + # initialises a new quantum backend quantum_engine = MainEngine() From 757ac8a0cb35f4f6a922e0d1718870d113f155bc Mon Sep 17 00:00:00 2001 From: Alan Paul <57307037+Alanzz@users.noreply.github.com> Date: Thu, 20 Oct 2022 14:53:32 +0530 Subject: [PATCH 19/23] Update quantum_random.py --- quantum/quantum_random.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index 6b14762e911d..94a14b04cd29 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -6,7 +6,7 @@ def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int: # """ - # >>> instance(get_random_number(MainEngine()), int) + # >>> isinstance(get_random_number(MainEngine()), int) # True # """ qubit = quantum_engine.allocate_qubit() From fce3736fd0709df0babddec655712190937515a3 Mon Sep 17 00:00:00 2001 From: Alan Paul <57307037+Alanzz@users.noreply.github.com> Date: Thu, 20 Oct 2022 14:57:53 +0530 Subject: [PATCH 20/23] Update quantum_random.py --- quantum/quantum_random.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index 94a14b04cd29..3e0184d7a1e3 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -19,7 +19,7 @@ def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int doctest.testmod() # initialises a new quantum backend - quantum_engine = MainEngine() + quantum_engine = projectq.MainEngine() # Generate a list of 10 random numbers random_numbers_list = [get_random_number(quantum_engine) for _ in range(10)] From a6c2d90d5dd356b010a8b5db5ef4c39cdf063949 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 20 Oct 2022 11:49:54 +0200 Subject: [PATCH 21/23] Update quantum/quantum_random.py --- quantum/quantum_random.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index 3e0184d7a1e3..bd27a0dd0bf9 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -5,10 +5,10 @@ def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int: - # """ - # >>> isinstance(get_random_number(MainEngine()), int) - # True - # """ + """ + >>> isinstance(get_random_number(MainEngine()), int) + True + """ qubit = quantum_engine.allocate_qubit() H | qubit Measure | qubit From c0f07bd620528d478c6386796f2a0e86e5e4e7fc Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 20 Oct 2022 11:50:31 +0200 Subject: [PATCH 22/23] Update quantum/quantum_random.py --- quantum/quantum_random.py | 1 + 1 file changed, 1 insertion(+) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index bd27a0dd0bf9..7491c72bc3f8 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -23,6 +23,7 @@ def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int # 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() From 47224517328b87e71153b5f5c950ef93c04b9b41 Mon Sep 17 00:00:00 2001 From: Alan Paul <57307037+Alanzz@users.noreply.github.com> Date: Thu, 20 Oct 2022 15:36:07 +0530 Subject: [PATCH 23/23] Update quantum_random.py --- quantum/quantum_random.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/quantum_random.py b/quantum/quantum_random.py index 7491c72bc3f8..01c8faa12ac0 100644 --- a/quantum/quantum_random.py +++ b/quantum/quantum_random.py @@ -6,7 +6,7 @@ def get_random_number(quantum_engine: projectq.cengines._main.MainEngine) -> int: """ - >>> isinstance(get_random_number(MainEngine()), int) + >>> isinstance(get_random_number(projectq.MainEngine()), int) True """ qubit = quantum_engine.allocate_qubit()