11
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
- import re
15
14
from typing import Any , Callable , Dict , Generic , Iterator , TypeVar , cast , TYPE_CHECKING
16
15
17
16
import functools
18
17
import networkx
19
18
20
- from cirq import _compat , ops , devices
19
+ from cirq import ops
21
20
from cirq .circuits import circuit
22
21
23
22
if TYPE_CHECKING :
@@ -70,17 +69,10 @@ class CircuitDag(networkx.DiGraph):
70
69
71
70
disjoint_qubits = staticmethod (_disjoint_qubits )
72
71
73
- @_compat .deprecated_parameter (
74
- deadline = 'v0.15' ,
75
- fix = circuit ._DEVICE_DEP_MESSAGE ,
76
- parameter_desc = 'device' ,
77
- match = lambda args , kwargs : 'device' in kwargs or len (args ) == 4 ,
78
- )
79
72
def __init__ (
80
73
self ,
81
74
can_reorder : Callable [['cirq.Operation' , 'cirq.Operation' ], bool ] = _disjoint_qubits ,
82
75
incoming_graph_data : Any = None ,
83
- device : 'cirq.Device' = devices .UNCONSTRAINED_DEVICE ,
84
76
) -> None :
85
77
"""Initializes a CircuitDag.
86
78
@@ -98,15 +90,6 @@ def __init__(
98
90
"""
99
91
super ().__init__ (incoming_graph_data )
100
92
self .can_reorder = can_reorder
101
- self ._device = device
102
-
103
- @property # type: ignore
104
- @_compat .deprecated (
105
- deadline = 'v0.15' ,
106
- fix = circuit ._DEVICE_DEP_MESSAGE ,
107
- )
108
- def device (self ) -> devices .Device :
109
- return self ._device
110
93
111
94
@staticmethod
112
95
def make_node (op : 'cirq.Operation' ) -> Unique :
@@ -117,30 +100,14 @@ def from_circuit(
117
100
circuit : circuit .Circuit ,
118
101
can_reorder : Callable [['cirq.Operation' , 'cirq.Operation' ], bool ] = _disjoint_qubits ,
119
102
) -> 'CircuitDag' :
120
- if circuit ._device == devices .UNCONSTRAINED_DEVICE :
121
- return CircuitDag .from_ops (circuit .all_operations (), can_reorder = can_reorder )
122
- return CircuitDag .from_ops (
123
- circuit .all_operations (), can_reorder = can_reorder , device = circuit ._device
124
- )
103
+ return CircuitDag .from_ops (circuit .all_operations (), can_reorder = can_reorder )
125
104
126
105
@staticmethod
127
- @_compat .deprecated_parameter (
128
- deadline = 'v0.15' ,
129
- fix = circuit ._DEVICE_DEP_MESSAGE ,
130
- parameter_desc = 'device' ,
131
- match = lambda args , kwargs : 'device' in kwargs ,
132
- )
133
106
def from_ops (
134
107
* operations : 'cirq.OP_TREE' ,
135
108
can_reorder : Callable [['cirq.Operation' , 'cirq.Operation' ], bool ] = _disjoint_qubits ,
136
- device : 'cirq.Device' = devices .UNCONSTRAINED_DEVICE ,
137
109
) -> 'CircuitDag' :
138
- if device == devices .UNCONSTRAINED_DEVICE :
139
- dag = CircuitDag (can_reorder = can_reorder )
140
- else :
141
- with _compat .block_overlapping_deprecation (re .escape (circuit ._DEVICE_DEP_MESSAGE )):
142
- dag = CircuitDag (can_reorder = can_reorder , device = device )
143
-
110
+ dag = CircuitDag (can_reorder = can_reorder )
144
111
for op in ops .flatten_op_tree (operations ):
145
112
dag .append (cast (ops .Operation , op ))
146
113
return dag
@@ -212,11 +179,7 @@ def all_qubits(self):
212
179
return frozenset (q for node in self .nodes for q in node .val .qubits )
213
180
214
181
def to_circuit (self ) -> circuit .Circuit :
215
- if self ._device == devices .UNCONSTRAINED_DEVICE :
216
- return circuit .Circuit (self .all_operations (), strategy = circuit .InsertStrategy .EARLIEST )
217
- return circuit .Circuit (
218
- self .all_operations (), strategy = circuit .InsertStrategy .EARLIEST , device = self ._device
219
- )
182
+ return circuit .Circuit (self .all_operations (), strategy = circuit .InsertStrategy .EARLIEST )
220
183
221
184
def findall_nodes_until_blocked (
222
185
self , is_blocker : Callable [['cirq.Operation' ], bool ]
0 commit comments