1313# limitations under the License.
1414"""Objects and methods for acting efficiently on a state tensor."""
1515import copy
16- import inspect
17- import warnings
1816from typing import (
1917 Any ,
2018 cast ,
3129
3230import numpy as np
3331
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
3634from cirq .protocols .decompose_protocol import _try_decompose_into_operations_and_qubits
3735from cirq .sim .operation_target import OperationTarget
3836
4543class ActOnArgs (OperationTarget [TSelf ]):
4644 """State and context for an operation acting on a state tensor."""
4745
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- )
5446 def __init__ (
5547 self ,
5648 prng : Optional [np .random .RandomState ] = None ,
5749 qubits : Optional [Sequence ['cirq.Qid' ]] = None ,
5850 log_of_measurement_results : Optional [Dict [str , List [int ]]] = None ,
59- ignore_measurement_results : bool = False ,
6051 classical_data : Optional ['cirq.ClassicalDataStore' ] = None ,
6152 state : Optional ['cirq.QuantumStateRepresentation' ] = None ,
6253 ):
@@ -70,10 +61,6 @@ def __init__(
7061 ordering of the computational basis states.
7162 log_of_measurement_results: A mutable object that measurements are
7263 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.
7764 classical_data: The shared classical data container for this
7865 simulation.
7966 state: The underlying quantum state of the simulation.
@@ -90,7 +77,6 @@ def __init__(
9077 for k , v in (log_of_measurement_results or {}).items ()
9178 }
9279 )
93- self ._ignore_measurement_results = ignore_measurement_results
9480 self ._state = state
9581
9682 @property
@@ -101,32 +87,14 @@ def prng(self) -> np.random.RandomState:
10187 def qubit_map (self ) -> Mapping ['cirq.Qid' , int ]:
10288 return self ._qubit_map
10389
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-
12090 def _set_qubits (self , qubits : Sequence ['cirq.Qid' ]):
12191 self ._qubits = tuple (qubits )
12292 self ._qubit_map = {q : i for i , q in enumerate (self .qubits )}
12393
12494 def measure (self , qubits : Sequence ['cirq.Qid' ], key : str , invert_mask : Sequence [bool ]):
12595 """Measures the qubits and records to `log_of_measurement_results`.
12696
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.
13098
13199 Args:
132100 qubits: The qubits to measure.
@@ -138,9 +106,6 @@ def measure(self, qubits: Sequence['cirq.Qid'], key: str, invert_mask: Sequence[
138106 Raises:
139107 ValueError: If a measurement key has already been logged to a key.
140108 """
141- if self .ignore_measurement_results :
142- self ._act_on_fallback_ (ops .phase_damp (1 ), qubits )
143- return
144109 bits = self ._perform_measurement (qubits )
145110 corrected = [bit ^ (bit < 2 and mask ) for bit , mask in zip (bits , invert_mask )]
146111 self ._classical_data .record_measurement (
@@ -181,18 +146,8 @@ def copy(self: TSelf, deep_copy_buffers: bool = True) -> TSelf:
181146 args ._classical_data = self ._classical_data .copy ()
182147 if self ._state is not None :
183148 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 )
187149 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 )
196151 return args
197152
198153 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
304259 def classical_data (self ) -> 'cirq.ClassicalDataStoreReader' :
305260 return self ._classical_data
306261
307- @property
262+ @property # type: ignore
263+ @deprecated (deadline = 'v0.16' , fix = 'Remove this call, it always returns False.' )
308264 def ignore_measurement_results (self ) -> bool :
309- return self . _ignore_measurement_results
265+ return False
310266
311267 @property
312268 def qubits (self ) -> Tuple ['cirq.Qid' , ...]:
0 commit comments