Skip to content

Commit 4837660

Browse files
committed
Fixed more mypy errors
1 parent 34c3fe8 commit 4837660

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

cirq-google/cirq_google/devices/grid_device.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ def __post_init__(self):
134134

135135

136136
def _in_or_equals(g: GateOrFamily, gate_family: cirq.GateFamily):
137-
return (isinstance(g, cirq.GateFamily) and g == gate_family) or g in gate_family
137+
if isinstance(g, cirq.GateFamily):
138+
return g == gate_family
139+
elif isinstance(g, cirq.Gate):
140+
return g in gate_family
141+
else: # Gate type
142+
return cirq.GateFamily(g) == gate_family
138143

139144

140145
def _validate_device_specification(proto: v2.device_pb2.DeviceSpecification) -> None:
@@ -469,8 +474,10 @@ def to_proto(
469474
DeviceSpecification.
470475
"""
471476
qubits = self._metadata.qubit_set
472-
pairs: List[Tuple[cirq.GridQubit, cirq.GridQubit]] = [
473-
tuple(sorted(pair)) for pair in self._metadata.qubit_pairs
477+
unordered_pairs = [tuple(pair_set) for pair_set in self._metadata.qubit_pairs]
478+
pairs = [
479+
(pair[0], pair[1]) if pair[0] <= pair[1] else (pair[1], pair[0])
480+
for pair in unordered_pairs
474481
]
475482
gateset = self._metadata.gateset
476483
gate_durations = self._metadata.gate_durations

0 commit comments

Comments
 (0)