4949 import cirq
5050
5151 from qualtran .cirq_interop ._cirq_to_bloq import CirqQuregInT , CirqQuregT
52- from qualtran .cirq_interop .t_complexity_protocol import TComplexity
5352 from qualtran .resource_counting import BloqCountT , SympySymbolAllocator
5453 from qualtran .simulation .classical_sim import ClassicalValT
5554
@@ -139,16 +138,19 @@ def as_cirq_op(
139138 """Return a cirq.CircuitOperation containing a cirq-exported version of this cbloq."""
140139 import cirq
141140
142- circuit , out_quregs = self .to_cirq_circuit (qubit_manager = qubit_manager , ** cirq_quregs )
141+ circuit , out_quregs = self .to_cirq_circuit_and_quregs (
142+ qubit_manager = qubit_manager , cirq_quregs = cirq_quregs
143+ )
143144 return cirq .CircuitOperation (circuit ), out_quregs
144145
145- def to_cirq_circuit (
146- self , qubit_manager : Optional ['cirq.QubitManager' ] = None , ** cirq_quregs : 'CirqQuregInT'
146+ def to_cirq_circuit_and_quregs (
147+ self , qubit_manager : Optional ['cirq.QubitManager' ] = None , ** cirq_quregs
147148 ) -> Tuple ['cirq.FrozenCircuit' , Dict [str , 'CirqQuregT' ]]:
148- """Convert this CompositeBloq to a `cirq.Circuit`.
149+ """Convert this CompositeBloq to a `cirq.Circuit` and output qubit registers .
149150
150151 Args:
151- qubit_manager: A `cirq.QubitManager` to allocate new qubits.
152+ qubit_manager: A `cirq.QubitManager` to allocate new qubits. If not provided,
153+ uses `cirq.SimpleQubitManager()` by default.
152154 **cirq_quregs: Mapping from left register names to Cirq qubit arrays.
153155
154156 Returns:
@@ -166,6 +168,30 @@ def to_cirq_circuit(
166168 self .signature , cirq_quregs , self ._binst_graph , qubit_manager = qubit_manager
167169 )
168170
171+ def to_cirq_circuit (
172+ self ,
173+ * ,
174+ qubit_manager : Optional ['cirq.QubitManager' ] = None ,
175+ cirq_quregs : Optional [Mapping [str , 'CirqQuregInT' ]] = None ,
176+ ) -> 'cirq.FrozenCircuit' :
177+ """Convert this CompositeBloq to a `cirq.Circuit`.
178+
179+ Args:
180+ qubit_manager: A `cirq.QubitManager` to allocate new qubits. If not provided,
181+ uses `cirq.SimpleQubitManager()` by default.
182+ cirq_quregs: Mapping from left register names to Cirq qubit arrays. If not provided,
183+ uses `get_named_qubits(self.signature.lefts())` by default.
184+
185+ Returns:
186+ circuit: The cirq.FrozenCircuit version of this composite bloq.
187+ """
188+ from qualtran ._infra .gate_with_registers import get_named_qubits
189+
190+ if cirq_quregs is None :
191+ cirq_quregs = get_named_qubits (self .signature .lefts ())
192+
193+ return self .to_cirq_circuit_and_quregs (qubit_manager = qubit_manager , ** cirq_quregs )[0 ]
194+
169195 @classmethod
170196 def from_cirq_circuit (cls , circuit : 'cirq.Circuit' ) -> 'CompositeBloq' :
171197 """Construct a composite bloq from a Cirq circuit.
0 commit comments