Skip to content

Commit 21b9be3

Browse files
Flush v0.14.0 deprecation backlog. (#4601)
Removed `cirq.<vendor>` to `cirq_<vendor>` deprecations (This required some repr_inward changes as well as some renaming in `cirq_pasqal`). Removed `ParallelGateOperation`. Removed `cirq.Two/ThreeQubitGate`. We still have `cirq.testing.Two/ThreeQubitGate`. Removed `SupportsOnEachGate`. Removed `allow_decompose` parameter from `measurement_key_names` and `is_measurement`. Removed `kraus_to_channel_matrix`, `operation_to_channel_matrix`. Removed `asynchronous_pending` and `cirq-core/cirq/testing/asynchronous.py`. Removed `gate_set_name` in favor of `name` from `serializable_gate_set.py` @mpharrigan can you double check my changes on the json items. BREAKING CHANGE= some features of ParallelGateOperation aren't fully convertible. i.e. `cirq.num_qubits(old_op.gate) != cirq.num_qubits(new_op.gate)` and `isinstance(old_op, GateOperation) != isinstance(new_op, GateOperation)`
1 parent c7d420b commit 21b9be3

File tree

54 files changed

+102
-1369
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+102
-1369
lines changed

cirq-core/cirq/__init__.py

-40
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from cirq import (
2222
# Low level
2323
_version,
24-
_compat,
2524
_doc,
2625
type_workarounds,
2726
)
@@ -249,7 +248,6 @@
249248
ParallelGate,
250249
ParallelGateFamily,
251250
parallel_gate_op,
252-
ParallelGateOperation,
253251
Pauli,
254252
PAULI_GATE_LIKE,
255253
PAULI_STRING_LIKE,
@@ -301,12 +299,10 @@
301299
SwapPowGate,
302300
T,
303301
TaggedOperation,
304-
ThreeQubitGate,
305302
ThreeQubitDiagonalGate,
306303
TOFFOLI,
307304
transform_op_tree,
308305
TwoQubitDiagonalGate,
309-
TwoQubitGate,
310306
VirtualTag,
311307
wait,
312308
WaitGate,
@@ -369,11 +365,9 @@
369365
entanglement_fidelity,
370366
eye_tensor,
371367
fidelity,
372-
kraus_to_channel_matrix,
373368
kraus_to_choi,
374369
kraus_to_superoperator,
375370
one_hot,
376-
operation_to_channel_matrix,
377371
operation_to_choi,
378372
operation_to_superoperator,
379373
QUANTUM_STATE_LIKE,
@@ -621,40 +615,6 @@
621615
testing,
622616
)
623617

624-
_compat.deprecated_submodule(
625-
new_module_name='cirq_google',
626-
old_parent=__name__,
627-
old_child='google',
628-
deadline="v0.14",
629-
create_attribute=True,
630-
)
631-
632-
_compat.deprecated_submodule(
633-
new_module_name='cirq_aqt',
634-
old_parent=__name__,
635-
old_child='aqt',
636-
deadline="v0.14",
637-
create_attribute=True,
638-
)
639-
640-
641-
_compat.deprecated_submodule(
642-
new_module_name='cirq_ionq',
643-
old_parent=__name__,
644-
old_child='ionq',
645-
deadline="v0.14",
646-
create_attribute=True,
647-
)
648-
649-
_compat.deprecated_submodule(
650-
new_module_name='cirq_pasqal',
651-
old_parent=__name__,
652-
old_child='pasqal',
653-
deadline="v0.14",
654-
create_attribute=True,
655-
)
656-
657-
658618
# Registers cirq-core's public classes for JSON serialization.
659619
# pylint: disable=wrong-import-position
660620
from cirq.protocols.json_serialization import _register_resolver

cirq-core/cirq/json_resolver_cache.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ def two_qubit_matrix_gate(matrix):
4545
matrix = np.array(matrix, dtype=np.complex128)
4646
return cirq.MatrixGate(matrix, qid_shape=(2, 2))
4747

48+
def _parallel_gate_op(gate, qubits):
49+
return cirq.parallel_gate_op(gate, *qubits)
50+
4851
import sympy
4952

5053
return {
@@ -112,7 +115,7 @@ def two_qubit_matrix_gate(matrix):
112115
'_PauliY': cirq.ops.pauli_gates._PauliY,
113116
'_PauliZ': cirq.ops.pauli_gates._PauliZ,
114117
'ParamResolver': cirq.ParamResolver,
115-
'ParallelGateOperation': cirq.ParallelGateOperation,
118+
'ParallelGateOperation': _parallel_gate_op, # Removed in v0.14
116119
'ParallelGate': cirq.ParallelGate,
117120
'PauliMeasurementGate': cirq.PauliMeasurementGate,
118121
'PauliString': cirq.PauliString,

cirq-core/cirq/neutral_atoms/neutral_atom_devices.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def duration_of(self, operation: ops.Operation):
139139
gate
140140
"""
141141
self.validate_operation(operation)
142-
if isinstance(operation, (ops.GateOperation, ops.ParallelGateOperation)):
142+
if isinstance(operation, ops.GateOperation):
143143
if isinstance(operation.gate, ops.MeasurementGate):
144144
return self._measurement_duration
145145
return self._gate_duration
@@ -167,7 +167,7 @@ def validate_operation(self, operation: ops.Operation):
167167
Raises:
168168
ValueError: If the operation is not valid
169169
"""
170-
if not isinstance(operation, (ops.GateOperation, ops.ParallelGateOperation)):
170+
if not isinstance(operation, ops.GateOperation):
171171
raise ValueError(f'Unsupported operation: {operation!r}')
172172

173173
# All qubits the operation acts on must be on the device
@@ -219,7 +219,7 @@ def validate_moment(self, moment: ops.Moment):
219219

220220
categorized_ops: DefaultDict = collections.defaultdict(list)
221221
for op in moment.operations:
222-
assert isinstance(op, (ops.GateOperation, ops.ParallelGateOperation))
222+
assert isinstance(op, ops.GateOperation)
223223
for k, v in CATEGORIES.items():
224224
assert isinstance(v, tuple)
225225
gate = _subgate_if_parallel_gate(op.gate)

cirq-core/cirq/ops/__init__.py

-6
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@
108108
from cirq.ops.gate_features import (
109109
InterchangeableQubitsGate,
110110
SingleQubitGate,
111-
ThreeQubitGate,
112-
TwoQubitGate,
113111
)
114112

115113
from cirq.ops.gate_operation import (
@@ -154,10 +152,6 @@
154152

155153
from cirq.ops.parallel_gate import ParallelGate, parallel_gate_op
156154

157-
from cirq.ops.parallel_gate_operation import (
158-
ParallelGateOperation,
159-
)
160-
161155
from cirq.ops.projector import (
162156
ProjectorString,
163157
)

cirq-core/cirq/ops/gate_features.py

-53
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
"""
1919

2020
import abc
21-
import warnings
2221

23-
from cirq import value, ops
24-
from cirq._compat import deprecated_class
2522
from cirq.ops import raw_types
2623

2724

@@ -33,58 +30,8 @@ def qubit_index_to_equivalence_group_key(self, index: int) -> int:
3330
return 0
3431

3532

36-
class _SupportsOnEachGateMeta(value.ABCMetaImplementAnyOneOf):
37-
def __instancecheck__(cls, instance):
38-
return isinstance(instance, (SingleQubitGate, ops.DepolarizingChannel)) or issubclass(
39-
type(instance), SupportsOnEachGate
40-
)
41-
42-
43-
@deprecated_class(
44-
deadline='v0.14',
45-
fix='Remove `SupportsOnEachGate` from the list of parent classes. '
46-
'`on_each` is now directly supported in the `Gate` base class.',
47-
)
48-
class SupportsOnEachGate(raw_types.Gate, metaclass=_SupportsOnEachGateMeta):
49-
pass
50-
51-
5233
class SingleQubitGate(raw_types.Gate, metaclass=abc.ABCMeta):
5334
"""A gate that must be applied to exactly one qubit."""
5435

5536
def _num_qubits_(self) -> int:
5637
return 1
57-
58-
59-
class _TwoQubitGateMeta(value.ABCMetaImplementAnyOneOf):
60-
def __instancecheck__(cls, instance):
61-
warnings.warn(
62-
'isinstance(gate, TwoQubitGate) is deprecated. Use cirq.num_qubits(gate) == 2 instead',
63-
DeprecationWarning,
64-
)
65-
return isinstance(instance, raw_types.Gate) and instance._num_qubits_() == 2
66-
67-
68-
@deprecated_class(deadline='v0.14', fix='Define _num_qubits_ manually.')
69-
class TwoQubitGate(raw_types.Gate, metaclass=_TwoQubitGateMeta):
70-
"""A gate that must be applied to exactly two qubits."""
71-
72-
def _num_qubits_(self) -> int:
73-
return 2
74-
75-
76-
class _ThreeQubitGateMeta(value.ABCMetaImplementAnyOneOf):
77-
def __instancecheck__(cls, instance):
78-
warnings.warn(
79-
'isinstance(gate, TwoQubitGate) is deprecated. Use cirq.num_qubits(gate) == 3 instead',
80-
DeprecationWarning,
81-
)
82-
return isinstance(instance, raw_types.Gate) and instance._num_qubits_() == 3
83-
84-
85-
@deprecated_class(deadline='v0.14', fix='Define _num_qubits_ manually.')
86-
class ThreeQubitGate(raw_types.Gate, metaclass=_ThreeQubitGateMeta):
87-
"""A gate that must be applied to exactly three qubits."""
88-
89-
def _num_qubits_(self) -> int:
90-
return 3

0 commit comments

Comments
 (0)