13
13
# limitations under the License.
14
14
"""Objects and methods for acting efficiently on a state tensor."""
15
15
import copy
16
- import inspect
17
- import warnings
18
16
from typing import (
19
17
Any ,
20
18
cast ,
31
29
32
30
import numpy as np
33
31
34
- from cirq import ops , protocols , value
35
- from cirq ._compat import deprecated , deprecated_parameter
32
+ from cirq import protocols , value
33
+ from cirq ._compat import deprecated
36
34
from cirq .protocols .decompose_protocol import _try_decompose_into_operations_and_qubits
37
35
from cirq .sim .operation_target import OperationTarget
38
36
45
43
class ActOnArgs (OperationTarget [TSelf ]):
46
44
"""State and context for an operation acting on a state tensor."""
47
45
48
- @deprecated_parameter (
49
- deadline = 'v0.15' ,
50
- fix = 'Use cirq.dephase_measurements to transform the circuit before simulating.' ,
51
- parameter_desc = 'ignore_measurement_results' ,
52
- match = lambda args , kwargs : 'ignore_measurement_results' in kwargs or len (args ) > 4 ,
53
- )
54
46
def __init__ (
55
47
self ,
56
48
prng : Optional [np .random .RandomState ] = None ,
57
49
qubits : Optional [Sequence ['cirq.Qid' ]] = None ,
58
50
log_of_measurement_results : Optional [Dict [str , List [int ]]] = None ,
59
- ignore_measurement_results : bool = False ,
60
51
classical_data : Optional ['cirq.ClassicalDataStore' ] = None ,
61
52
state : Optional ['cirq.QuantumStateRepresentation' ] = None ,
62
53
):
@@ -70,10 +61,6 @@ def __init__(
70
61
ordering of the computational basis states.
71
62
log_of_measurement_results: A mutable object that measurements are
72
63
being recorded into.
73
- ignore_measurement_results: If True, then the simulation
74
- will treat measurement as dephasing instead of collapsing
75
- process, and not log the result. This is only applicable to
76
- simulators that can represent mixed states.
77
64
classical_data: The shared classical data container for this
78
65
simulation.
79
66
state: The underlying quantum state of the simulation.
@@ -90,7 +77,6 @@ def __init__(
90
77
for k , v in (log_of_measurement_results or {}).items ()
91
78
}
92
79
)
93
- self ._ignore_measurement_results = ignore_measurement_results
94
80
self ._state = state
95
81
96
82
@property
@@ -101,32 +87,14 @@ def prng(self) -> np.random.RandomState:
101
87
def qubit_map (self ) -> Mapping ['cirq.Qid' , int ]:
102
88
return self ._qubit_map
103
89
104
- @prng .setter # type: ignore
105
- @deprecated (
106
- deadline = "v0.15" ,
107
- fix = "The mutators of this class are deprecated, instantiate a new object instead." ,
108
- )
109
- def prng (self , prng ):
110
- self ._prng = prng
111
-
112
- @qubit_map .setter # type: ignore
113
- @deprecated (
114
- deadline = "v0.15" ,
115
- fix = "The mutators of this class are deprecated, instantiate a new object instead." ,
116
- )
117
- def qubit_map (self , qubit_map ):
118
- self ._qubit_map = qubit_map
119
-
120
90
def _set_qubits (self , qubits : Sequence ['cirq.Qid' ]):
121
91
self ._qubits = tuple (qubits )
122
92
self ._qubit_map = {q : i for i , q in enumerate (self .qubits )}
123
93
124
94
def measure (self , qubits : Sequence ['cirq.Qid' ], key : str , invert_mask : Sequence [bool ]):
125
95
"""Measures the qubits and records to `log_of_measurement_results`.
126
96
127
- Any bitmasks will be applied to the measurement record. If
128
- `self._ignore_measurement_results` is set, it dephases instead of
129
- measuring, and no measurement result will be logged.
97
+ Any bitmasks will be applied to the measurement record.
130
98
131
99
Args:
132
100
qubits: The qubits to measure.
@@ -138,9 +106,6 @@ def measure(self, qubits: Sequence['cirq.Qid'], key: str, invert_mask: Sequence[
138
106
Raises:
139
107
ValueError: If a measurement key has already been logged to a key.
140
108
"""
141
- if self .ignore_measurement_results :
142
- self ._act_on_fallback_ (ops .phase_damp (1 ), qubits )
143
- return
144
109
bits = self ._perform_measurement (qubits )
145
110
corrected = [bit ^ (bit < 2 and mask ) for bit , mask in zip (bits , invert_mask )]
146
111
self ._classical_data .record_measurement (
@@ -181,18 +146,8 @@ def copy(self: TSelf, deep_copy_buffers: bool = True) -> TSelf:
181
146
args ._classical_data = self ._classical_data .copy ()
182
147
if self ._state is not None :
183
148
args ._state = self ._state .copy (deep_copy_buffers = deep_copy_buffers )
184
- return args
185
- if 'deep_copy_buffers' in inspect .signature (self ._on_copy ).parameters :
186
- self ._on_copy (args , deep_copy_buffers )
187
149
else :
188
- warnings .warn (
189
- (
190
- 'A new parameter deep_copy_buffers has been added to ActOnArgs._on_copy(). '
191
- 'The classes that inherit from ActOnArgs should support it before Cirq 0.15.'
192
- ),
193
- DeprecationWarning ,
194
- )
195
- self ._on_copy (args )
150
+ self ._on_copy (args , deep_copy_buffers )
196
151
return args
197
152
198
153
def _on_copy (self : TSelf , args : TSelf , deep_copy_buffers : bool = True ):
@@ -304,9 +259,10 @@ def _on_transpose_to_qubit_order(self: TSelf, qubits: Sequence['cirq.Qid'], targ
304
259
def classical_data (self ) -> 'cirq.ClassicalDataStoreReader' :
305
260
return self ._classical_data
306
261
307
- @property
262
+ @property # type: ignore
263
+ @deprecated (deadline = 'v0.16' , fix = 'Remove this call, it always returns False.' )
308
264
def ignore_measurement_results (self ) -> bool :
309
- return self . _ignore_measurement_results
265
+ return False
310
266
311
267
@property
312
268
def qubits (self ) -> Tuple ['cirq.Qid' , ...]:
0 commit comments