From 2657c53b8a046a4e064ebd26dd154a8521326a4b Mon Sep 17 00:00:00 2001 From: Dax Fohl Date: Thu, 7 Jul 2022 13:05:28 -0400 Subject: [PATCH] Remove key protocol frozenset conversion (#5660) Co-authored-by: Cirq Bot --- cirq-core/cirq/protocols/act_on_protocol.py | 15 +-------------- cirq-core/cirq/protocols/act_on_protocol_test.py | 6 ------ cirq-core/cirq/protocols/control_key_protocol.py | 7 ------- .../cirq/protocols/control_key_protocol_test.py | 9 --------- .../cirq/protocols/measurement_key_protocol.py | 14 +------------- .../protocols/measurement_key_protocol_test.py | 15 --------------- 6 files changed, 2 insertions(+), 64 deletions(-) diff --git a/cirq-core/cirq/protocols/act_on_protocol.py b/cirq-core/cirq/protocols/act_on_protocol.py index c250a2351dc..703396c92c2 100644 --- a/cirq-core/cirq/protocols/act_on_protocol.py +++ b/cirq-core/cirq/protocols/act_on_protocol.py @@ -16,7 +16,7 @@ from typing_extensions import Protocol -from cirq import _compat, ops +from cirq import ops from cirq._doc import doc_private from cirq.type_workarounds import NotImplementedType @@ -86,19 +86,6 @@ def _act_on_( """ -def _fix_deprecated_args(args, kwargs): - kwargs['sim_state'] = kwargs['args'] - del kwargs['args'] - return args, kwargs - - -@_compat.deprecated_parameter( - deadline='v0.16', - fix='Change argument name to `sim_state`', - parameter_desc='args', - match=lambda args, kwargs: 'args' in kwargs, - rewrite=_fix_deprecated_args, -) def act_on( action: Any, sim_state: 'cirq.SimulationStateBase', diff --git a/cirq-core/cirq/protocols/act_on_protocol_test.py b/cirq-core/cirq/protocols/act_on_protocol_test.py index 5ffac035b33..a5e4ffb1ea8 100644 --- a/cirq-core/cirq/protocols/act_on_protocol_test.py +++ b/cirq-core/cirq/protocols/act_on_protocol_test.py @@ -96,9 +96,3 @@ def test_qubits_should_be_defined_for_operations(): state = DummySimulationState() with pytest.raises(ValueError, match='Calls to act_on should'): cirq.act_on(cirq.KrausChannel([np.array([[1, 0], [0, 0]])]), state, qubits=None) - - -def test_args_deprecated(): - args = DummySimulationState(fallback_result=True) - with cirq.testing.assert_deprecated(deadline='v0.16'): - cirq.act_on(action=op, args=args) # pylint: disable=no-value-for-parameter diff --git a/cirq-core/cirq/protocols/control_key_protocol.py b/cirq-core/cirq/protocols/control_key_protocol.py index f8897734918..d8c8a0ea589 100644 --- a/cirq-core/cirq/protocols/control_key_protocol.py +++ b/cirq-core/cirq/protocols/control_key_protocol.py @@ -17,7 +17,6 @@ from typing_extensions import Protocol -from cirq import _compat from cirq._doc import doc_private from cirq.protocols import measurement_key_protocol from cirq.type_workarounds import NotImplementedType @@ -58,12 +57,6 @@ def control_keys(val: Any) -> FrozenSet['cirq.MeasurementKey']: getter = getattr(val, '_control_keys_', None) result = NotImplemented if getter is None else getter() if result is not NotImplemented and result is not None: - if not isinstance(result, FrozenSet): - _compat._warn_or_error( - f'The _control_keys_ implementation of {type(val)} must return a' - f' frozenset instead of {type(result)} by v0.16.' - ) - return frozenset(result) return result return frozenset() diff --git a/cirq-core/cirq/protocols/control_key_protocol_test.py b/cirq-core/cirq/protocols/control_key_protocol_test.py index 4b72aecf277..6f539125296 100644 --- a/cirq-core/cirq/protocols/control_key_protocol_test.py +++ b/cirq-core/cirq/protocols/control_key_protocol_test.py @@ -27,12 +27,3 @@ def _control_keys_(self): assert cirq.control_keys(Named()) == {cirq.MeasurementKey('key')} assert not cirq.control_keys(NoImpl()) assert not cirq.control_keys(5) - - -def test_control_key_enumerable_deprecated(): - class Deprecated: - def _control_keys_(self): - return [cirq.MeasurementKey('key')] - - with cirq.testing.assert_deprecated('frozenset', deadline='v0.16'): - assert cirq.control_keys(Deprecated()) == {cirq.MeasurementKey('key')} diff --git a/cirq-core/cirq/protocols/measurement_key_protocol.py b/cirq-core/cirq/protocols/measurement_key_protocol.py index a7f84c3718f..69b552f8e23 100644 --- a/cirq-core/cirq/protocols/measurement_key_protocol.py +++ b/cirq-core/cirq/protocols/measurement_key_protocol.py @@ -17,7 +17,7 @@ from typing_extensions import Protocol -from cirq import value, _compat +from cirq import value from cirq._doc import doc_private from cirq.type_workarounds import NotImplementedType @@ -182,12 +182,6 @@ def _measurement_key_objs_from_magic_methods( getter = getattr(val, '_measurement_key_objs_', None) result = NotImplemented if getter is None else getter() if result is not NotImplemented and result is not None: - if not isinstance(result, FrozenSet): - _compat._warn_or_error( - f'The _measurement_key_objs_ implementation of {type(val)} must return a' - f' frozenset instead of {type(result)} by v0.16.' - ) - return frozenset(result) return result getter = getattr(val, '_measurement_key_obj_', None) @@ -205,12 +199,6 @@ def _measurement_key_names_from_magic_methods( getter = getattr(val, '_measurement_key_names_', None) result = NotImplemented if getter is None else getter() if result is not NotImplemented and result is not None: - if not isinstance(result, FrozenSet): - _compat._warn_or_error( - f'The _measurement_key_names_ implementation of {type(val)} must return a' - f' frozenset instead of {type(result)} by v0.16.' - ) - return frozenset(result) return result getter = getattr(val, '_measurement_key_name_', None) diff --git a/cirq-core/cirq/protocols/measurement_key_protocol_test.py b/cirq-core/cirq/protocols/measurement_key_protocol_test.py index 9b24681ba26..f07d032b986 100644 --- a/cirq-core/cirq/protocols/measurement_key_protocol_test.py +++ b/cirq-core/cirq/protocols/measurement_key_protocol_test.py @@ -238,18 +238,3 @@ def _with_key_path_(self, path): assert cirq.measurement_key_names(mkg_cd) == {'c:d:a', 'c:d:b'} assert cirq.with_key_path(cirq.X, ('c', 'd')) is NotImplemented - - -def test_measurement_key_enumerable_deprecated(): - class Deprecated: - def _measurement_key_objs_(self): - return [cirq.MeasurementKey('key')] - - def _measurement_key_names_(self): - return ['key'] - - with cirq.testing.assert_deprecated('frozenset', deadline='v0.16'): - assert cirq.measurement_key_objs(Deprecated()) == {cirq.MeasurementKey('key')} - - with cirq.testing.assert_deprecated('frozenset', deadline='v0.16'): - assert cirq.measurement_key_names(Deprecated()) == {'key'}