Skip to content

Commit b782166

Browse files
daxfohlCirqBot
andauthored
Remove key protocol frozenset conversion (quantumlib#5660)
Co-authored-by: Cirq Bot <craiggidney+github+cirqbot@google.com>
1 parent beedecb commit b782166

File tree

6 files changed

+2
-64
lines changed

6 files changed

+2
-64
lines changed

cirq/protocols/act_on_protocol.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
from typing_extensions import Protocol
1818

19-
from cirq import _compat, ops
19+
from cirq import ops
2020
from cirq._doc import doc_private
2121
from cirq.type_workarounds import NotImplementedType
2222

@@ -86,19 +86,6 @@ def _act_on_(
8686
"""
8787

8888

89-
def _fix_deprecated_args(args, kwargs):
90-
kwargs['sim_state'] = kwargs['args']
91-
del kwargs['args']
92-
return args, kwargs
93-
94-
95-
@_compat.deprecated_parameter(
96-
deadline='v0.16',
97-
fix='Change argument name to `sim_state`',
98-
parameter_desc='args',
99-
match=lambda args, kwargs: 'args' in kwargs,
100-
rewrite=_fix_deprecated_args,
101-
)
10289
def act_on(
10390
action: Any,
10491
sim_state: 'cirq.SimulationStateBase',

cirq/protocols/act_on_protocol_test.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,3 @@ def test_qubits_should_be_defined_for_operations():
9696
state = DummySimulationState()
9797
with pytest.raises(ValueError, match='Calls to act_on should'):
9898
cirq.act_on(cirq.KrausChannel([np.array([[1, 0], [0, 0]])]), state, qubits=None)
99-
100-
101-
def test_args_deprecated():
102-
args = DummySimulationState(fallback_result=True)
103-
with cirq.testing.assert_deprecated(deadline='v0.16'):
104-
cirq.act_on(action=op, args=args) # pylint: disable=no-value-for-parameter

cirq/protocols/control_key_protocol.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
from typing_extensions import Protocol
1919

20-
from cirq import _compat
2120
from cirq._doc import doc_private
2221
from cirq.protocols import measurement_key_protocol
2322
from cirq.type_workarounds import NotImplementedType
@@ -58,12 +57,6 @@ def control_keys(val: Any) -> FrozenSet['cirq.MeasurementKey']:
5857
getter = getattr(val, '_control_keys_', None)
5958
result = NotImplemented if getter is None else getter()
6059
if result is not NotImplemented and result is not None:
61-
if not isinstance(result, FrozenSet):
62-
_compat._warn_or_error(
63-
f'The _control_keys_ implementation of {type(val)} must return a'
64-
f' frozenset instead of {type(result)} by v0.16.'
65-
)
66-
return frozenset(result)
6760
return result
6861

6962
return frozenset()

cirq/protocols/control_key_protocol_test.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,3 @@ def _control_keys_(self):
2727
assert cirq.control_keys(Named()) == {cirq.MeasurementKey('key')}
2828
assert not cirq.control_keys(NoImpl())
2929
assert not cirq.control_keys(5)
30-
31-
32-
def test_control_key_enumerable_deprecated():
33-
class Deprecated:
34-
def _control_keys_(self):
35-
return [cirq.MeasurementKey('key')]
36-
37-
with cirq.testing.assert_deprecated('frozenset', deadline='v0.16'):
38-
assert cirq.control_keys(Deprecated()) == {cirq.MeasurementKey('key')}

cirq/protocols/measurement_key_protocol.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from typing_extensions import Protocol
1919

20-
from cirq import value, _compat
20+
from cirq import value
2121
from cirq._doc import doc_private
2222
from cirq.type_workarounds import NotImplementedType
2323

@@ -182,12 +182,6 @@ def _measurement_key_objs_from_magic_methods(
182182
getter = getattr(val, '_measurement_key_objs_', None)
183183
result = NotImplemented if getter is None else getter()
184184
if result is not NotImplemented and result is not None:
185-
if not isinstance(result, FrozenSet):
186-
_compat._warn_or_error(
187-
f'The _measurement_key_objs_ implementation of {type(val)} must return a'
188-
f' frozenset instead of {type(result)} by v0.16.'
189-
)
190-
return frozenset(result)
191185
return result
192186

193187
getter = getattr(val, '_measurement_key_obj_', None)
@@ -205,12 +199,6 @@ def _measurement_key_names_from_magic_methods(
205199
getter = getattr(val, '_measurement_key_names_', None)
206200
result = NotImplemented if getter is None else getter()
207201
if result is not NotImplemented and result is not None:
208-
if not isinstance(result, FrozenSet):
209-
_compat._warn_or_error(
210-
f'The _measurement_key_names_ implementation of {type(val)} must return a'
211-
f' frozenset instead of {type(result)} by v0.16.'
212-
)
213-
return frozenset(result)
214202
return result
215203

216204
getter = getattr(val, '_measurement_key_name_', None)

cirq/protocols/measurement_key_protocol_test.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -238,18 +238,3 @@ def _with_key_path_(self, path):
238238
assert cirq.measurement_key_names(mkg_cd) == {'c:d:a', 'c:d:b'}
239239

240240
assert cirq.with_key_path(cirq.X, ('c', 'd')) is NotImplemented
241-
242-
243-
def test_measurement_key_enumerable_deprecated():
244-
class Deprecated:
245-
def _measurement_key_objs_(self):
246-
return [cirq.MeasurementKey('key')]
247-
248-
def _measurement_key_names_(self):
249-
return ['key']
250-
251-
with cirq.testing.assert_deprecated('frozenset', deadline='v0.16'):
252-
assert cirq.measurement_key_objs(Deprecated()) == {cirq.MeasurementKey('key')}
253-
254-
with cirq.testing.assert_deprecated('frozenset', deadline='v0.16'):
255-
assert cirq.measurement_key_names(Deprecated()) == {'key'}

0 commit comments

Comments
 (0)