13
13
# limitations under the License.
14
14
15
15
from dataclasses import dataclass
16
- from typing import (Callable , cast , List , Optional , Type , TypeVar , Union ,
16
+ from typing import (Callable , List , Optional , Type , TypeVar , Union ,
17
17
TYPE_CHECKING )
18
18
19
19
import numpy as np
20
20
21
- from cirq import devices , ops
21
+ from cirq import ops
22
22
from cirq .google .api import v2
23
23
from cirq .google import arg_func_langs
24
24
from cirq .google .arg_func_langs import _arg_to_proto
@@ -104,8 +104,6 @@ def to_proto(
104
104
) -> Optional [v2 .program_pb2 .Operation ]:
105
105
"""Returns the cirq.google.api.v2.Operation message as a proto dict."""
106
106
107
- if not all (isinstance (qubit , devices .GridQubit ) for qubit in op .qubits ):
108
- raise ValueError ('All qubits must be GridQubits' )
109
107
gate = op .gate
110
108
if not isinstance (gate , self .gate_type ):
111
109
raise ValueError (
@@ -120,8 +118,7 @@ def to_proto(
120
118
121
119
msg .gate .id = self .serialized_gate_id
122
120
for qubit in op .qubits :
123
- msg .qubits .add ().id = v2 .qubit_to_proto_id (
124
- cast (devices .GridQubit , qubit ))
121
+ msg .qubits .add ().id = v2 .qubit_to_proto_id (qubit )
125
122
for arg in self .args :
126
123
value = self ._value_from_gate (op , arg )
127
124
if value is not None :
0 commit comments