Simplify cbloq.to_cirq_circuit()
with sensible defaults and add cbloq.to_cirq_circuit_and_quregs()
#927
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
More often than not, we construct a composite bloq corresponding to an algorithm / primitive in Qualtran and then wish to convert it to a cirq circuit. The
CompositeBloq.to_cirq_circuit
api is unnecessarily complex for this use case.This PR refactors the api s.t. the previous API for
CompositeBloq.to_cirq_circuit()
is now renamed toCompositeBloq.to_cirq_circuit_and_quregs()
and the newCompositeBloq.to_cirq_circuit()
simply returns acirq.FrozenCircuit
. It also doesn't need you to provide the inputquregs
and can use sensible defaults usingget_named_qubits(self.signature.lefts())
.Therefore, to get a cirq circuit from a composite bloq, users can now simply do
circuit = cbloq.to_cirq_circuit()
for a reasonable default and can provide the input quregs explicitly or callcbloq.to_cirq_circuit_and_quregs
for more advanced use cases.