|
15 | 15 | import numpy as np
|
16 | 16 | import pytest
|
17 | 17 | import sympy
|
18 |
| -from attrs import frozen |
19 | 18 |
|
20 |
| -from qualtran import Bloq, BloqBuilder, CtrlSpec, QInt, QUInt, Signature, Soquet, SoquetT |
| 19 | +from qualtran import BloqBuilder |
21 | 20 | from qualtran.bloqs.basic_gates import OneState
|
22 | 21 | from qualtran.bloqs.basic_gates.identity import _identity, _identity_n, _identity_symb, Identity
|
23 | 22 | from qualtran.simulation.classical_sim import (
|
24 | 23 | format_classical_truth_table,
|
25 | 24 | get_classical_truth_table,
|
26 | 25 | )
|
27 |
| -from qualtran.symbolics import SymbolicInt |
28 | 26 | from qualtran.testing import execute_notebook
|
29 | 27 |
|
30 | 28 |
|
@@ -95,42 +93,6 @@ def test_identity_controlled():
|
95 | 93 | assert Identity(n).controlled() == Identity(n + 1)
|
96 | 94 |
|
97 | 95 |
|
98 |
| -@frozen |
99 |
| -class TestIdentityDecomposition(Bloq): |
100 |
| - """helper to test Identity.get_ctrl_system""" |
101 |
| - |
102 |
| - bitsize: SymbolicInt |
103 |
| - |
104 |
| - @property |
105 |
| - def signature(self) -> 'Signature': |
106 |
| - return Signature.build(q=self.bitsize) |
107 |
| - |
108 |
| - def build_composite_bloq(self, bb: 'BloqBuilder', q: Soquet) -> dict[str, 'SoquetT']: |
109 |
| - q = bb.add(Identity(self.bitsize), q=q) |
110 |
| - q = bb.add(Identity(self.bitsize), q=q) |
111 |
| - return {'q': q} |
112 |
| - |
113 |
| - |
114 |
| -@pytest.mark.parametrize("n", [4, sympy.Symbol("n")]) |
115 |
| -@pytest.mark.parametrize( |
116 |
| - "ctrl_spec", |
117 |
| - [ |
118 |
| - CtrlSpec(cvs=(np.array([1, 0, 1]),)), |
119 |
| - CtrlSpec(qdtypes=(QUInt(3), QInt(3)), cvs=(np.array(0b010), np.array(0b001))), |
120 |
| - ], |
121 |
| -) |
122 |
| -def test_identity_get_ctrl_system(n: SymbolicInt, ctrl_spec: CtrlSpec): |
123 |
| - m = ctrl_spec.num_qubits |
124 |
| - |
125 |
| - bloq = TestIdentityDecomposition(n) |
126 |
| - ctrl_bloq = bloq.controlled(ctrl_spec) |
127 |
| - |
128 |
| - _ = ctrl_bloq.decompose_bloq() |
129 |
| - |
130 |
| - _, sigma = ctrl_bloq.call_graph() |
131 |
| - assert sigma == {Identity(n + m): 2} |
132 |
| - |
133 |
| - |
134 | 96 | @pytest.mark.notebook
|
135 | 97 | def test_notebook():
|
136 | 98 | execute_notebook('identity')
|
0 commit comments