Skip to content

Commit

Permalink
Return default None for gates that do not have a diagram info from Ci…
Browse files Browse the repository at this point in the history
…rqGateAsBloq (#880)
  • Loading branch information
tanujkhattar authored Apr 24, 2024
1 parent 0ea00a7 commit 7471fbd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion qualtran/cirq_interop/_cirq_to_bloq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion qualtran/cirq_interop/_cirq_to_bloq_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 7471fbd

Please sign in to comment.