Skip to content

Commit

Permalink
types
Browse files Browse the repository at this point in the history
  • Loading branch information
eliottrosenberg committed Mar 2, 2025
1 parent f232b9e commit cc79604
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions cirq-core/cirq/transformers/gauge_compiling/cphase_gauge.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CPhasePauliGauge(Gauge):
def weight(self) -> float:
return 1.0

def _get_new_post(self, exponent: float, pre: 'cirq.Gate') -> 'cirq.Gate':
def _get_new_post(self, exponent: float, pre: ops.Gate) -> ops.Gate:
"""Identify the new single-qubit gate that needs to be inserted in the case that both pre
gates are X or Y.
Expand All @@ -57,7 +57,7 @@ def _get_new_post(self, exponent: float, pre: 'cirq.Gate') -> 'cirq.Gate':
raise ValueError("pre should be cirq.X or cirq.Y")

def _get_constant_gauge(
self, gate: ops.CZPowGate, pre_q0: 'cirq.Gate', pre_q1: 'cirq.Gate'
self, gate: ops.CZPowGate, pre_q0: ops.Gate, pre_q1: ops.Gate
) -> ConstantGauge:
"""Get the ConstantGauge corresponding to a given pre_q0 and pre_q1.
Expand Down Expand Up @@ -111,7 +111,7 @@ def _get_constant_gauge(
else:
raise ValueError("pre_q0 and pre_q1 should be single-qubit Pauli operators")

def sample(self, gate: ops.CZPowGate, prng: np.random.Generator) -> ConstantGauge:
def sample(self, gate: ops.Gate, prng: np.random.Generator) -> ConstantGauge:
"""Sample the 16 cphase gauges at random.
Args:
Expand All @@ -122,7 +122,7 @@ def sample(self, gate: ops.CZPowGate, prng: np.random.Generator) -> ConstantGaug
A ConstantGauge implementing the transformation.
"""

pre_q0, pre_q1 = prng.choice([ops.I, ops.X, ops.Y, ops.Z], size=2, replace=True)
pre_q0, pre_q1 = prng.choice(np.array([ops.I, ops.X, ops.Y, ops.Z]), size=2, replace=True)
return self._get_constant_gauge(gate, pre_q0, pre_q1)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

import cirq
from cirq.transformers.gauge_compiling import CPhaseGaugeTransformer
from cirq.transformers.gauge_compiling.cphase_gauge import CPhaseGaugeTransformer
from cirq.transformers.gauge_compiling.gauge_compiling_test_utils import GaugeTester


Expand Down

0 comments on commit cc79604

Please sign in to comment.