diff --git a/cirq-core/cirq/ops/pauli_gates.py b/cirq-core/cirq/ops/pauli_gates.py index 85f3b881bca..4465697d2dc 100644 --- a/cirq-core/cirq/ops/pauli_gates.py +++ b/cirq-core/cirq/ops/pauli_gates.py @@ -108,7 +108,7 @@ def __init__(self): common_gates.XPowGate.__init__(self, exponent=1.0) def __pow__(self: '_PauliX', exponent: 'cirq.TParamVal') -> common_gates.XPowGate: - return common_gates.XPowGate(exponent=exponent) + return common_gates.XPowGate(exponent=exponent) if exponent != 1 else _PauliX() def _with_exponent(self: '_PauliX', exponent: 'cirq.TParamVal') -> common_gates.XPowGate: return self.__pow__(exponent) @@ -135,7 +135,7 @@ def __init__(self): common_gates.YPowGate.__init__(self, exponent=1.0) def __pow__(self: '_PauliY', exponent: 'cirq.TParamVal') -> common_gates.YPowGate: - return common_gates.YPowGate(exponent=exponent) + return common_gates.YPowGate(exponent=exponent) if exponent != 1 else _PauliY() def _with_exponent(self: '_PauliY', exponent: 'cirq.TParamVal') -> common_gates.YPowGate: return self.__pow__(exponent) @@ -162,7 +162,7 @@ def __init__(self): common_gates.ZPowGate.__init__(self, exponent=1.0) def __pow__(self: '_PauliZ', exponent: 'cirq.TParamVal') -> common_gates.ZPowGate: - return common_gates.ZPowGate(exponent=exponent) + return common_gates.ZPowGate(exponent=exponent) if exponent != 1 else _PauliZ() def _with_exponent(self: '_PauliZ', exponent: 'cirq.TParamVal') -> common_gates.ZPowGate: return self.__pow__(exponent) diff --git a/cirq-core/cirq/ops/pauli_gates_test.py b/cirq-core/cirq/ops/pauli_gates_test.py index b4e375f41e0..81753b5f019 100644 --- a/cirq-core/cirq/ops/pauli_gates_test.py +++ b/cirq-core/cirq/ops/pauli_gates_test.py @@ -216,3 +216,7 @@ def test_powers(): assert isinstance(cirq.X ** -0.5, cirq.XPowGate) assert isinstance(cirq.Y ** 0.2, cirq.YPowGate) assert isinstance(cirq.Z ** 0.5, cirq.ZPowGate) + + assert isinstance(cirq.X ** 1, cirq.Pauli) + assert isinstance(cirq.Y ** 1, cirq.Pauli) + assert isinstance(cirq.Z ** 1, cirq.Pauli)