Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions cirq-core/cirq/ops/pauli_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from typing import Any, cast, Tuple, TYPE_CHECKING, Union, Dict

from cirq._doc import document
from cirq._import import LazyLoader
from cirq.ops import common_gates, raw_types, identity
from cirq.type_workarounds import NotImplementedType

Expand All @@ -29,6 +30,9 @@
) # pragma: no cover


pauli_string = LazyLoader("pauli_string", globals(), "cirq.ops.pauli_string")


class Pauli(raw_types.Gate, metaclass=abc.ABCMeta):
"""Represents the Pauli gates.

Expand Down Expand Up @@ -97,9 +101,8 @@ def on(self, *qubits: 'cirq.Qid') -> 'SingleQubitPauliStringGateOperation':
"""
if len(qubits) != 1:
raise ValueError(f'Expected a single qubit, got <{qubits!r}>.')
from cirq.ops.pauli_string import SingleQubitPauliStringGateOperation

return SingleQubitPauliStringGateOperation(self, qubits[0])
return pauli_string.SingleQubitPauliStringGateOperation(self, qubits[0])

@property
def _canonical_exponent(self):
Expand Down
4 changes: 2 additions & 2 deletions cirq-core/cirq/ops/pauli_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import sympy

import cirq
from cirq import value, protocols, linalg, qis
from cirq import value, protocols, linalg, qis, _compat
from cirq._doc import document
from cirq._import import LazyLoader
from cirq.ops import (
Expand Down Expand Up @@ -184,7 +184,7 @@ def __init__(
Raises:
TypeError: If the `qubit_pauli_map` has values that are not Paulis.
"""
if qubit_pauli_map is not None:
if _compat.__cirq_debug__.get() and qubit_pauli_map is not None:
for v in qubit_pauli_map.values():
if not isinstance(v, pauli_gates.Pauli):
raise TypeError(f'{v} is not a Pauli')
Expand Down