cirq-core 1.6.0.dev20250520054601__py3-none-any.whl → 1.6.0.dev20250520181654__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cirq-core might be problematic. Click here for more details.
- cirq/_compat.py +15 -17
- cirq/_compat_test.py +6 -9
- cirq/_doc.py +2 -2
- cirq/_import.py +6 -6
- cirq/_version.py +1 -1
- cirq/_version_test.py +1 -1
- cirq/circuits/_block_diagram_drawer.py +9 -10
- cirq/circuits/_box_drawing_character_data.py +6 -8
- cirq/circuits/_bucket_priority_queue.py +7 -7
- cirq/circuits/circuit.py +118 -125
- cirq/circuits/circuit_operation.py +38 -52
- cirq/circuits/circuit_test.py +4 -4
- cirq/circuits/frozen_circuit.py +13 -23
- cirq/circuits/moment.py +23 -29
- cirq/circuits/optimization_pass.py +4 -4
- cirq/circuits/optimization_pass_test.py +4 -6
- cirq/circuits/qasm_output.py +11 -11
- cirq/circuits/text_diagram_drawer.py +21 -36
- cirq/contrib/acquaintance/bipartite.py +5 -8
- cirq/contrib/acquaintance/executor.py +5 -5
- cirq/contrib/acquaintance/executor_test.py +3 -3
- cirq/contrib/acquaintance/gates.py +16 -26
- cirq/contrib/acquaintance/gates_test.py +3 -3
- cirq/contrib/acquaintance/mutation_utils.py +4 -4
- cirq/contrib/acquaintance/optimizers.py +4 -4
- cirq/contrib/acquaintance/permutation.py +15 -27
- cirq/contrib/acquaintance/shift.py +3 -3
- cirq/contrib/acquaintance/shift_swap_network.py +4 -4
- cirq/contrib/acquaintance/strategies/cubic.py +2 -2
- cirq/contrib/acquaintance/strategies/quartic_paired.py +6 -6
- cirq/contrib/bayesian_network/bayesian_network_gate.py +9 -10
- cirq/contrib/circuitdag/circuit_dag.py +2 -2
- cirq/contrib/custom_simulators/custom_state_simulator.py +3 -3
- cirq/contrib/custom_simulators/custom_state_simulator_test.py +4 -4
- cirq/contrib/graph_device/graph_device.py +5 -5
- cirq/contrib/graph_device/hypergraph.py +12 -12
- cirq/contrib/graph_device/uniform_graph_device.py +4 -4
- cirq/contrib/paulistring/clifford_optimize.py +2 -2
- cirq/contrib/paulistring/clifford_target_gateset.py +7 -7
- cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation.py +31 -31
- cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation_test.py +23 -23
- cirq/contrib/paulistring/recombine.py +3 -3
- cirq/contrib/paulistring/separate.py +2 -2
- cirq/contrib/qasm_import/_parser.py +20 -32
- cirq/contrib/qcircuit/qcircuit_diagram_info.py +3 -5
- cirq/contrib/quantum_volume/quantum_volume.py +24 -24
- cirq/contrib/quimb/density_matrix.py +12 -14
- cirq/contrib/quimb/mps_simulator.py +20 -20
- cirq/contrib/quimb/state_vector.py +6 -10
- cirq/contrib/quirk/export_to_quirk.py +3 -3
- cirq/contrib/quirk/quirk_gate.py +15 -15
- cirq/contrib/routing/device.py +3 -3
- cirq/contrib/routing/greedy.py +10 -21
- cirq/contrib/routing/initialization.py +2 -2
- cirq/contrib/routing/swap_network.py +3 -3
- cirq/contrib/routing/utils.py +2 -2
- cirq/contrib/shuffle_circuits/shuffle_circuits_with_readout_benchmarking.py +8 -8
- cirq/contrib/svg/svg.py +3 -3
- cirq/devices/grid_device_metadata.py +10 -10
- cirq/devices/grid_qubit.py +20 -20
- cirq/devices/insertion_noise_model.py +5 -5
- cirq/devices/line_qubit.py +13 -13
- cirq/devices/named_topologies.py +18 -29
- cirq/devices/noise_model.py +3 -3
- cirq/devices/noise_properties.py +2 -2
- cirq/devices/noise_properties_test.py +1 -3
- cirq/devices/noise_utils.py +7 -7
- cirq/devices/superconducting_qubits_noise_properties.py +21 -21
- cirq/devices/superconducting_qubits_noise_properties_test.py +5 -7
- cirq/devices/thermal_noise_model.py +14 -14
- cirq/devices/unconstrained_device.py +2 -2
- cirq/experiments/benchmarking/parallel_xeb.py +29 -31
- cirq/experiments/n_qubit_tomography.py +5 -7
- cirq/experiments/qubit_characterizations.py +29 -40
- cirq/experiments/qubit_characterizations_test.py +1 -1
- cirq/experiments/random_quantum_circuit_generation.py +19 -33
- cirq/experiments/random_quantum_circuit_generation_test.py +6 -6
- cirq/experiments/readout_confusion_matrix.py +14 -14
- cirq/experiments/single_qubit_readout_calibration.py +12 -12
- cirq/experiments/t2_decay_experiment.py +7 -7
- cirq/experiments/two_qubit_xeb.py +32 -32
- cirq/experiments/two_qubit_xeb_test.py +5 -5
- cirq/experiments/xeb_fitting.py +25 -25
- cirq/experiments/xeb_sampling.py +22 -33
- cirq/experiments/xeb_simulation.py +5 -5
- cirq/experiments/xeb_simulation_test.py +3 -3
- cirq/experiments/z_phase_calibration.py +19 -19
- cirq/interop/quirk/cells/arithmetic_cells.py +23 -36
- cirq/interop/quirk/cells/cell.py +9 -21
- cirq/interop/quirk/cells/composite_cell.py +7 -22
- cirq/interop/quirk/cells/control_cells.py +8 -8
- cirq/interop/quirk/cells/input_cells.py +4 -4
- cirq/interop/quirk/cells/input_rotation_cells.py +5 -5
- cirq/interop/quirk/cells/parse.py +20 -23
- cirq/interop/quirk/cells/qubit_permutation_cells.py +3 -3
- cirq/interop/quirk/cells/swap_cell.py +3 -3
- cirq/interop/quirk/cells/testing.py +5 -7
- cirq/interop/quirk/url_to_circuit.py +17 -33
- cirq/json_resolver_cache.py +6 -6
- cirq/linalg/decompositions.py +20 -31
- cirq/linalg/diagonalize.py +4 -4
- cirq/linalg/diagonalize_test.py +3 -4
- cirq/linalg/operator_spaces.py +5 -5
- cirq/linalg/predicates.py +7 -7
- cirq/linalg/transformations.py +20 -20
- cirq/ops/arithmetic_operation.py +13 -15
- cirq/ops/boolean_hamiltonian.py +17 -17
- cirq/ops/classically_controlled_operation.py +13 -25
- cirq/ops/clifford_gate.py +31 -35
- cirq/ops/clifford_gate_test.py +2 -3
- cirq/ops/common_channels.py +30 -32
- cirq/ops/common_gates.py +64 -74
- cirq/ops/control_values.py +12 -12
- cirq/ops/controlled_gate.py +15 -30
- cirq/ops/controlled_gate_test.py +5 -5
- cirq/ops/controlled_operation.py +12 -25
- cirq/ops/controlled_operation_test.py +5 -5
- cirq/ops/dense_pauli_string.py +23 -34
- cirq/ops/dense_pauli_string_test.py +1 -2
- cirq/ops/diagonal_gate.py +9 -20
- cirq/ops/diagonal_gate_test.py +1 -3
- cirq/ops/eigen_gate.py +11 -23
- cirq/ops/eigen_gate_test.py +6 -8
- cirq/ops/fourier_transform.py +5 -5
- cirq/ops/fsim_gate.py +14 -14
- cirq/ops/gate_operation.py +23 -44
- cirq/ops/gateset.py +23 -37
- cirq/ops/gateset_test.py +2 -2
- cirq/ops/global_phase_op.py +8 -10
- cirq/ops/greedy_qubit_manager.py +6 -6
- cirq/ops/identity.py +9 -9
- cirq/ops/kraus_channel.py +7 -7
- cirq/ops/linear_combinations.py +29 -48
- cirq/ops/matrix_gates.py +8 -8
- cirq/ops/measure_util.py +13 -14
- cirq/ops/measurement_gate.py +18 -29
- cirq/ops/mixed_unitary_channel.py +8 -8
- cirq/ops/named_qubit.py +10 -10
- cirq/ops/op_tree.py +7 -7
- cirq/ops/parallel_gate.py +5 -5
- cirq/ops/parity_gates.py +14 -14
- cirq/ops/pauli_gates.py +8 -10
- cirq/ops/pauli_interaction_gate.py +6 -6
- cirq/ops/pauli_measurement_gate.py +11 -23
- cirq/ops/pauli_string.py +35 -52
- cirq/ops/pauli_string_phasor.py +4 -14
- cirq/ops/pauli_string_raw_types.py +3 -3
- cirq/ops/pauli_sum_exponential.py +2 -2
- cirq/ops/permutation_gate.py +4 -4
- cirq/ops/phased_iswap_gate.py +9 -9
- cirq/ops/phased_x_gate.py +10 -10
- cirq/ops/phased_x_z_gate.py +11 -11
- cirq/ops/projector.py +6 -6
- cirq/ops/qubit_manager.py +6 -6
- cirq/ops/qubit_order.py +3 -3
- cirq/ops/random_gate_channel.py +4 -4
- cirq/ops/raw_types.py +48 -70
- cirq/ops/state_preparation_channel.py +3 -3
- cirq/ops/swap_gates.py +9 -9
- cirq/ops/tags.py +2 -4
- cirq/ops/three_qubit_gates.py +20 -38
- cirq/ops/two_qubit_diagonal_gate.py +5 -5
- cirq/ops/uniform_superposition_gate.py +2 -2
- cirq/ops/wait_gate.py +5 -5
- cirq/protocols/act_on_protocol_test.py +3 -3
- cirq/protocols/apply_channel_protocol.py +8 -14
- cirq/protocols/apply_mixture_protocol.py +14 -16
- cirq/protocols/apply_mixture_protocol_test.py +5 -6
- cirq/protocols/apply_unitary_protocol.py +17 -19
- cirq/protocols/circuit_diagram_info_protocol.py +19 -30
- cirq/protocols/decompose_protocol.py +30 -34
- cirq/protocols/inverse_protocol.py +7 -7
- cirq/protocols/json_serialization.py +32 -51
- cirq/protocols/json_serialization_test.py +9 -10
- cirq/protocols/kraus_protocol.py +4 -4
- cirq/protocols/kraus_protocol_test.py +3 -3
- cirq/protocols/measurement_key_protocol.py +11 -13
- cirq/protocols/mixture_protocol.py +4 -4
- cirq/protocols/qasm.py +11 -13
- cirq/protocols/qid_shape_protocol.py +6 -8
- cirq/qis/clifford_tableau.py +12 -12
- cirq/qis/measures.py +7 -7
- cirq/qis/quantum_state_representation.py +3 -3
- cirq/qis/states.py +51 -51
- cirq/sim/classical_simulator.py +10 -10
- cirq/sim/clifford/clifford_simulator.py +6 -6
- cirq/sim/clifford/clifford_tableau_simulation_state_test.py +1 -3
- cirq/sim/clifford/stabilizer_sampler.py +4 -4
- cirq/sim/clifford/stabilizer_state_ch_form.py +3 -3
- cirq/sim/density_matrix_simulation_state.py +15 -15
- cirq/sim/density_matrix_simulator.py +11 -11
- cirq/sim/density_matrix_utils.py +9 -9
- cirq/sim/mux.py +9 -9
- cirq/sim/simulation_product_state.py +9 -9
- cirq/sim/simulation_product_state_test.py +2 -2
- cirq/sim/simulation_state.py +14 -27
- cirq/sim/simulation_state_base.py +8 -24
- cirq/sim/simulation_utils.py +3 -4
- cirq/sim/simulator.py +28 -43
- cirq/sim/simulator_base.py +12 -25
- cirq/sim/simulator_base_test.py +6 -6
- cirq/sim/simulator_test.py +7 -7
- cirq/sim/sparse_simulator.py +8 -8
- cirq/sim/state_vector.py +8 -8
- cirq/sim/state_vector_simulation_state.py +17 -17
- cirq/sim/state_vector_simulator.py +4 -4
- cirq/study/flatten_expressions.py +12 -14
- cirq/study/resolver.py +9 -11
- cirq/study/result.py +11 -24
- cirq/study/sweepable.py +5 -5
- cirq/study/sweeps.py +27 -40
- cirq/testing/circuit_compare.py +5 -5
- cirq/testing/consistent_controlled_gate_op_test.py +7 -11
- cirq/testing/consistent_protocols.py +10 -10
- cirq/testing/consistent_protocols_test.py +7 -7
- cirq/testing/consistent_qasm.py +4 -4
- cirq/testing/consistent_qasm_test.py +2 -3
- cirq/testing/devices.py +4 -5
- cirq/testing/equals_tester.py +2 -2
- cirq/testing/equivalent_basis_map.py +4 -4
- cirq/testing/equivalent_repr_eval.py +3 -3
- cirq/testing/json.py +14 -14
- cirq/testing/logs.py +3 -3
- cirq/testing/no_identifier_qubit.py +2 -3
- cirq/testing/random_circuit.py +7 -7
- cirq/testing/random_circuit_test.py +3 -3
- cirq/transformers/analytical_decompositions/clifford_decomposition.py +16 -16
- cirq/transformers/analytical_decompositions/controlled_gate_decomposition.py +13 -13
- cirq/transformers/analytical_decompositions/cphase_to_fsim.py +5 -5
- cirq/transformers/analytical_decompositions/cphase_to_fsim_test.py +3 -3
- cirq/transformers/analytical_decompositions/pauli_string_decomposition.py +3 -3
- cirq/transformers/analytical_decompositions/quantum_shannon_decomposition.py +4 -4
- cirq/transformers/analytical_decompositions/single_qubit_decompositions.py +6 -7
- cirq/transformers/analytical_decompositions/single_to_two_qubit_isometry.py +2 -2
- cirq/transformers/analytical_decompositions/three_qubit_decomposition.py +7 -7
- cirq/transformers/analytical_decompositions/two_qubit_state_preparation.py +4 -4
- cirq/transformers/analytical_decompositions/two_qubit_to_cz.py +7 -7
- cirq/transformers/analytical_decompositions/two_qubit_to_fsim.py +11 -11
- cirq/transformers/analytical_decompositions/two_qubit_to_ms.py +5 -5
- cirq/transformers/analytical_decompositions/two_qubit_to_sqrt_iswap.py +14 -14
- cirq/transformers/dynamical_decoupling.py +13 -13
- cirq/transformers/dynamical_decoupling_test.py +4 -4
- cirq/transformers/eject_phased_paulis.py +16 -16
- cirq/transformers/eject_z.py +5 -7
- cirq/transformers/gauge_compiling/gauge_compiling.py +38 -38
- cirq/transformers/gauge_compiling/sqrt_cz_gauge.py +2 -2
- cirq/transformers/heuristic_decompositions/two_qubit_gate_tabulation.py +8 -8
- cirq/transformers/insertion_sort.py +5 -5
- cirq/transformers/measurement_transformers.py +14 -14
- cirq/transformers/merge_k_qubit_gates_test.py +1 -3
- cirq/transformers/merge_single_qubit_gates_test.py +1 -3
- cirq/transformers/qubit_management_transformers.py +5 -5
- cirq/transformers/routing/initial_mapper.py +4 -4
- cirq/transformers/routing/line_initial_mapper.py +9 -9
- cirq/transformers/routing/mapping_manager.py +7 -7
- cirq/transformers/routing/route_circuit_cqc.py +27 -27
- cirq/transformers/routing/visualize_routed_circuit.py +4 -4
- cirq/transformers/stratify.py +8 -8
- cirq/transformers/synchronize_terminal_measurements.py +6 -6
- cirq/transformers/target_gatesets/compilation_target_gateset.py +8 -8
- cirq/transformers/target_gatesets/compilation_target_gateset_test.py +2 -2
- cirq/transformers/target_gatesets/cz_gateset.py +4 -4
- cirq/transformers/target_gatesets/sqrt_iswap_gateset.py +5 -5
- cirq/transformers/transformer_api.py +11 -26
- cirq/transformers/transformer_primitives.py +24 -36
- cirq/transformers/transformer_primitives_test.py +3 -3
- cirq/value/classical_data.py +18 -18
- cirq/value/condition.py +8 -8
- cirq/value/digits.py +7 -7
- cirq/value/duration.py +12 -12
- cirq/value/linear_dict.py +8 -12
- cirq/value/measurement_key.py +8 -8
- cirq/value/product_state.py +9 -9
- cirq/value/value_equality_attr.py +4 -4
- cirq/vis/heatmap.py +23 -35
- cirq/work/collector.py +9 -17
- cirq/work/observable_grouping.py +4 -7
- cirq/work/observable_measurement.py +29 -41
- cirq/work/observable_measurement_data.py +14 -14
- cirq/work/observable_measurement_test.py +2 -2
- cirq/work/observable_settings.py +9 -10
- cirq/work/pauli_sum_collector.py +5 -5
- cirq/work/sampler.py +17 -17
- cirq/work/zeros_sampler.py +3 -3
- {cirq_core-1.6.0.dev20250520054601.dist-info → cirq_core-1.6.0.dev20250520181654.dist-info}/METADATA +1 -1
- {cirq_core-1.6.0.dev20250520054601.dist-info → cirq_core-1.6.0.dev20250520181654.dist-info}/RECORD +289 -289
- {cirq_core-1.6.0.dev20250520054601.dist-info → cirq_core-1.6.0.dev20250520181654.dist-info}/WHEEL +1 -1
- {cirq_core-1.6.0.dev20250520054601.dist-info → cirq_core-1.6.0.dev20250520181654.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.6.0.dev20250520054601.dist-info → cirq_core-1.6.0.dev20250520181654.dist-info}/top_level.txt +0 -0
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
|
-
from typing import Any,
|
|
19
|
+
from typing import Any, Sequence, TYPE_CHECKING
|
|
20
20
|
|
|
21
21
|
import numpy as np
|
|
22
22
|
|
|
@@ -119,7 +119,7 @@ class DensityMatrixSimulator(
|
|
|
119
119
|
def __init__(
|
|
120
120
|
self,
|
|
121
121
|
*,
|
|
122
|
-
dtype:
|
|
122
|
+
dtype: type[np.complexfloating] = np.complex64,
|
|
123
123
|
noise: cirq.NOISE_MODEL_LIKE = None,
|
|
124
124
|
seed: cirq.RANDOM_STATE_OR_SEED_LIKE = None,
|
|
125
125
|
split_untangled_states: bool = True,
|
|
@@ -151,7 +151,7 @@ class DensityMatrixSimulator(
|
|
|
151
151
|
|
|
152
152
|
def _create_partial_simulation_state(
|
|
153
153
|
self,
|
|
154
|
-
initial_state:
|
|
154
|
+
initial_state: np.ndarray | cirq.STATE_VECTOR_LIKE | cirq.DensityMatrixSimulationState,
|
|
155
155
|
qubits: Sequence[cirq.Qid],
|
|
156
156
|
classical_data: cirq.ClassicalDataStore,
|
|
157
157
|
) -> cirq.DensityMatrixSimulationState:
|
|
@@ -192,7 +192,7 @@ class DensityMatrixSimulator(
|
|
|
192
192
|
def _create_simulator_trial_result(
|
|
193
193
|
self,
|
|
194
194
|
params: cirq.ParamResolver,
|
|
195
|
-
measurements:
|
|
195
|
+
measurements: dict[str, np.ndarray],
|
|
196
196
|
final_simulator_state: cirq.SimulationStateBase[cirq.DensityMatrixSimulationState],
|
|
197
197
|
) -> cirq.DensityMatrixTrialResult:
|
|
198
198
|
return DensityMatrixTrialResult(
|
|
@@ -203,12 +203,12 @@ class DensityMatrixSimulator(
|
|
|
203
203
|
def simulate_expectation_values_sweep(
|
|
204
204
|
self,
|
|
205
205
|
program: cirq.AbstractCircuit,
|
|
206
|
-
observables:
|
|
206
|
+
observables: cirq.PauliSumLike | list[cirq.PauliSumLike],
|
|
207
207
|
params: cirq.Sweepable,
|
|
208
208
|
qubit_order: cirq.QubitOrderOrList = ops.QubitOrder.DEFAULT,
|
|
209
209
|
initial_state: Any = None,
|
|
210
210
|
permit_terminal_measurements: bool = False,
|
|
211
|
-
) ->
|
|
211
|
+
) -> list[list[float]]:
|
|
212
212
|
if not permit_terminal_measurements and program.are_any_measurements_terminal():
|
|
213
213
|
raise ValueError(
|
|
214
214
|
'Provided circuit has terminal measurements, which may '
|
|
@@ -218,7 +218,7 @@ class DensityMatrixSimulator(
|
|
|
218
218
|
swept_evs = []
|
|
219
219
|
qubit_order = ops.QubitOrder.as_qubit_order(qubit_order)
|
|
220
220
|
qmap = {q: i for i, q in enumerate(qubit_order.order_for(program.all_qubits()))}
|
|
221
|
-
if not isinstance(observables,
|
|
221
|
+
if not isinstance(observables, list):
|
|
222
222
|
observables = [observables]
|
|
223
223
|
pslist = [ops.PauliSum.wrap(pslike) for pslike in observables]
|
|
224
224
|
for param_resolver in study.to_resolvers(params):
|
|
@@ -245,7 +245,7 @@ class DensityMatrixStepResult(simulator_base.StepResultBase['cirq.DensityMatrixS
|
|
|
245
245
|
def __init__(
|
|
246
246
|
self,
|
|
247
247
|
sim_state: cirq.SimulationStateBase[cirq.DensityMatrixSimulationState],
|
|
248
|
-
dtype:
|
|
248
|
+
dtype: type[np.complexfloating] = np.complex64,
|
|
249
249
|
):
|
|
250
250
|
"""DensityMatrixStepResult.
|
|
251
251
|
|
|
@@ -256,7 +256,7 @@ class DensityMatrixStepResult(simulator_base.StepResultBase['cirq.DensityMatrixS
|
|
|
256
256
|
"""
|
|
257
257
|
super().__init__(sim_state)
|
|
258
258
|
self._dtype = dtype
|
|
259
|
-
self._density_matrix:
|
|
259
|
+
self._density_matrix: np.ndarray | None = None
|
|
260
260
|
|
|
261
261
|
def density_matrix(self, copy=True):
|
|
262
262
|
"""Returns the density matrix at this step in the simulation.
|
|
@@ -356,13 +356,13 @@ class DensityMatrixTrialResult(
|
|
|
356
356
|
def __init__(
|
|
357
357
|
self,
|
|
358
358
|
params: cirq.ParamResolver,
|
|
359
|
-
measurements:
|
|
359
|
+
measurements: dict[str, np.ndarray],
|
|
360
360
|
final_simulator_state: cirq.SimulationStateBase[cirq.DensityMatrixSimulationState],
|
|
361
361
|
) -> None:
|
|
362
362
|
super().__init__(
|
|
363
363
|
params=params, measurements=measurements, final_simulator_state=final_simulator_state
|
|
364
364
|
)
|
|
365
|
-
self._final_density_matrix:
|
|
365
|
+
self._final_density_matrix: np.ndarray | None = None
|
|
366
366
|
|
|
367
367
|
@property
|
|
368
368
|
def final_density_matrix(self) -> np.ndarray:
|
cirq/sim/density_matrix_utils.py
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
|
-
from typing import
|
|
19
|
+
from typing import Sequence, TYPE_CHECKING
|
|
20
20
|
|
|
21
21
|
import numpy as np
|
|
22
22
|
|
|
@@ -31,7 +31,7 @@ def sample_density_matrix(
|
|
|
31
31
|
density_matrix: np.ndarray,
|
|
32
32
|
indices: Sequence[int],
|
|
33
33
|
*, # Force keyword arguments
|
|
34
|
-
qid_shape:
|
|
34
|
+
qid_shape: tuple[int, ...] | None = None,
|
|
35
35
|
repetitions: int = 1,
|
|
36
36
|
seed: cirq.RANDOM_STATE_OR_SEED_LIKE = None,
|
|
37
37
|
) -> np.ndarray:
|
|
@@ -96,10 +96,10 @@ def sample_density_matrix(
|
|
|
96
96
|
def measure_density_matrix(
|
|
97
97
|
density_matrix: np.ndarray,
|
|
98
98
|
indices: Sequence[int],
|
|
99
|
-
qid_shape:
|
|
100
|
-
out:
|
|
99
|
+
qid_shape: tuple[int, ...] | None = None,
|
|
100
|
+
out: np.ndarray | None = None,
|
|
101
101
|
seed: cirq.RANDOM_STATE_OR_SEED_LIKE = None,
|
|
102
|
-
) ->
|
|
102
|
+
) -> tuple[list[int], np.ndarray]:
|
|
103
103
|
"""Performs a measurement of the density matrix in the computational basis.
|
|
104
104
|
|
|
105
105
|
This does not modify `density_matrix` unless the optional `out` is
|
|
@@ -187,7 +187,7 @@ def measure_density_matrix(
|
|
|
187
187
|
|
|
188
188
|
|
|
189
189
|
def _probs(
|
|
190
|
-
density_matrix: np.ndarray, indices: Sequence[int], qid_shape:
|
|
190
|
+
density_matrix: np.ndarray, indices: Sequence[int], qid_shape: tuple[int, ...]
|
|
191
191
|
) -> np.ndarray:
|
|
192
192
|
"""Returns the probabilities for a measurement on the given indices."""
|
|
193
193
|
# Only diagonal elements matter.
|
|
@@ -197,8 +197,8 @@ def _probs(
|
|
|
197
197
|
|
|
198
198
|
|
|
199
199
|
def _validate_density_matrix_qid_shape(
|
|
200
|
-
density_matrix: np.ndarray, qid_shape:
|
|
201
|
-
) ->
|
|
200
|
+
density_matrix: np.ndarray, qid_shape: tuple[int, ...]
|
|
201
|
+
) -> tuple[int, ...]:
|
|
202
202
|
"""Validates that a tensor's shape is a valid shape for qids and returns the
|
|
203
203
|
qid shape.
|
|
204
204
|
"""
|
|
@@ -244,7 +244,7 @@ def _validate_num_qubits(density_matrix: np.ndarray) -> int:
|
|
|
244
244
|
return int(row_size).bit_length() - 1
|
|
245
245
|
|
|
246
246
|
|
|
247
|
-
def _indices_shape(qid_shape:
|
|
247
|
+
def _indices_shape(qid_shape: tuple[int, ...], indices: Sequence[int]) -> tuple[int, ...]:
|
|
248
248
|
"""Validates that the indices have values within range of `len(qid_shape)`."""
|
|
249
249
|
if any(index < 0 for index in indices):
|
|
250
250
|
raise IndexError(f'Negative index in indices: {indices}')
|
cirq/sim/mux.py
CHANGED
|
@@ -19,7 +19,7 @@ Filename is a reference to multiplexing.
|
|
|
19
19
|
|
|
20
20
|
from __future__ import annotations
|
|
21
21
|
|
|
22
|
-
from typing import
|
|
22
|
+
from typing import Sequence, TYPE_CHECKING
|
|
23
23
|
|
|
24
24
|
import numpy as np
|
|
25
25
|
|
|
@@ -32,7 +32,7 @@ from cirq.transformers import measurement_transformers
|
|
|
32
32
|
if TYPE_CHECKING:
|
|
33
33
|
import cirq
|
|
34
34
|
|
|
35
|
-
CIRCUIT_LIKE =
|
|
35
|
+
CIRCUIT_LIKE = circuits.Circuit | ops.Gate | ops.OP_TREE
|
|
36
36
|
document(
|
|
37
37
|
CIRCUIT_LIKE,
|
|
38
38
|
"""A `circuits.Circuit` or a value that can be trivially converted into it:
|
|
@@ -52,9 +52,9 @@ def sample(
|
|
|
52
52
|
program: cirq.Circuit,
|
|
53
53
|
*,
|
|
54
54
|
noise: cirq.NOISE_MODEL_LIKE = None,
|
|
55
|
-
param_resolver:
|
|
55
|
+
param_resolver: cirq.ParamResolver | None = None,
|
|
56
56
|
repetitions: int = 1,
|
|
57
|
-
dtype:
|
|
57
|
+
dtype: type[np.complexfloating] = np.complex64,
|
|
58
58
|
seed: cirq.RANDOM_STATE_OR_SEED_LIKE = None,
|
|
59
59
|
) -> cirq.Result:
|
|
60
60
|
"""Simulates sampling from the given circuit.
|
|
@@ -111,7 +111,7 @@ def final_state_vector(
|
|
|
111
111
|
param_resolver: cirq.ParamResolverOrSimilarType = None,
|
|
112
112
|
qubit_order: cirq.QubitOrderOrList = ops.QubitOrder.DEFAULT,
|
|
113
113
|
ignore_terminal_measurements: bool = False,
|
|
114
|
-
dtype:
|
|
114
|
+
dtype: type[np.complexfloating] = np.complex64,
|
|
115
115
|
seed: cirq.RANDOM_STATE_OR_SEED_LIKE = None,
|
|
116
116
|
) -> np.ndarray:
|
|
117
117
|
"""Returns the state vector resulting from acting operations on a state.
|
|
@@ -181,7 +181,7 @@ def sample_sweep(
|
|
|
181
181
|
*,
|
|
182
182
|
noise: cirq.NOISE_MODEL_LIKE = None,
|
|
183
183
|
repetitions: int = 1,
|
|
184
|
-
dtype:
|
|
184
|
+
dtype: type[np.complexfloating] = np.complex64,
|
|
185
185
|
seed: cirq.RANDOM_STATE_OR_SEED_LIKE = None,
|
|
186
186
|
) -> Sequence[cirq.Result]:
|
|
187
187
|
"""Runs the supplied Circuit, mimicking quantum hardware.
|
|
@@ -206,7 +206,7 @@ def sample_sweep(
|
|
|
206
206
|
"""
|
|
207
207
|
prng = value.parse_random_state(seed)
|
|
208
208
|
|
|
209
|
-
trial_results:
|
|
209
|
+
trial_results: list[study.Result] = []
|
|
210
210
|
for param_resolver in study.to_resolvers(params):
|
|
211
211
|
measurements = sample(
|
|
212
212
|
program,
|
|
@@ -227,8 +227,8 @@ def final_density_matrix(
|
|
|
227
227
|
initial_state: cirq.STATE_VECTOR_LIKE = 0,
|
|
228
228
|
param_resolver: cirq.ParamResolverOrSimilarType = None,
|
|
229
229
|
qubit_order: cirq.QubitOrderOrList = ops.QubitOrder.DEFAULT,
|
|
230
|
-
dtype:
|
|
231
|
-
seed:
|
|
230
|
+
dtype: type[np.complexfloating] = np.complex64,
|
|
231
|
+
seed: int | np.random.RandomState | None = None,
|
|
232
232
|
ignore_measurement_results: bool = True,
|
|
233
233
|
) -> np.ndarray:
|
|
234
234
|
"""Returns the density matrix resulting from simulating the circuit.
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
from collections import abc
|
|
18
|
-
from typing import Any,
|
|
18
|
+
from typing import Any, Generic, Iterator, Mapping, Sequence, TYPE_CHECKING
|
|
19
19
|
|
|
20
20
|
import numpy as np
|
|
21
21
|
|
|
@@ -34,10 +34,10 @@ class SimulationProductState(
|
|
|
34
34
|
|
|
35
35
|
def __init__(
|
|
36
36
|
self,
|
|
37
|
-
sim_states:
|
|
37
|
+
sim_states: dict[cirq.Qid | None, TSimulationState],
|
|
38
38
|
qubits: Sequence[cirq.Qid],
|
|
39
39
|
split_untangled_states: bool,
|
|
40
|
-
classical_data:
|
|
40
|
+
classical_data: cirq.ClassicalDataStore | None = None,
|
|
41
41
|
):
|
|
42
42
|
"""Initializes the class.
|
|
43
43
|
|
|
@@ -57,7 +57,7 @@ class SimulationProductState(
|
|
|
57
57
|
self._split_untangled_states = split_untangled_states
|
|
58
58
|
|
|
59
59
|
@property
|
|
60
|
-
def sim_states(self) -> Mapping[
|
|
60
|
+
def sim_states(self) -> Mapping[cirq.Qid | None, TSimulationState]:
|
|
61
61
|
return self._sim_states
|
|
62
62
|
|
|
63
63
|
@property
|
|
@@ -108,7 +108,7 @@ class SimulationProductState(
|
|
|
108
108
|
|
|
109
109
|
# Go through the op's qubits and join any disparate SimulationState states
|
|
110
110
|
# into a new combined state.
|
|
111
|
-
op_args_opt:
|
|
111
|
+
op_args_opt: TSimulationState | None = None
|
|
112
112
|
for q in qubits:
|
|
113
113
|
if op_args_opt is None:
|
|
114
114
|
op_args_opt = self.sim_states[q]
|
|
@@ -152,12 +152,12 @@ class SimulationProductState(
|
|
|
152
152
|
|
|
153
153
|
def sample(
|
|
154
154
|
self,
|
|
155
|
-
qubits:
|
|
155
|
+
qubits: list[cirq.Qid],
|
|
156
156
|
repetitions: int = 1,
|
|
157
157
|
seed: cirq.RANDOM_STATE_OR_SEED_LIKE = None,
|
|
158
158
|
) -> np.ndarray:
|
|
159
159
|
columns = []
|
|
160
|
-
selected_order:
|
|
160
|
+
selected_order: list[ops.Qid] = []
|
|
161
161
|
q_set = set(qubits)
|
|
162
162
|
for v in dict.fromkeys(self.sim_states.values()):
|
|
163
163
|
qs = [q for q in v.qubits if q in q_set]
|
|
@@ -170,11 +170,11 @@ class SimulationProductState(
|
|
|
170
170
|
index_order = [qubit_map[q] for q in qubits]
|
|
171
171
|
return stacked[:, index_order]
|
|
172
172
|
|
|
173
|
-
def __getitem__(self, item:
|
|
173
|
+
def __getitem__(self, item: cirq.Qid | None) -> TSimulationState:
|
|
174
174
|
return self.sim_states[item]
|
|
175
175
|
|
|
176
176
|
def __len__(self) -> int:
|
|
177
177
|
return len(self.sim_states)
|
|
178
178
|
|
|
179
|
-
def __iter__(self) -> Iterator[
|
|
179
|
+
def __iter__(self) -> Iterator[cirq.Qid | None]:
|
|
180
180
|
return iter(self.sim_states)
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from typing import Any,
|
|
17
|
+
from typing import Any, Sequence
|
|
18
18
|
|
|
19
19
|
import cirq
|
|
20
20
|
|
|
@@ -57,7 +57,7 @@ qs2 = cirq.LineQubit.range(2)
|
|
|
57
57
|
def create_container(
|
|
58
58
|
qubits: Sequence[cirq.Qid], split_untangled_states=True
|
|
59
59
|
) -> cirq.SimulationProductState[EmptySimulationState]:
|
|
60
|
-
state_map:
|
|
60
|
+
state_map: dict[cirq.Qid | None, EmptySimulationState] = {}
|
|
61
61
|
log = cirq.ClassicalDataDictionaryStore()
|
|
62
62
|
if split_untangled_states:
|
|
63
63
|
for q in reversed(qubits):
|
cirq/sim/simulation_state.py
CHANGED
|
@@ -18,20 +18,7 @@ from __future__ import annotations
|
|
|
18
18
|
|
|
19
19
|
import abc
|
|
20
20
|
import copy
|
|
21
|
-
from typing import
|
|
22
|
-
Any,
|
|
23
|
-
cast,
|
|
24
|
-
Dict,
|
|
25
|
-
Generic,
|
|
26
|
-
Iterator,
|
|
27
|
-
List,
|
|
28
|
-
Optional,
|
|
29
|
-
Sequence,
|
|
30
|
-
Set,
|
|
31
|
-
Tuple,
|
|
32
|
-
TYPE_CHECKING,
|
|
33
|
-
TypeVar,
|
|
34
|
-
)
|
|
21
|
+
from typing import Any, cast, Generic, Iterator, Sequence, TYPE_CHECKING, TypeVar
|
|
35
22
|
|
|
36
23
|
import numpy as np
|
|
37
24
|
from typing_extensions import Self
|
|
@@ -52,9 +39,9 @@ class SimulationState(SimulationStateBase, Generic[TState], metaclass=abc.ABCMet
|
|
|
52
39
|
self,
|
|
53
40
|
*,
|
|
54
41
|
state: TState,
|
|
55
|
-
prng:
|
|
56
|
-
qubits:
|
|
57
|
-
classical_data:
|
|
42
|
+
prng: np.random.RandomState | None = None,
|
|
43
|
+
qubits: Sequence[cirq.Qid] | None = None,
|
|
44
|
+
classical_data: cirq.ClassicalDataStore | None = None,
|
|
58
45
|
):
|
|
59
46
|
"""Inits SimulationState.
|
|
60
47
|
|
|
@@ -86,7 +73,7 @@ class SimulationState(SimulationStateBase, Generic[TState], metaclass=abc.ABCMet
|
|
|
86
73
|
qubits: Sequence[cirq.Qid],
|
|
87
74
|
key: str,
|
|
88
75
|
invert_mask: Sequence[bool],
|
|
89
|
-
confusion_map:
|
|
76
|
+
confusion_map: dict[tuple[int, ...], np.ndarray],
|
|
90
77
|
):
|
|
91
78
|
"""Measures the qubits and records to `log_of_measurement_results`.
|
|
92
79
|
|
|
@@ -110,10 +97,10 @@ class SimulationState(SimulationStateBase, Generic[TState], metaclass=abc.ABCMet
|
|
|
110
97
|
value.MeasurementKey.parse_serialized(key), corrected, qubits
|
|
111
98
|
)
|
|
112
99
|
|
|
113
|
-
def get_axes(self, qubits: Sequence[cirq.Qid]) ->
|
|
100
|
+
def get_axes(self, qubits: Sequence[cirq.Qid]) -> list[int]:
|
|
114
101
|
return [self.qubit_map[q] for q in qubits]
|
|
115
102
|
|
|
116
|
-
def _perform_measurement(self, qubits: Sequence[cirq.Qid]) ->
|
|
103
|
+
def _perform_measurement(self, qubits: Sequence[cirq.Qid]) -> list[int]:
|
|
117
104
|
"""Delegates the call to measure the `QuantumStateRepresentation`."""
|
|
118
105
|
if self._state is not None:
|
|
119
106
|
return self._state.measure(self.get_axes(qubits), self.prng)
|
|
@@ -121,9 +108,9 @@ class SimulationState(SimulationStateBase, Generic[TState], metaclass=abc.ABCMet
|
|
|
121
108
|
|
|
122
109
|
def _confuse_result(
|
|
123
110
|
self,
|
|
124
|
-
bits:
|
|
111
|
+
bits: list[int],
|
|
125
112
|
qubits: Sequence[cirq.Qid],
|
|
126
|
-
confusion_map:
|
|
113
|
+
confusion_map: dict[tuple[int, ...], np.ndarray],
|
|
127
114
|
):
|
|
128
115
|
"""Applies confusion matrices to measured results.
|
|
129
116
|
|
|
@@ -211,7 +198,7 @@ class SimulationState(SimulationStateBase, Generic[TState], metaclass=abc.ABCMet
|
|
|
211
198
|
|
|
212
199
|
def factor(
|
|
213
200
|
self, qubits: Sequence[cirq.Qid], *, validate=True, atol=1e-07, inplace=False
|
|
214
|
-
) ->
|
|
201
|
+
) -> tuple[Self, Self]:
|
|
215
202
|
"""Splits two state spaces after a measurement or reset."""
|
|
216
203
|
extracted = copy.copy(self)
|
|
217
204
|
remainder = self if inplace else copy.copy(self)
|
|
@@ -249,7 +236,7 @@ class SimulationState(SimulationStateBase, Generic[TState], metaclass=abc.ABCMet
|
|
|
249
236
|
return args
|
|
250
237
|
|
|
251
238
|
@property
|
|
252
|
-
def qubits(self) ->
|
|
239
|
+
def qubits(self) -> tuple[cirq.Qid, ...]:
|
|
253
240
|
return self._qubits
|
|
254
241
|
|
|
255
242
|
def swap(self, q1: cirq.Qid, q2: cirq.Qid, *, inplace=False):
|
|
@@ -310,7 +297,7 @@ class SimulationState(SimulationStateBase, Generic[TState], metaclass=abc.ABCMet
|
|
|
310
297
|
args._set_qubits(qubits)
|
|
311
298
|
return args
|
|
312
299
|
|
|
313
|
-
def __getitem__(self, item:
|
|
300
|
+
def __getitem__(self, item: cirq.Qid | None) -> Self:
|
|
314
301
|
if item not in self.qubit_map:
|
|
315
302
|
raise IndexError(f'{item} not in {self.qubits}')
|
|
316
303
|
return self
|
|
@@ -318,7 +305,7 @@ class SimulationState(SimulationStateBase, Generic[TState], metaclass=abc.ABCMet
|
|
|
318
305
|
def __len__(self) -> int:
|
|
319
306
|
return len(self.qubits)
|
|
320
307
|
|
|
321
|
-
def __iter__(self) -> Iterator[
|
|
308
|
+
def __iter__(self) -> Iterator[cirq.Qid | None]:
|
|
322
309
|
return iter(self.qubits)
|
|
323
310
|
|
|
324
311
|
@property
|
|
@@ -335,7 +322,7 @@ def strat_act_on_from_apply_decompose(
|
|
|
335
322
|
decomposed = protocols.decompose_once(val, flatten=False, default=None)
|
|
336
323
|
if decomposed is None:
|
|
337
324
|
return NotImplemented
|
|
338
|
-
all_ancilla:
|
|
325
|
+
all_ancilla: set[cirq.Qid] = set()
|
|
339
326
|
for operation in ops.flatten_to_ops(decomposed):
|
|
340
327
|
curr_ancilla = tuple(q for q in operation.qubits if q not in args.qubits)
|
|
341
328
|
args = args.add_qubits(curr_ancilla)
|
|
@@ -18,20 +18,7 @@ from __future__ import annotations
|
|
|
18
18
|
|
|
19
19
|
import abc
|
|
20
20
|
from types import NotImplementedType
|
|
21
|
-
from typing import
|
|
22
|
-
Any,
|
|
23
|
-
Dict,
|
|
24
|
-
Generic,
|
|
25
|
-
Iterator,
|
|
26
|
-
List,
|
|
27
|
-
Mapping,
|
|
28
|
-
Optional,
|
|
29
|
-
Sequence,
|
|
30
|
-
Tuple,
|
|
31
|
-
TYPE_CHECKING,
|
|
32
|
-
TypeVar,
|
|
33
|
-
Union,
|
|
34
|
-
)
|
|
21
|
+
from typing import Any, Generic, Iterator, Mapping, Sequence, TYPE_CHECKING, TypeVar
|
|
35
22
|
|
|
36
23
|
from typing_extensions import Self
|
|
37
24
|
|
|
@@ -50,10 +37,7 @@ class SimulationStateBase(Generic[TSimulationState], metaclass=abc.ABCMeta):
|
|
|
50
37
|
"""An interface for quantum states as targets for operations."""
|
|
51
38
|
|
|
52
39
|
def __init__(
|
|
53
|
-
self,
|
|
54
|
-
*,
|
|
55
|
-
qubits: Sequence[cirq.Qid],
|
|
56
|
-
classical_data: Optional[cirq.ClassicalDataStore] = None,
|
|
40
|
+
self, *, qubits: Sequence[cirq.Qid], classical_data: cirq.ClassicalDataStore | None = None
|
|
57
41
|
):
|
|
58
42
|
"""Initializes the class.
|
|
59
43
|
|
|
@@ -66,7 +50,7 @@ class SimulationStateBase(Generic[TSimulationState], metaclass=abc.ABCMeta):
|
|
|
66
50
|
self._classical_data = classical_data or value.ClassicalDataDictionaryStore()
|
|
67
51
|
|
|
68
52
|
@property
|
|
69
|
-
def qubits(self) ->
|
|
53
|
+
def qubits(self) -> tuple[cirq.Qid, ...]:
|
|
70
54
|
return self._qubits
|
|
71
55
|
|
|
72
56
|
@property
|
|
@@ -88,7 +72,7 @@ class SimulationStateBase(Generic[TSimulationState], metaclass=abc.ABCMeta):
|
|
|
88
72
|
@abc.abstractmethod
|
|
89
73
|
def _act_on_fallback_(
|
|
90
74
|
self, action: Any, qubits: Sequence[cirq.Qid], allow_decompose: bool = True
|
|
91
|
-
) ->
|
|
75
|
+
) -> bool | NotImplementedType:
|
|
92
76
|
"""Handles the act_on protocol fallback implementation.
|
|
93
77
|
|
|
94
78
|
Args:
|
|
@@ -116,21 +100,21 @@ class SimulationStateBase(Generic[TSimulationState], metaclass=abc.ABCMeta):
|
|
|
116
100
|
"""
|
|
117
101
|
|
|
118
102
|
@property
|
|
119
|
-
def log_of_measurement_results(self) ->
|
|
103
|
+
def log_of_measurement_results(self) -> dict[str, list[int]]:
|
|
120
104
|
"""Gets the log of measurement results."""
|
|
121
105
|
return {str(k): list(self.classical_data.get_digits(k)) for k in self.classical_data.keys()}
|
|
122
106
|
|
|
123
107
|
@abc.abstractmethod
|
|
124
108
|
def sample(
|
|
125
109
|
self,
|
|
126
|
-
qubits:
|
|
110
|
+
qubits: list[cirq.Qid],
|
|
127
111
|
repetitions: int = 1,
|
|
128
112
|
seed: cirq.RANDOM_STATE_OR_SEED_LIKE = None,
|
|
129
113
|
) -> np.ndarray:
|
|
130
114
|
"""Samples the state value."""
|
|
131
115
|
|
|
132
116
|
@abc.abstractmethod
|
|
133
|
-
def __getitem__(self, item:
|
|
117
|
+
def __getitem__(self, item: cirq.Qid | None) -> TSimulationState:
|
|
134
118
|
"""Gets the item associated with the qubit."""
|
|
135
119
|
|
|
136
120
|
@abc.abstractmethod
|
|
@@ -138,5 +122,5 @@ class SimulationStateBase(Generic[TSimulationState], metaclass=abc.ABCMeta):
|
|
|
138
122
|
"""Gets the number of items in the mapping."""
|
|
139
123
|
|
|
140
124
|
@abc.abstractmethod
|
|
141
|
-
def __iter__(self) -> Iterator[
|
|
125
|
+
def __iter__(self) -> Iterator[cirq.Qid | None]:
|
|
142
126
|
"""Iterates the keys of the mapping."""
|
cirq/sim/simulation_utils.py
CHANGED
|
@@ -11,10 +11,9 @@
|
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
|
-
|
|
15
14
|
from __future__ import annotations
|
|
16
15
|
|
|
17
|
-
from typing import Any, Sequence
|
|
16
|
+
from typing import Any, Sequence
|
|
18
17
|
|
|
19
18
|
import numpy as np
|
|
20
19
|
|
|
@@ -22,7 +21,7 @@ from cirq import linalg
|
|
|
22
21
|
|
|
23
22
|
|
|
24
23
|
def state_probabilities_by_indices(
|
|
25
|
-
state_probability: np.ndarray, indices: Sequence[int], qid_shape:
|
|
24
|
+
state_probability: np.ndarray, indices: Sequence[int], qid_shape: tuple[int, ...]
|
|
26
25
|
) -> np.ndarray:
|
|
27
26
|
"""Returns the probabilities for a state/measurement on the given indices.
|
|
28
27
|
|
|
@@ -40,7 +39,7 @@ def state_probabilities_by_indices(
|
|
|
40
39
|
Returns:
|
|
41
40
|
State probabilities.
|
|
42
41
|
"""
|
|
43
|
-
probs: np.ndarray[
|
|
42
|
+
probs: np.ndarray[tuple[int, ...], Any]
|
|
44
43
|
probs = state_probability.reshape((-1,))
|
|
45
44
|
not_measured = [i for i in range(len(qid_shape)) if i not in indices]
|
|
46
45
|
if linalg.can_numpy_support_shape(qid_shape):
|