From 7471fbdc2f2c6bba637f8d41be29490f3be7045e Mon Sep 17 00:00:00 2001 From: Tanuj Khattar Date: Wed, 24 Apr 2024 00:11:07 -0700 Subject: [PATCH] Return default None for gates that do not have a diagram info from CirqGateAsBloq (#880) --- qualtran/cirq_interop/_cirq_to_bloq.py | 2 +- qualtran/cirq_interop/_cirq_to_bloq_test.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/qualtran/cirq_interop/_cirq_to_bloq.py b/qualtran/cirq_interop/_cirq_to_bloq.py index 3bb182a77..58a284c1a 100644 --- a/qualtran/cirq_interop/_cirq_to_bloq.py +++ b/qualtran/cirq_interop/_cirq_to_bloq.py @@ -132,7 +132,7 @@ def _unitary_(self): return cirq.unitary(self.cirq_gate, default=None) def _circuit_diagram_info_(self, args: cirq.CircuitDiagramInfoArgs) -> cirq.CircuitDiagramInfo: - return cirq.circuit_diagram_info(self.cirq_gate) + return cirq.circuit_diagram_info(self.cirq_gate, default=None) def __str__(self): return str(self.cirq_gate) diff --git a/qualtran/cirq_interop/_cirq_to_bloq_test.py b/qualtran/cirq_interop/_cirq_to_bloq_test.py index 3c4e871bf..c2e69ed7f 100644 --- a/qualtran/cirq_interop/_cirq_to_bloq_test.py +++ b/qualtran/cirq_interop/_cirq_to_bloq_test.py @@ -32,7 +32,7 @@ Signature, ) from qualtran._infra.gate_with_registers import get_named_qubits -from qualtran.bloqs.basic_gates import CNOT, OneState +from qualtran.bloqs.basic_gates import CNOT, GlobalPhase, OneState from qualtran.bloqs.mcmt.and_bloq import And from qualtran.bloqs.util_bloqs import Allocate, Free, Join, Split from qualtran.cirq_interop import cirq_optree_to_cbloq, CirqGateAsBloq, CirqQuregT @@ -224,3 +224,7 @@ def test_cirq_gate_as_bloq_decompose_raises(): bloq = CirqGateAsBloq(cirq.X) with pytest.raises(DecomposeNotImplementedError, match="does not declare a decomposition"): _ = bloq.decompose_bloq() + + +def test_cirq_gate_as_bloq_diagram_info(): + assert cirq.circuit_diagram_info(GlobalPhase(1j)) is None