4545 Side ,
4646 Signature ,
4747)
48- from qualtran .bloqs .basic_gates import TGate , XGate
49- from qualtran .bloqs .bookkeeping import ArbitraryClifford
48+ from qualtran .bloqs .basic_gates import XGate
5049from qualtran .cirq_interop import decompose_from_cirq_style_method
5150from qualtran .drawing import Circle , directional_text_box , Text , WireSymbol
52- from qualtran .resource_counting import (
53- big_O ,
54- BloqCountDictT ,
55- MutableBloqCountDictT ,
56- SympySymbolAllocator ,
57- )
58- from qualtran .resource_counting .generalizers import (
59- cirq_to_bloqs ,
60- generalize_cvs ,
61- generalize_rotation_angle ,
62- ignore_alloc_free ,
63- ignore_cliffords ,
64- )
51+ from qualtran .resource_counting import BloqCountDictT , MutableBloqCountDictT , SympySymbolAllocator
52+ from qualtran .resource_counting .generalizers import generalize_cvs , ignore_cliffords
6553from qualtran .simulation .classical_sim import ClassicalValT
6654from qualtran .symbolics import HasLength , is_symbolic , SymbolicInt
6755
6856if TYPE_CHECKING :
6957 import quimb .tensor as qtn
7058
71- # TODO: https://github.com/quantumlib/Qualtran/issues/1346
72- FLAG_AND_AS_LEAF = False
73-
7459
7560@frozen
7661class And (GateWithRegisters ):
@@ -108,22 +93,7 @@ def adjoint(self) -> 'And':
10893 return attrs .evolve (self , uncompute = not self .uncompute )
10994
11095 def decompose_bloq (self ) -> 'CompositeBloq' :
111- if FLAG_AND_AS_LEAF :
112- raise DecomposeTypeError (f"{ self } is atomic." )
113- return decompose_from_cirq_style_method (self )
114-
115- def build_call_graph (self , ssa : 'SympySymbolAllocator' ) -> 'BloqCountDictT' :
116- if FLAG_AND_AS_LEAF :
117- raise DecomposeTypeError (f"{ self } is atomic." )
118-
119- if isinstance (self .cv1 , sympy .Expr ) or isinstance (self .cv2 , sympy .Expr ):
120- pre_post_cliffords : Union [sympy .Order , int ] = big_O (1 )
121- else :
122- pre_post_cliffords = 2 - self .cv1 - self .cv2
123- if self .uncompute :
124- return {ArbitraryClifford (n = 2 ): 4 + 2 * pre_post_cliffords }
125-
126- return {ArbitraryClifford (n = 2 ): 9 + 2 * pre_post_cliffords , TGate (): 4 }
96+ raise DecomposeTypeError (f"{ self } is atomic." )
12797
12898 def on_classical_vals (
12999 self , * , ctrl : NDArray [np .uint8 ], target : Optional [int ] = None
@@ -243,13 +213,6 @@ def to_clifford_t_circuit(self) -> 'cirq.FrozenCircuit':
243213 circuit += pre_post_ops
244214 return circuit .freeze ()
245215
246- def __pow__ (self , power : int ) -> 'And' :
247- if power == 1 :
248- return self
249- if power == - 1 :
250- return self .adjoint ()
251- return NotImplemented # pragma: no cover
252-
253216 def _circuit_diagram_info_ (self , args : cirq .CircuitDiagramInfoArgs ) -> cirq .CircuitDiagramInfo :
254217 controls = ["(0)" , "@" ]
255218 target = "And†" if self .uncompute else "And"
@@ -263,9 +226,7 @@ def _has_unitary_(self) -> bool:
263226 return not self .uncompute
264227
265228
266- @bloq_example (
267- generalizer = [cirq_to_bloqs , ignore_cliffords , ignore_alloc_free , generalize_rotation_angle ]
268- )
229+ @bloq_example ()
269230def _and_bloq () -> And :
270231 and_bloq = And ()
271232 return and_bloq
0 commit comments