Skip to content

Commit

Permalink
Remove sim v0.16 deprecations (quantumlib#5645)
Browse files Browse the repository at this point in the history
Remove all the deprecated classes and functions and clean up other deprecation warnings from `sim` module.
  • Loading branch information
daxfohl authored and rht committed May 1, 2023
1 parent b845fc9 commit 52fbea3
Show file tree
Hide file tree
Showing 33 changed files with 36 additions and 1,063 deletions.
10 changes: 0 additions & 10 deletions cirq-core/cirq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,13 +443,6 @@
)

from cirq.sim import (
ActOnArgs,
ActOnArgsContainer,
ActOnCliffordTableauArgs,
ActOnDensityMatrixArgs,
ActOnStabilizerCHFormArgs,
ActOnStabilizerArgs,
ActOnStateVectorArgs,
CIRCUIT_LIKE,
CliffordSimulator,
CliffordState,
Expand All @@ -458,14 +451,12 @@
CliffordTrialResult,
DensityMatrixSimulationState,
DensityMatrixSimulator,
DensityMatrixSimulatorState,
DensityMatrixStepResult,
DensityMatrixTrialResult,
measure_density_matrix,
measure_state_vector,
final_density_matrix,
final_state_vector,
OperationTarget,
sample,
sample_density_matrix,
sample_state_vector,
Expand All @@ -490,7 +481,6 @@
StabilizerStateChForm,
StateVectorMixin,
StateVectorSimulationState,
StateVectorSimulatorState,
StateVectorStepResult,
StateVectorTrialResult,
StepResult,
Expand Down
32 changes: 3 additions & 29 deletions cirq-core/cirq/contrib/quimb/mps_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
import quimb.tensor as qtn

from cirq import devices, protocols, qis, value
from cirq._compat import deprecated_parameter
from cirq.sim import simulator, simulator_base
from cirq.sim import simulator_base
from cirq.sim.simulation_state import SimulationState

if TYPE_CHECKING:
Expand Down Expand Up @@ -143,7 +142,6 @@ def _create_simulator_trial_result(
class MPSTrialResult(simulator_base.SimulationTrialResultBase['MPSState']):
"""A single trial reult"""

@simulator._deprecated_step_result_parameter(old_position=3)
def __init__(
self,
params: 'cirq.ParamResolver',
Expand Down Expand Up @@ -563,27 +561,14 @@ def sample(
class MPSState(SimulationState[_MPSHandler]):
"""A state of the MPS simulation."""

@deprecated_parameter(
deadline='v0.16',
fix='Use kwargs instead of positional args',
parameter_desc='args',
match=lambda args, kwargs: len(args) > 1,
)
@deprecated_parameter(
deadline='v0.16',
fix='Replace log_of_measurement_results with'
' classical_data=cirq.ClassicalDataDictionaryStore(_records=logs).',
parameter_desc='log_of_measurement_results',
match=lambda args, kwargs: 'log_of_measurement_results' in kwargs,
)
def __init__(
self,
*,
qubits: Sequence['cirq.Qid'],
prng: np.random.RandomState,
simulation_options: MPSOptions = MPSOptions(),
grouping: Optional[Dict['cirq.Qid', int]] = None,
initial_state: int = 0,
log_of_measurement_results: Dict[str, Any] = None,
classical_data: 'cirq.ClassicalDataStore' = None,
):
"""Creates and MPSState
Expand All @@ -596,8 +581,6 @@ def __init__(
simulation_options: Numerical options for the simulation.
grouping: How to group qubits together, if None all are individual.
initial_state: An integer representing the initial state.
log_of_measurement_results: A mutable object that measurements are
being recorded into.
classical_data: The shared classical data container for this
simulation.
Expand All @@ -614,16 +597,7 @@ def __init__(
simulation_options=simulation_options,
grouping={qubit_map[k]: v for k, v in final_grouping.items()},
)
if log_of_measurement_results is not None:
super().__init__(
state=state,
prng=prng,
qubits=qubits,
log_of_measurement_results=log_of_measurement_results,
classical_data=classical_data,
)
else:
super().__init__(state=state, prng=prng, qubits=qubits, classical_data=classical_data)
super().__init__(state=state, prng=prng, qubits=qubits, classical_data=classical_data)

def i_str(self, i: int) -> str:
# Returns the index name for the i'th qid.
Expand Down
10 changes: 0 additions & 10 deletions cirq-core/cirq/contrib/quimb/mps_simulator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,13 +488,3 @@ def test_act_on_gate():
args.state_vector().reshape((2, 2, 2)),
cirq.one_hot(index=(0, 1, 0), shape=(2, 2, 2), dtype=np.complex64),
)


def test_deprecated():
prng = np.random.RandomState(0)
with cirq.testing.assert_deprecated('log_of_measurement_results', deadline='0.16', count=2):
_ = ccq.mps_simulator.MPSState(
qubits=cirq.LineQubit.range(3), prng=prng, log_of_measurement_results={}
)
with cirq.testing.assert_deprecated('positional', deadline='0.16'):
_ = ccq.mps_simulator.MPSState(cirq.LineQubit.range(3), prng=prng)
10 changes: 0 additions & 10 deletions cirq-core/cirq/protocols/json_test_data/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
'CliffordSimulatorStepResult',
'CliffordTrialResult',
'DensityMatrixSimulator',
'DensityMatrixSimulatorState',
'DensityMatrixStepResult',
'DensityMatrixTrialResult',
'ExpressionMap',
Expand Down Expand Up @@ -66,7 +65,6 @@
'Timestamp',
'TwoQubitGateTabulationResult',
'UnitSweep',
'StateVectorSimulatorState',
'StateVectorTrialResult',
'ZerosSampler',
'Zip',
Expand All @@ -76,19 +74,11 @@
'Heatmap',
'TwoQubitInteractionHeatmap',
# Intermediate states with work buffers and unknown external prng guts.
'ActOnArgs',
'ActOnArgsContainer',
'ActOnCliffordTableauArgs',
'ActOnDensityMatrixArgs',
'ActOnStabilizerArgs',
'ActOnStabilizerCHFormArgs',
'ActOnStateVectorArgs',
'ApplyChannelArgs',
'ApplyMixtureArgs',
'ApplyUnitaryArgs',
'CliffordTableauSimulationState',
'DensityMatrixSimulationState',
'OperationTarget',
'SimulationProductState',
'SimulationState',
'SimulationStateBase',
Expand Down
15 changes: 0 additions & 15 deletions cirq-core/cirq/sim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,7 @@

"""Classes for circuit simulators and base implementations of these classes."""

from cirq.sim.act_on_args import ActOnArgs

from cirq.sim.act_on_args_container import ActOnArgsContainer

from cirq.sim.act_on_density_matrix_args import ActOnDensityMatrixArgs

from cirq.sim.act_on_state_vector_args import ActOnStateVectorArgs

from cirq.sim.clifford import (
ActOnCliffordTableauArgs,
ActOnStabilizerArgs,
ActOnStabilizerCHFormArgs,
CliffordSimulator,
CliffordSimulatorStepResult,
CliffordState,
Expand All @@ -41,7 +30,6 @@

from cirq.sim.density_matrix_simulator import (
DensityMatrixSimulator,
DensityMatrixSimulatorState,
DensityMatrixStepResult,
DensityMatrixTrialResult,
)
Expand All @@ -56,8 +44,6 @@
sample_sweep,
)

from cirq.sim.operation_target import OperationTarget

from cirq.sim.simulation_product_state import SimulationProductState

from cirq.sim.simulation_state import SimulationState
Expand All @@ -84,7 +70,6 @@

from cirq.sim.state_vector_simulator import (
SimulatesIntermediateStateVector,
StateVectorSimulatorState,
StateVectorStepResult,
StateVectorTrialResult,
)
21 changes: 0 additions & 21 deletions cirq-core/cirq/sim/act_on_args.py

This file was deleted.

21 changes: 0 additions & 21 deletions cirq-core/cirq/sim/act_on_args_container.py

This file was deleted.

21 changes: 0 additions & 21 deletions cirq-core/cirq/sim/act_on_density_matrix_args.py

This file was deleted.

21 changes: 0 additions & 21 deletions cirq-core/cirq/sim/act_on_state_vector_args.py

This file was deleted.

6 changes: 0 additions & 6 deletions cirq-core/cirq/sim/clifford/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# pylint: disable=wrong-or-nonexistent-copyright-notice

from cirq.sim.clifford.act_on_clifford_tableau_args import ActOnCliffordTableauArgs

from cirq.sim.clifford.act_on_stabilizer_args import ActOnStabilizerArgs

from cirq.sim.clifford.act_on_stabilizer_ch_form_args import ActOnStabilizerCHFormArgs

from cirq.sim.clifford.clifford_simulator import (
CliffordSimulator,
CliffordSimulatorStepResult,
Expand Down
21 changes: 0 additions & 21 deletions cirq-core/cirq/sim/clifford/act_on_clifford_tableau_args.py

This file was deleted.

21 changes: 0 additions & 21 deletions cirq-core/cirq/sim/clifford/act_on_stabilizer_args.py

This file was deleted.

21 changes: 0 additions & 21 deletions cirq-core/cirq/sim/clifford/act_on_stabilizer_ch_form_args.py

This file was deleted.

Loading

0 comments on commit 52fbea3

Please sign in to comment.