|
17 | 17 | import abc |
18 | 18 | from collections import defaultdict |
19 | 19 |
|
20 | | -from cirq import circuits, devices, ops, protocols, transformers, _compat |
| 20 | +from cirq import circuits, devices, ops, protocols, transformers |
21 | 21 |
|
22 | 22 | from cirq.contrib.acquaintance.gates import AcquaintanceOpportunityGate |
23 | 23 | from cirq.contrib.acquaintance.permutation import ( |
|
34 | 34 |
|
35 | 35 |
|
36 | 36 | class ExecutionStrategy(metaclass=abc.ABCMeta): |
37 | | - """Tells StrategyExecutor how to execute an acquaintance strategy. |
| 37 | + """Tells `StrategyExecutorTransormer` how to execute an acquaintance strategy. |
38 | 38 |
|
39 | | - An execution strategy tells StrategyExecutor how to execute an |
40 | | - acquaintance strategy, i.e. what gates to implement at the available |
| 39 | + An execution strategy tells `StrategyExecutorTransformer` how to execute |
| 40 | + an acquaintance strategy, i.e. what gates to implement at the available |
41 | 41 | acquaintance opportunities.""" |
42 | 42 |
|
43 | 43 | keep_acquaintance = False |
@@ -78,45 +78,6 @@ def __call__(self, *args, **kwargs): |
78 | 78 | return strategy.mapping |
79 | 79 |
|
80 | 80 |
|
81 | | -@_compat.deprecated_class( |
82 | | - deadline='v1.0', fix='Use cirq.contrib.acquaintance.StrategyExecutorTransformer' |
83 | | -) |
84 | | -class StrategyExecutor(circuits.PointOptimizer): |
85 | | - """Executes an acquaintance strategy.""" |
86 | | - |
87 | | - def __init__(self, execution_strategy: ExecutionStrategy) -> None: |
88 | | - super().__init__() |
89 | | - self.execution_strategy = execution_strategy |
90 | | - self.mapping = execution_strategy.initial_mapping.copy() |
91 | | - |
92 | | - def __call__(self, strategy: 'cirq.Circuit'): |
93 | | - expose_acquaintance_gates(strategy) |
94 | | - super().optimize_circuit(strategy) |
95 | | - return self.mapping.copy() |
96 | | - |
97 | | - def optimization_at( |
98 | | - self, circuit: 'cirq.Circuit', index: int, op: 'cirq.Operation' |
99 | | - ) -> Optional['cirq.PointOptimizationSummary']: |
100 | | - if isinstance(op.gate, AcquaintanceOpportunityGate): |
101 | | - logical_indices = tuple(self.mapping[q] for q in op.qubits) |
102 | | - logical_operations = self.execution_strategy.get_operations(logical_indices, op.qubits) |
103 | | - clear_span = int(not self.execution_strategy.keep_acquaintance) |
104 | | - |
105 | | - return circuits.PointOptimizationSummary( |
106 | | - clear_span=clear_span, clear_qubits=op.qubits, new_operations=logical_operations |
107 | | - ) |
108 | | - |
109 | | - if isinstance(op, ops.GateOperation) and isinstance(op.gate, PermutationGate): |
110 | | - op.gate.update_mapping(self.mapping, op.qubits) |
111 | | - return None |
112 | | - |
113 | | - raise TypeError( |
114 | | - 'Can only execute a strategy consisting of gates that ' |
115 | | - 'are instances of AcquaintanceOpportunityGate or ' |
116 | | - 'PermutationGate.' |
117 | | - ) |
118 | | - |
119 | | - |
120 | 81 | @transformers.transformer |
121 | 82 | class StrategyExecutorTransformer: |
122 | 83 | """Executes an acquaintance strategy.""" |
|
0 commit comments