| @@ -6,6 +6,7 @@ from tqdm import tqdm | |||||
| import random | import random | ||||
| import itertools as it | import itertools as it | ||||
| def test_single_qubit_measurements(): | def test_single_qubit_measurements(): | ||||
| """ Various simple tests of measurements """ | """ Various simple tests of measurements """ | ||||
| @@ -26,6 +27,7 @@ def test_single_qubit_measurements(): | |||||
| g.act_local_rotation(0, "pz") | g.act_local_rotation(0, "pz") | ||||
| assert g.measure(0, "px") == 1, "Measuring |-> in X gives 1" | assert g.measure(0, "px") == 1, "Measuring |-> in X gives 1" | ||||
| def test_type(): | def test_type(): | ||||
| """ Test that the output is always an int """ | """ Test that the output is always an int """ | ||||
| for r, m, f in it.product(range(24), ("px", "py", "pz"), (0, 1)): | for r, m, f in it.product(range(24), ("px", "py", "pz"), (0, 1)): | ||||
| @@ -36,7 +38,6 @@ def test_type(): | |||||
| assert g.measure(0, m, f, detail=True)["determinate"] == True | assert g.measure(0, m, f, detail=True)["determinate"] == True | ||||
| def test_random_outcomes(): | def test_random_outcomes(): | ||||
| """ Testing random behaviour """ | """ Testing random behaviour """ | ||||
| ones = 0 | ones = 0 | ||||
| @@ -46,6 +47,7 @@ def test_random_outcomes(): | |||||
| ones += g.measure(0, "pz") | ones += g.measure(0, "pz") | ||||
| assert 400 < ones < 600, "This is a probabilistic test!" | assert 400 < ones < 600, "This is a probabilistic test!" | ||||
| def test_projection(): | def test_projection(): | ||||
| """ Test that projection works correctly """ | """ Test that projection works correctly """ | ||||
| g = GraphState([0]) | g = GraphState([0]) | ||||
| @@ -58,5 +60,3 @@ def test_projection(): | |||||
| g.act_local_rotation(0, "hadamard") | g.act_local_rotation(0, "hadamard") | ||||
| g.measure(0, "pz", 1) | g.measure(0, "pz", 1) | ||||
| assert np.allclose(g.to_state_vector().state, qi.one) | assert np.allclose(g.to_state_vector().state, qi.one) | ||||