Skip to content

Commit

Permalink
Fix bug in TGate.as_cirq_op when is_adjoint=True (#826)
Browse files Browse the repository at this point in the history
* Fix bug in TGate.as_cirq_op when is_adjoint=True

* Fix pylint
  • Loading branch information
tanujkhattar authored Mar 26, 2024
1 parent 722ab05 commit d0d6bd1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion qualtran/bloqs/basic_gates/t_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def as_cirq_op(
import cirq

(q,) = q
return cirq.T(q), {'q': np.array([q])}
p = -1 if self.is_adjoint else 1
return cirq.T(q) ** p, {'q': np.array([q])}

def pretty_name(self) -> str:
maybe_dag = '†' if self.is_adjoint else ''
Expand Down
3 changes: 2 additions & 1 deletion qualtran/bloqs/basic_gates/t_gate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ def test_to_cirq():
bb = BloqBuilder()
q = bb.add(PlusState())
q = bb.add(TGate(), q=q)
q = bb.add(TGate(is_adjoint=True), q=q)
cbloq = bb.finalize(q=q)
circuit, _ = cbloq.to_cirq_circuit()
cirq.testing.assert_has_diagram(circuit, "_c(0): ───H───T───")
cirq.testing.assert_has_diagram(circuit, "_c(0): ───H───T───T^-1───")


def test_tensors():
Expand Down

0 comments on commit d0d6bd1

Please sign in to comment.