3030import numpy as np
3131
3232from cirq import protocols , value
33- from cirq ._compat import deprecated
33+ from cirq ._compat import _warn_or_error , deprecated
3434from cirq .protocols .decompose_protocol import _try_decompose_into_operations_and_qubits
3535from cirq .sim .operation_target import OperationTarget
3636
@@ -78,6 +78,8 @@ def __init__(
7878 }
7979 )
8080 self ._state = state
81+ if state is None :
82+ _warn_or_error ('This function will require a valid `state` input in cirq v0.16.' )
8183
8284 @property
8385 def prng (self ) -> np .random .RandomState :
@@ -147,9 +149,17 @@ def copy(self: TSelf, deep_copy_buffers: bool = True) -> TSelf:
147149 if self ._state is not None :
148150 args ._state = self ._state .copy (deep_copy_buffers = deep_copy_buffers )
149151 else :
152+ _warn_or_error (
153+ 'Pass a `QuantumStateRepresentation` into the `ActOnArgs` constructor. The `_on_`'
154+ ' overrides will be removed in cirq v0.16.'
155+ )
150156 self ._on_copy (args , deep_copy_buffers )
151157 return args
152158
159+ @deprecated (
160+ deadline = 'v0.16' ,
161+ fix = 'Pass a `QuantumStateRepresentation` into the `ActOnArgs` constructor.' ,
162+ )
153163 def _on_copy (self : TSelf , args : TSelf , deep_copy_buffers : bool = True ):
154164 """Subclasses should implement this with any additional state copy
155165 functionality."""
@@ -164,10 +174,18 @@ def kronecker_product(self: TSelf, other: TSelf, *, inplace=False) -> TSelf:
164174 if self ._state is not None and other ._state is not None :
165175 args ._state = self ._state .kron (other ._state )
166176 else :
177+ _warn_or_error (
178+ 'Pass a `QuantumStateRepresentation` into the `ActOnArgs` constructor. The `_on_`'
179+ ' overrides will be removed in cirq v0.16.'
180+ )
167181 self ._on_kronecker_product (other , args )
168182 args ._set_qubits (self .qubits + other .qubits )
169183 return args
170184
185+ @deprecated (
186+ deadline = 'v0.16' ,
187+ fix = 'Pass a `QuantumStateRepresentation` into the `ActOnArgs` constructor.' ,
188+ )
171189 def _on_kronecker_product (self : TSelf , other : TSelf , target : TSelf ):
172190 """Subclasses should implement this with any additional state product
173191 functionality, if supported."""
@@ -204,6 +222,10 @@ def factor(
204222 extracted ._state = e
205223 remainder ._state = r
206224 else :
225+ _warn_or_error (
226+ 'Pass a `QuantumStateRepresentation` into the `ActOnArgs` constructor. The `_on_`'
227+ ' overrides will be removed in cirq v0.16.'
228+ )
207229 self ._on_factor (qubits , extracted , remainder , validate , atol )
208230 extracted ._set_qubits (qubits )
209231 remainder ._set_qubits ([q for q in self .qubits if q not in qubits ])
@@ -214,6 +236,10 @@ def allows_factoring(self):
214236 """Subclasses that allow factorization should override this."""
215237 return self ._state .supports_factor if self ._state is not None else False
216238
239+ @deprecated (
240+ deadline = 'v0.16' ,
241+ fix = 'Pass a `QuantumStateRepresentation` into the `ActOnArgs` constructor.' ,
242+ )
217243 def _on_factor (
218244 self : TSelf ,
219245 qubits : Sequence ['cirq.Qid' ],
@@ -247,10 +273,18 @@ def transpose_to_qubit_order(
247273 if self ._state is not None :
248274 args ._state = self ._state .reindex (self .get_axes (qubits ))
249275 else :
276+ _warn_or_error (
277+ 'Pass a `QuantumStateRepresentation` into the `ActOnArgs` constructor. The `_on_`'
278+ ' overrides will be removed in cirq v0.16.'
279+ )
250280 self ._on_transpose_to_qubit_order (qubits , args )
251281 args ._set_qubits (qubits )
252282 return args
253283
284+ @deprecated (
285+ deadline = 'v0.16' ,
286+ fix = 'Pass a `QuantumStateRepresentation` into the `ActOnArgs` constructor.' ,
287+ )
254288 def _on_transpose_to_qubit_order (self : TSelf , qubits : Sequence ['cirq.Qid' ], target : TSelf ):
255289 """Subclasses should implement this with any additional state transpose
256290 functionality, if supported."""
0 commit comments