From 82889436bb1c0eb3a55e629815b4e5c84f62daff Mon Sep 17 00:00:00 2001 From: Daniel Tsvetkov Date: Fri, 27 Mar 2020 20:13:12 +0100 Subject: [PATCH] better ordered formatting of results --- 10_krisi_3qubits_game.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/10_krisi_3qubits_game.py b/10_krisi_3qubits_game.py index c9fbf7f..03b48ad 100644 --- a/10_krisi_3qubits_game.py +++ b/10_krisi_3qubits_game.py @@ -57,12 +57,16 @@ def test_krisi_measurement_2(): def test_krisi_measurement_3(): + iterations = 400 + beta = np.pi * 0.62 + CASE_ID_ID = "id_id" CASE_ID_ORT = "id_ort" CASE_ORT_ID = "ort_id" CASE_ORT_ORT = "ort_ort" - beta = 0 + case_choices = [CASE_ID_ID, CASE_ID_ORT, CASE_ORT_ID, CASE_ORT_ORT] + b_0 = State(1 / np.sqrt(2) * (s("|100>") - s("|010>"))) b_1 = State(1 / np.sqrt(2) * (s("|011>") - s("|101>"))) basis = [ @@ -112,7 +116,8 @@ def test_krisi_measurement_3(): def krisi_3_format_results(results): all_pos = generate_bins(8) print("Results:") - for case, rv in results.items(): + for case in case_choices: + rv = results.get(case) print("{}:".format(case)) print(" raw : {}".format(sorted(rv.items()))) case_total = sum(rv.values()) @@ -123,8 +128,8 @@ def test_krisi_measurement_3(): print(" {} : {:3d} ({:.2f}%)".format(pos, value, percent)) results = defaultdict(lambda: defaultdict(int)) - for i in range(1000): - case = random.choice([CASE_ID_ID, CASE_ID_ORT, CASE_ORT_ID, CASE_ORT_ORT]) + for i in range(iterations): + case = random.choice(case_choices) result = perform_exp(case=case) results[case][result] += 1