|
18 | 18 | import pytest |
19 | 19 |
|
20 | 20 | import qualtran.rotation_synthesis.math_config as mc |
| 21 | +import qualtran.rotation_synthesis.matrix as rsm |
21 | 22 | from qualtran.rotation_synthesis.matrix import su2_ct |
22 | 23 | from qualtran.rotation_synthesis.rings import zsqrt2, zw |
23 | 24 |
|
@@ -82,40 +83,21 @@ def test_t_gates(g, g_numpy): |
82 | 83 | ) |
83 | 84 |
|
84 | 85 |
|
85 | | -@pytest.mark.parametrize("g", _make_random_su(50, 5, random_cliffords=True, seed=0)) |
86 | | -def test_to_seq(g): |
87 | | - seq = g.to_sequence() |
88 | | - got = su2_ct.SU2CliffordT.from_sequence(seq) |
89 | | - assert got == g or got * -1 == g |
90 | | - |
91 | | - |
92 | 86 | def are_close_up_to_global_phase(u, v): |
93 | 87 | i, j = np.unravel_index( # pylint: disable=unbalanced-tuple-unpacking |
94 | 88 | np.abs(u).argmax(), u.shape |
95 | 89 | ) |
96 | 90 | return np.allclose(u * v[i, j] / u[i, j], v) |
97 | 91 |
|
98 | 92 |
|
99 | | -def test_generate_cliffords(): |
100 | | - cliffords = su2_ct.generate_cliffords() |
101 | | - cirq_cliffords = [ |
102 | | - cirq.unitary(c) for c in cirq.SingleQubitCliffordGate.all_single_qubit_cliffords |
103 | | - ] |
104 | | - assert np.allclose(np.abs([np.linalg.det(c.matrix.astype(complex)) for c in cliffords]), 2) |
105 | | - sqrt2 = np.sqrt(2) |
106 | | - for c in cliffords: |
107 | | - u = c.matrix.astype(complex) / sqrt2 |
108 | | - assert np.any([are_close_up_to_global_phase(u, c) for c in cirq_cliffords]) |
109 | | - |
110 | | - |
111 | 93 | @pytest.mark.parametrize("g", _make_random_su(50, 5, random_cliffords=True, seed=0)) |
112 | 94 | @pytest.mark.parametrize("config", [None, mc.NumpyConfig]) |
113 | 95 | def test_rescale(g: su2_ct.SU2CliffordT, config): |
114 | 96 | np.testing.assert_allclose(g.numpy(config), g.rescale().numpy(config)) |
115 | 97 |
|
116 | 98 |
|
117 | 99 | def test_num_t_gates(): |
118 | | - for clifford in su2_ct.generate_cliffords(): |
| 100 | + for clifford in rsm.generate_cliffords(): |
119 | 101 | assert clifford.num_t_gates() == 0 |
120 | 102 |
|
121 | 103 | for t in su2_ct.Ts: |
|
0 commit comments