cirq-core 1.7.0.dev20250924231107__py3-none-any.whl → 1.7.0.dev20251203004401__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.
- cirq/__init__.py +1 -0
- cirq/_compat.py +3 -2
- cirq/_compat_test.py +16 -15
- cirq/_doc.py +4 -3
- cirq/_import.py +2 -1
- cirq/_version.py +1 -1
- cirq/_version_test.py +1 -1
- cirq/circuits/_bucket_priority_queue.py +2 -1
- cirq/circuits/circuit.py +7 -13
- cirq/circuits/circuit_operation.py +2 -1
- cirq/circuits/circuit_test.py +13 -12
- cirq/circuits/frozen_circuit.py +3 -2
- cirq/circuits/moment.py +3 -15
- cirq/circuits/optimization_pass.py +2 -1
- cirq/circuits/qasm_output.py +39 -10
- cirq/circuits/qasm_output_test.py +51 -2
- cirq/circuits/text_diagram_drawer.py +2 -1
- cirq/contrib/acquaintance/bipartite.py +2 -1
- cirq/contrib/acquaintance/devices.py +1 -1
- cirq/contrib/acquaintance/executor.py +4 -5
- cirq/contrib/acquaintance/executor_test.py +2 -1
- cirq/contrib/acquaintance/gates.py +2 -1
- cirq/contrib/acquaintance/gates_test.py +1 -1
- cirq/contrib/acquaintance/inspection_utils.py +2 -1
- cirq/contrib/acquaintance/mutation_utils.py +2 -1
- cirq/contrib/acquaintance/optimizers.py +2 -1
- cirq/contrib/acquaintance/permutation.py +2 -1
- cirq/contrib/acquaintance/permutation_test.py +1 -1
- cirq/contrib/acquaintance/shift.py +2 -1
- cirq/contrib/acquaintance/shift_swap_network.py +2 -1
- cirq/contrib/acquaintance/strategies/complete.py +3 -2
- cirq/contrib/acquaintance/strategies/cubic.py +2 -1
- cirq/contrib/acquaintance/strategies/quartic_paired.py +2 -1
- cirq/contrib/acquaintance/strategies/quartic_paired_test.py +1 -1
- cirq/contrib/acquaintance/testing.py +2 -1
- cirq/contrib/acquaintance/topological_sort.py +2 -1
- cirq/contrib/bayesian_network/bayesian_network_gate.py +3 -2
- cirq/contrib/circuitdag/circuit_dag.py +4 -2
- cirq/contrib/custom_simulators/custom_state_simulator.py +2 -1
- cirq/contrib/custom_simulators/custom_state_simulator_test.py +1 -1
- cirq/contrib/graph_device/graph_device.py +2 -1
- cirq/contrib/graph_device/graph_device_test.py +2 -1
- cirq/contrib/graph_device/hypergraph.py +2 -1
- cirq/contrib/graph_device/uniform_graph_device.py +2 -1
- cirq/contrib/json.py +14 -2
- cirq/contrib/json_test_data/BayesianNetworkGate.json +10 -0
- cirq/contrib/json_test_data/BayesianNetworkGate.repr +3 -0
- cirq/contrib/json_test_data/QuantumVolumeResult.json +169 -0
- cirq/contrib/json_test_data/QuantumVolumeResult.repr +22 -0
- cirq/contrib/json_test_data/SwapPermutationGate.json +3 -0
- cirq/contrib/json_test_data/SwapPermutationGate.repr +1 -0
- cirq/contrib/json_test_data/spec.py +0 -2
- cirq/contrib/noise_models/noise_models.py +2 -1
- cirq/contrib/paulistring/clifford_optimize.py +20 -2
- cirq/contrib/paulistring/optimize.py +1 -1
- cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation.py +146 -35
- cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation_test.py +74 -171
- cirq/contrib/paulistring/recombine.py +5 -2
- cirq/contrib/paulistring/separate.py +1 -1
- cirq/contrib/qasm_import/_parser.py +2 -1
- cirq/contrib/qasm_import/_parser_test.py +3 -3
- cirq/contrib/quantikz/__init__.py +21 -0
- cirq/contrib/quantikz/circuit_to_latex_quantikz.py +680 -0
- cirq/contrib/quantikz/circuit_to_latex_quantikz_test.py +253 -0
- cirq/contrib/quantikz/circuit_to_latex_render.py +424 -0
- cirq/contrib/quantikz/circuit_to_latex_render_test.py +44 -0
- cirq/contrib/quantum_volume/quantum_volume.py +2 -1
- cirq/contrib/quimb/density_matrix.py +1 -1
- cirq/contrib/quimb/grid_circuits.py +2 -1
- cirq/contrib/quimb/grid_circuits_test.py +1 -1
- cirq/contrib/quimb/mps_simulator.py +4 -3
- cirq/contrib/quimb/state_vector.py +2 -1
- cirq/contrib/quirk/export_to_quirk.py +2 -1
- cirq/contrib/quirk/linearize_circuit.py +1 -1
- cirq/contrib/quirk/quirk_gate.py +2 -1
- cirq/contrib/routing/device.py +1 -1
- cirq/contrib/routing/greedy.py +2 -1
- cirq/contrib/routing/initialization.py +2 -1
- cirq/contrib/routing/router.py +2 -1
- cirq/contrib/routing/swap_network.py +2 -1
- cirq/contrib/routing/utils.py +2 -1
- cirq/contrib/shuffle_circuits/shuffle_circuits_with_readout_benchmarking.py +7 -5
- cirq/contrib/shuffle_circuits/shuffle_circuits_with_readout_benchmarking_test.py +6 -6
- cirq/devices/device.py +2 -1
- cirq/devices/grid_device_metadata.py +2 -1
- cirq/devices/grid_qubit.py +7 -6
- cirq/devices/insertion_noise_model.py +2 -1
- cirq/devices/line_qubit.py +2 -1
- cirq/devices/named_topologies.py +2 -1
- cirq/devices/noise_model.py +2 -1
- cirq/devices/noise_model_test.py +1 -1
- cirq/devices/noise_properties.py +2 -1
- cirq/devices/superconducting_qubits_noise_properties_test.py +2 -1
- cirq/devices/thermal_noise_model.py +2 -1
- cirq/experiments/__init__.py +2 -0
- cirq/experiments/benchmarking/parallel_xeb.py +2 -1
- cirq/experiments/benchmarking/parallel_xeb_test.py +1 -1
- cirq/experiments/fidelity_estimation.py +2 -1
- cirq/experiments/fidelity_estimation_test.py +1 -1
- cirq/experiments/ghz_2d.py +150 -0
- cirq/experiments/ghz_2d_test.py +155 -0
- cirq/experiments/n_qubit_tomography.py +2 -1
- cirq/experiments/n_qubit_tomography_test.py +1 -1
- cirq/experiments/purity_estimation.py +1 -1
- cirq/experiments/qubit_characterizations.py +2 -1
- cirq/experiments/random_quantum_circuit_generation.py +2 -1
- cirq/experiments/random_quantum_circuit_generation_test.py +2 -1
- cirq/experiments/readout_confusion_matrix.py +2 -1
- cirq/experiments/readout_confusion_matrix_test.py +1 -1
- cirq/experiments/single_qubit_readout_calibration.py +2 -1
- cirq/experiments/single_qubit_readout_calibration_test.py +1 -1
- cirq/experiments/t1_decay_experiment.py +2 -1
- cirq/experiments/two_qubit_xeb.py +2 -1
- cirq/experiments/two_qubit_xeb_test.py +1 -1
- cirq/experiments/xeb_fitting.py +2 -1
- cirq/experiments/xeb_fitting_test.py +1 -1
- cirq/experiments/xeb_sampling.py +5 -3
- cirq/experiments/xeb_sampling_test.py +1 -1
- cirq/experiments/xeb_simulation.py +2 -1
- cirq/experiments/xeb_simulation_test.py +2 -1
- cirq/experiments/z_phase_calibration.py +2 -1
- cirq/experiments/z_phase_calibration_test.py +18 -3
- cirq/interop/quirk/cells/__init__.py +1 -2
- cirq/interop/quirk/cells/all_cells.py +2 -1
- cirq/interop/quirk/cells/arithmetic_cells.py +2 -1
- cirq/interop/quirk/cells/cell.py +2 -1
- cirq/interop/quirk/cells/composite_cell.py +2 -1
- cirq/interop/quirk/cells/composite_cell_test.py +1 -1
- cirq/interop/quirk/cells/control_cells.py +2 -1
- cirq/interop/quirk/cells/frequency_space_cells.py +1 -1
- cirq/interop/quirk/cells/ignored_cells.py +1 -1
- cirq/interop/quirk/cells/input_cells.py +2 -1
- cirq/interop/quirk/cells/input_rotation_cells.py +2 -1
- cirq/interop/quirk/cells/measurement_cells.py +2 -1
- cirq/interop/quirk/cells/parse.py +2 -11
- cirq/interop/quirk/cells/qubit_permutation_cells.py +2 -1
- cirq/interop/quirk/cells/scalar_cells.py +2 -1
- cirq/interop/quirk/cells/single_qubit_rotation_cells.py +2 -1
- cirq/interop/quirk/cells/swap_cell.py +2 -1
- cirq/interop/quirk/cells/unsupported_cells.py +1 -1
- cirq/interop/quirk/url_to_circuit.py +2 -1
- cirq/json_resolver_cache.py +0 -2
- cirq/linalg/decompositions.py +6 -2
- cirq/linalg/decompositions_test.py +1 -0
- cirq/linalg/diagonalize.py +1 -1
- cirq/linalg/predicates.py +2 -1
- cirq/linalg/tolerance.py +2 -1
- cirq/linalg/transformations.py +2 -1
- cirq/ops/arithmetic_operation.py +2 -1
- cirq/ops/arithmetic_operation_test.py +1 -1
- cirq/ops/boolean_hamiltonian.py +4 -3
- cirq/ops/classically_controlled_operation.py +3 -2
- cirq/ops/clifford_gate.py +2 -1
- cirq/ops/clifford_gate_test.py +1 -2
- cirq/ops/common_channels.py +2 -1
- cirq/ops/common_gates.py +2 -1
- cirq/ops/control_values.py +2 -1
- cirq/ops/controlled_gate.py +3 -2
- cirq/ops/controlled_gate_test.py +2 -1
- cirq/ops/controlled_operation.py +3 -2
- cirq/ops/controlled_operation_test.py +2 -1
- cirq/ops/dense_pauli_string.py +3 -13
- cirq/ops/diagonal_gate.py +3 -2
- cirq/ops/eigen_gate.py +9 -7
- cirq/ops/fourier_transform.py +3 -2
- cirq/ops/fourier_transform_test.py +2 -4
- cirq/ops/fsim_gate.py +3 -2
- cirq/ops/gate_operation.py +8 -12
- cirq/ops/gateset.py +22 -2
- cirq/ops/global_phase_op.py +3 -2
- cirq/ops/greedy_qubit_manager.py +2 -1
- cirq/ops/identity.py +2 -1
- cirq/ops/kraus_channel.py +2 -1
- cirq/ops/linear_combinations.py +8 -3
- cirq/ops/linear_combinations_test.py +23 -1
- cirq/ops/matrix_gates.py +2 -1
- cirq/ops/measure_util.py +2 -1
- cirq/ops/measurement_gate.py +2 -1
- cirq/ops/mixed_unitary_channel.py +2 -1
- cirq/ops/named_qubit.py +2 -2
- cirq/ops/op_tree.py +2 -1
- cirq/ops/parallel_gate.py +3 -2
- cirq/ops/parity_gates.py +2 -1
- cirq/ops/pauli_interaction_gate.py +2 -1
- cirq/ops/pauli_measurement_gate.py +2 -1
- cirq/ops/pauli_string.py +6 -12
- cirq/ops/pauli_string_phasor.py +3 -2
- cirq/ops/pauli_string_raw_types.py +2 -1
- cirq/ops/pauli_string_test.py +2 -2
- cirq/ops/pauli_sum_exponential.py +2 -1
- cirq/ops/permutation_gate.py +2 -1
- cirq/ops/phased_iswap_gate.py +3 -2
- cirq/ops/phased_x_gate.py +5 -4
- cirq/ops/phased_x_z_gate.py +12 -5
- cirq/ops/projector.py +2 -1
- cirq/ops/qubit_manager.py +2 -1
- cirq/ops/qubit_order.py +2 -1
- cirq/ops/qubit_order_or_list.py +1 -1
- cirq/ops/random_gate_channel.py +3 -2
- cirq/ops/raw_types.py +7 -15
- cirq/ops/raw_types_test.py +4 -3
- cirq/ops/state_preparation_channel.py +2 -1
- cirq/ops/three_qubit_gates.py +3 -2
- cirq/ops/two_qubit_diagonal_gate.py +3 -2
- cirq/ops/uniform_superposition_gate.py +2 -1
- cirq/ops/wait_gate.py +10 -4
- cirq/protocols/act_on_protocol.py +2 -1
- cirq/protocols/act_on_protocol_test.py +2 -1
- cirq/protocols/apply_channel_protocol.py +2 -1
- cirq/protocols/apply_mixture_protocol.py +2 -1
- cirq/protocols/apply_mixture_protocol_test.py +2 -1
- cirq/protocols/apply_unitary_protocol.py +2 -1
- cirq/protocols/apply_unitary_protocol_test.py +2 -0
- cirq/protocols/approximate_equality_protocol.py +2 -1
- cirq/protocols/circuit_diagram_info_protocol.py +2 -1
- cirq/protocols/decompose_protocol.py +2 -12
- cirq/protocols/has_stabilizer_effect_protocol.py +1 -1
- cirq/protocols/hash_from_pickle_test.py +2 -2
- cirq/protocols/inverse_protocol.py +2 -1
- cirq/protocols/json_serialization.py +2 -1
- cirq/protocols/kraus_protocol.py +4 -3
- cirq/protocols/kraus_protocol_test.py +2 -2
- cirq/protocols/measurement_key_protocol.py +2 -1
- cirq/protocols/mixture_protocol.py +2 -1
- cirq/protocols/pow_protocol.py +2 -1
- cirq/protocols/qasm.py +2 -1
- cirq/protocols/qid_shape_protocol.py +2 -1
- cirq/protocols/resolve_parameters.py +16 -14
- cirq/protocols/trace_distance_bound.py +2 -1
- cirq/protocols/unitary_protocol.py +21 -21
- cirq/qis/channels.py +1 -1
- cirq/qis/channels_test.py +1 -1
- cirq/qis/clifford_tableau.py +2 -1
- cirq/qis/entropy.py +2 -2
- cirq/qis/quantum_state_representation.py +2 -1
- cirq/qis/states.py +7 -2
- cirq/sim/classical_simulator.py +2 -1
- cirq/sim/clifford/clifford_simulator.py +2 -1
- cirq/sim/clifford/clifford_simulator_test.py +1 -1
- cirq/sim/clifford/clifford_tableau_simulation_state.py +2 -1
- cirq/sim/clifford/stabilizer_ch_form_simulation_state.py +2 -1
- cirq/sim/clifford/stabilizer_sampler.py +1 -1
- cirq/sim/clifford/stabilizer_simulation_state.py +2 -1
- cirq/sim/clifford/stabilizer_state_ch_form.py +3 -2
- cirq/sim/clifford/stabilizer_state_ch_form_test.py +0 -1
- cirq/sim/density_matrix_simulation_state.py +2 -1
- cirq/sim/density_matrix_simulator.py +2 -1
- cirq/sim/density_matrix_utils.py +2 -1
- cirq/sim/mux.py +2 -1
- cirq/sim/mux_test.py +0 -1
- cirq/sim/simulation_product_state.py +2 -1
- cirq/sim/simulation_product_state_test.py +2 -1
- cirq/sim/simulation_state.py +2 -1
- cirq/sim/simulation_state_base.py +2 -1
- cirq/sim/simulation_state_test.py +2 -1
- cirq/sim/simulation_utils.py +2 -1
- cirq/sim/simulator.py +2 -1
- cirq/sim/simulator_base.py +2 -1
- cirq/sim/simulator_base_test.py +2 -1
- cirq/sim/simulator_test.py +2 -1
- cirq/sim/sparse_simulator.py +2 -1
- cirq/sim/state_vector.py +2 -1
- cirq/sim/state_vector_simulation_state.py +2 -1
- cirq/sim/state_vector_simulator.py +2 -1
- cirq/sim/state_vector_test.py +1 -2
- cirq/study/__init__.py +1 -0
- cirq/study/flatten_expressions.py +2 -1
- cirq/study/resolver.py +31 -18
- cirq/study/resolver_test.py +1 -1
- cirq/study/result.py +2 -1
- cirq/study/sweepable.py +2 -1
- cirq/study/sweeps.py +26 -1
- cirq/study/sweeps_test.py +24 -0
- cirq/testing/_compat_test_data/__init__.py +3 -3
- cirq/testing/circuit_compare.py +2 -1
- cirq/testing/consistent_act_on_test.py +1 -1
- cirq/testing/consistent_controlled_gate_op.py +1 -1
- cirq/testing/consistent_controlled_gate_op_test.py +2 -1
- cirq/testing/consistent_protocols.py +2 -1
- cirq/testing/consistent_protocols_test.py +3 -3
- cirq/testing/consistent_qasm.py +2 -1
- cirq/testing/consistent_resolve_parameters.py +1 -1
- cirq/testing/consistent_unitary.py +1 -1
- cirq/testing/consistent_unitary_test.py +1 -1
- cirq/testing/deprecation.py +1 -1
- cirq/testing/devices.py +3 -2
- cirq/testing/equals_tester.py +4 -3
- cirq/testing/equivalent_basis_map.py +4 -2
- cirq/testing/json.py +3 -2
- cirq/testing/logs.py +1 -1
- cirq/testing/op_tree.py +1 -1
- cirq/testing/order_tester.py +2 -2
- cirq/testing/pytest_utils.py +2 -1
- cirq/testing/random_circuit.py +2 -1
- cirq/testing/random_circuit_test.py +2 -1
- cirq/testing/repr_pretty_tester.py +3 -3
- cirq/transformers/__init__.py +1 -0
- cirq/transformers/_connected_component.py +231 -0
- cirq/transformers/_connected_component_test.py +200 -0
- cirq/transformers/align_test.py +13 -13
- cirq/transformers/analytical_decompositions/clifford_decomposition.py +8 -7
- cirq/transformers/analytical_decompositions/clifford_decomposition_test.py +5 -5
- cirq/transformers/analytical_decompositions/controlled_gate_decomposition.py +11 -10
- cirq/transformers/analytical_decompositions/controlled_gate_decomposition_test.py +6 -6
- cirq/transformers/analytical_decompositions/cphase_to_fsim.py +3 -2
- cirq/transformers/analytical_decompositions/cphase_to_fsim_test.py +11 -10
- cirq/transformers/analytical_decompositions/quantum_shannon_decomposition.py +8 -7
- cirq/transformers/analytical_decompositions/quantum_shannon_decomposition_test.py +17 -20
- cirq/transformers/analytical_decompositions/single_qubit_decompositions_test.py +33 -27
- cirq/transformers/analytical_decompositions/single_to_two_qubit_isometry_test.py +1 -1
- cirq/transformers/analytical_decompositions/three_qubit_decomposition.py +1 -1
- cirq/transformers/analytical_decompositions/two_qubit_state_preparation_test.py +12 -11
- cirq/transformers/analytical_decompositions/two_qubit_to_cz.py +5 -2
- cirq/transformers/analytical_decompositions/two_qubit_to_cz_test.py +3 -3
- cirq/transformers/analytical_decompositions/two_qubit_to_fsim.py +2 -1
- cirq/transformers/analytical_decompositions/two_qubit_to_ms.py +2 -1
- cirq/transformers/analytical_decompositions/two_qubit_to_ms_test.py +2 -2
- cirq/transformers/analytical_decompositions/two_qubit_to_sqrt_iswap.py +2 -1
- cirq/transformers/analytical_decompositions/two_qubit_to_sqrt_iswap_test.py +32 -30
- cirq/transformers/drop_negligible_operations_test.py +7 -7
- cirq/transformers/dynamical_decoupling.py +185 -112
- cirq/transformers/dynamical_decoupling_test.py +195 -201
- cirq/transformers/eject_phased_paulis.py +2 -1
- cirq/transformers/eject_phased_paulis_test.py +3 -2
- cirq/transformers/eject_z.py +4 -3
- cirq/transformers/eject_z_test.py +23 -25
- cirq/transformers/expand_composite.py +3 -2
- cirq/transformers/expand_composite_test.py +14 -14
- cirq/transformers/gauge_compiling/__init__.py +8 -0
- cirq/transformers/gauge_compiling/gauge_compiling.py +3 -2
- cirq/transformers/gauge_compiling/gauge_compiling_test.py +14 -12
- cirq/transformers/gauge_compiling/gauge_compiling_test_utils.py +3 -3
- cirq/transformers/gauge_compiling/idle_moments_gauge.py +5 -2
- cirq/transformers/gauge_compiling/multi_moment_cphase_gauge.py +242 -0
- cirq/transformers/gauge_compiling/multi_moment_cphase_gauge_test.py +243 -0
- cirq/transformers/gauge_compiling/multi_moment_gauge_compiling.py +151 -0
- cirq/transformers/gauge_compiling/sqrt_cz_gauge.py +2 -1
- cirq/transformers/heuristic_decompositions/gate_tabulation_math_utils.py +1 -1
- cirq/transformers/heuristic_decompositions/gate_tabulation_math_utils_test.py +6 -6
- cirq/transformers/heuristic_decompositions/two_qubit_gate_tabulation.py +2 -1
- cirq/transformers/measurement_transformers.py +2 -1
- cirq/transformers/measurement_transformers_test.py +45 -39
- cirq/transformers/merge_k_qubit_gates.py +2 -1
- cirq/transformers/merge_k_qubit_gates_test.py +1 -1
- cirq/transformers/merge_single_qubit_gates.py +2 -1
- cirq/transformers/merge_single_qubit_gates_test.py +22 -22
- cirq/transformers/noise_adding_test.py +2 -2
- cirq/transformers/optimize_for_target_gateset.py +2 -1
- cirq/transformers/optimize_for_target_gateset_test.py +11 -9
- cirq/transformers/qubit_management_transformers_test.py +6 -2
- cirq/transformers/routing/mapping_manager.py +2 -1
- cirq/transformers/routing/route_circuit_cqc.py +2 -1
- cirq/transformers/stratify.py +2 -1
- cirq/transformers/symbolize.py +2 -1
- cirq/transformers/tag_transformers.py +2 -1
- cirq/transformers/target_gatesets/compilation_target_gateset.py +2 -1
- cirq/transformers/target_gatesets/cz_gateset.py +2 -1
- cirq/transformers/target_gatesets/cz_gateset_test.py +1 -1
- cirq/transformers/target_gatesets/sqrt_iswap_gateset.py +2 -1
- cirq/transformers/transformer_api.py +2 -1
- cirq/transformers/transformer_primitives.py +271 -145
- cirq/transformers/transformer_primitives_test.py +185 -1
- cirq/value/abc_alt.py +2 -1
- cirq/value/classical_data.py +2 -1
- cirq/value/condition.py +2 -1
- cirq/value/digits.py +9 -2
- cirq/value/duration.py +6 -5
- cirq/value/linear_dict.py +4 -9
- cirq/value/measurement_key.py +2 -1
- cirq/value/periodic_value.py +3 -2
- cirq/value/product_state.py +2 -1
- cirq/value/value_equality_attr.py +2 -1
- cirq/vis/density_matrix.py +1 -1
- cirq/vis/heatmap.py +2 -1
- cirq/vis/histogram.py +2 -1
- cirq/vis/state_histogram.py +2 -1
- cirq/work/collector.py +2 -1
- cirq/work/observable_grouping.py +2 -1
- cirq/work/observable_measurement.py +2 -1
- cirq/work/observable_measurement_data.py +2 -1
- cirq/work/observable_measurement_test.py +1 -1
- cirq/work/observable_readout_calibration.py +2 -1
- cirq/work/observable_readout_calibration_test.py +1 -1
- cirq/work/observable_settings.py +2 -1
- cirq/work/sampler.py +2 -1
- cirq/work/sampler_test.py +1 -1
- {cirq_core-1.7.0.dev20250924231107.dist-info → cirq_core-1.7.0.dev20251203004401.dist-info}/METADATA +4 -4
- {cirq_core-1.7.0.dev20250924231107.dist-info → cirq_core-1.7.0.dev20251203004401.dist-info}/RECORD +391 -374
- cirq/contrib/json_test.py +0 -33
- {cirq_core-1.7.0.dev20250924231107.dist-info → cirq_core-1.7.0.dev20251203004401.dist-info}/WHEEL +0 -0
- {cirq_core-1.7.0.dev20250924231107.dist-info → cirq_core-1.7.0.dev20251203004401.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.7.0.dev20250924231107.dist-info → cirq_core-1.7.0.dev20251203004401.dist-info}/top_level.txt +0 -0
cirq/qis/channels_test.py
CHANGED
cirq/qis/clifford_tableau.py
CHANGED
cirq/qis/entropy.py
CHANGED
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from collections.abc import Sequence
|
|
17
|
+
from collections.abc import Iterator, Sequence
|
|
18
18
|
from concurrent.futures import ThreadPoolExecutor
|
|
19
19
|
from itertools import product
|
|
20
|
-
from typing import Any, cast
|
|
20
|
+
from typing import Any, cast
|
|
21
21
|
|
|
22
22
|
import numpy as np
|
|
23
23
|
import numpy.typing as npt
|
cirq/qis/states.py
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
19
|
import itertools
|
|
20
|
-
from
|
|
20
|
+
from collections.abc import Iterable, Sequence
|
|
21
|
+
from typing import Any, cast, TYPE_CHECKING, Union
|
|
21
22
|
|
|
22
23
|
import numpy as np
|
|
23
24
|
|
|
@@ -1019,7 +1020,11 @@ def validate_density_matrix(
|
|
|
1019
1020
|
if not np.isclose(trace, 1.0, atol=atol):
|
|
1020
1021
|
raise ValueError(f'Density matrix does not have trace 1. Instead, it has trace {trace}.')
|
|
1021
1022
|
if not np.all(np.linalg.eigvalsh(density_matrix) > -atol):
|
|
1022
|
-
raise ValueError(
|
|
1023
|
+
raise ValueError(
|
|
1024
|
+
'The density matrix is not positive semidefinite. '
|
|
1025
|
+
'This may happen for simulations using lower-precision `dtype` such as '
|
|
1026
|
+
'`np.complex64`. Try using `np.complex128` in such a case.'
|
|
1027
|
+
)
|
|
1023
1028
|
|
|
1024
1029
|
|
|
1025
1030
|
def _qid_shape_from_args(
|
cirq/sim/classical_simulator.py
CHANGED
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
+
from collections.abc import Sequence
|
|
17
18
|
from copy import copy, deepcopy
|
|
18
|
-
from typing import Any, Generic,
|
|
19
|
+
from typing import Any, Generic, TYPE_CHECKING
|
|
19
20
|
|
|
20
21
|
import numpy as np
|
|
21
22
|
|
|
@@ -470,7 +470,7 @@ def test_swap() -> None:
|
|
|
470
470
|
assert r["b"][0]
|
|
471
471
|
|
|
472
472
|
with pytest.raises(TypeError, match="CliffordSimulator doesn't support"):
|
|
473
|
-
cirq.CliffordSimulator().simulate(
|
|
473
|
+
cirq.CliffordSimulator().simulate(cirq.Circuit(cirq.SWAP(a, b) ** 3.5))
|
|
474
474
|
|
|
475
475
|
|
|
476
476
|
def test_sample_seed() -> None:
|
|
@@ -17,7 +17,8 @@ for Clifford Simulator."""
|
|
|
17
17
|
|
|
18
18
|
from __future__ import annotations
|
|
19
19
|
|
|
20
|
-
from
|
|
20
|
+
from collections.abc import Sequence
|
|
21
|
+
from typing import TYPE_CHECKING
|
|
21
22
|
|
|
22
23
|
from cirq.qis import clifford_tableau
|
|
23
24
|
from cirq.sim.clifford.stabilizer_simulation_state import StabilizerSimulationState
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from
|
|
17
|
+
from collections.abc import Sequence
|
|
18
|
+
from typing import TYPE_CHECKING
|
|
18
19
|
|
|
19
20
|
from cirq._compat import proper_repr
|
|
20
21
|
from cirq.sim.clifford import stabilizer_state_ch_form
|
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
import abc
|
|
18
|
+
from collections.abc import Sequence
|
|
18
19
|
from types import NotImplementedType
|
|
19
|
-
from typing import Any, cast, Generic,
|
|
20
|
+
from typing import Any, cast, Generic, TYPE_CHECKING, TypeVar
|
|
20
21
|
|
|
21
22
|
import sympy
|
|
22
23
|
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from
|
|
17
|
+
from collections.abc import Sequence
|
|
18
|
+
from typing import Any
|
|
18
19
|
|
|
19
20
|
import numpy as np
|
|
20
21
|
|
|
@@ -214,7 +215,7 @@ class StabilizerStateChForm(qis.StabilizerState):
|
|
|
214
215
|
omega = (1j) ** (delta * int(y))
|
|
215
216
|
|
|
216
217
|
delta2 = ((-1) ** y * delta) % 4
|
|
217
|
-
c = bool(
|
|
218
|
+
c = bool(delta2 >> 1)
|
|
218
219
|
a = bool(delta2 & 1)
|
|
219
220
|
b = True
|
|
220
221
|
else:
|
cirq/sim/density_matrix_utils.py
CHANGED
cirq/sim/mux.py
CHANGED
cirq/sim/mux_test.py
CHANGED
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
from collections import abc
|
|
18
|
-
from
|
|
18
|
+
from collections.abc import Iterator, Mapping, Sequence
|
|
19
|
+
from typing import Any, Generic, TYPE_CHECKING
|
|
19
20
|
|
|
20
21
|
import numpy as np
|
|
21
22
|
|
cirq/sim/simulation_state.py
CHANGED
|
@@ -18,7 +18,8 @@ from __future__ import annotations
|
|
|
18
18
|
|
|
19
19
|
import abc
|
|
20
20
|
import copy
|
|
21
|
-
from
|
|
21
|
+
from collections.abc import Iterator, Sequence
|
|
22
|
+
from typing import Any, cast, Generic, Self, TYPE_CHECKING, TypeVar
|
|
22
23
|
|
|
23
24
|
import numpy as np
|
|
24
25
|
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
19
|
import abc
|
|
20
|
+
from collections.abc import Iterator, Mapping, Sequence
|
|
20
21
|
from types import NotImplementedType
|
|
21
|
-
from typing import Any, Generic,
|
|
22
|
+
from typing import Any, Generic, Self, TYPE_CHECKING, TypeVar
|
|
22
23
|
|
|
23
24
|
from cirq import protocols, value
|
|
24
25
|
|
cirq/sim/simulation_utils.py
CHANGED
cirq/sim/simulator.py
CHANGED
|
@@ -31,7 +31,8 @@ from __future__ import annotations
|
|
|
31
31
|
|
|
32
32
|
import abc
|
|
33
33
|
import collections
|
|
34
|
-
from
|
|
34
|
+
from collections.abc import Callable, Iterator, Mapping, Sequence
|
|
35
|
+
from typing import Any, cast, Generic, TYPE_CHECKING, TypeVar
|
|
35
36
|
|
|
36
37
|
import numpy as np
|
|
37
38
|
|
cirq/sim/simulator_base.py
CHANGED
|
@@ -18,7 +18,8 @@ from __future__ import annotations
|
|
|
18
18
|
|
|
19
19
|
import abc
|
|
20
20
|
import collections
|
|
21
|
-
from
|
|
21
|
+
from collections.abc import Iterator, Sequence
|
|
22
|
+
from typing import Any, cast, Generic, TYPE_CHECKING, TypeVar
|
|
22
23
|
|
|
23
24
|
import numpy as np
|
|
24
25
|
|
cirq/sim/simulator_base_test.py
CHANGED
cirq/sim/simulator_test.py
CHANGED
cirq/sim/sparse_simulator.py
CHANGED
cirq/sim/state_vector.py
CHANGED
|
@@ -18,8 +18,9 @@ from __future__ import annotations
|
|
|
18
18
|
|
|
19
19
|
import abc
|
|
20
20
|
import warnings
|
|
21
|
+
from collections.abc import Iterator, Sequence
|
|
21
22
|
from functools import cached_property
|
|
22
|
-
from typing import Any, Generic,
|
|
23
|
+
from typing import Any, Generic, TYPE_CHECKING, TypeVar
|
|
23
24
|
|
|
24
25
|
import numpy as np
|
|
25
26
|
|
cirq/sim/state_vector_test.py
CHANGED
|
@@ -17,14 +17,13 @@
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
19
|
import itertools
|
|
20
|
-
from
|
|
20
|
+
from collections.abc import Iterator
|
|
21
21
|
from unittest import mock
|
|
22
22
|
|
|
23
23
|
import numpy as np
|
|
24
24
|
import pytest
|
|
25
25
|
|
|
26
26
|
import cirq
|
|
27
|
-
import cirq.testing
|
|
28
27
|
from cirq import linalg
|
|
29
28
|
|
|
30
29
|
|
cirq/study/__init__.py
CHANGED
cirq/study/resolver.py
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
19
|
import numbers
|
|
20
|
-
from
|
|
20
|
+
from collections.abc import Iterator, Mapping
|
|
21
|
+
from typing import Any, cast, TYPE_CHECKING, Union
|
|
21
22
|
|
|
22
23
|
import numpy as np
|
|
23
24
|
import sympy
|
|
@@ -75,9 +76,20 @@ class ParamResolver:
|
|
|
75
76
|
|
|
76
77
|
self._param_hash: int | None = None
|
|
77
78
|
self._param_dict = cast(ParamDictType, {} if param_dict is None else param_dict)
|
|
79
|
+
self._param_dict_with_str_keys = self._param_dict
|
|
80
|
+
generate_str_keys = False
|
|
78
81
|
for key in self._param_dict:
|
|
79
|
-
if isinstance(key, sympy.Expr)
|
|
80
|
-
|
|
82
|
+
if isinstance(key, sympy.Expr):
|
|
83
|
+
if isinstance(key, sympy.Symbol):
|
|
84
|
+
generate_str_keys = True
|
|
85
|
+
else:
|
|
86
|
+
raise TypeError(f'ParamResolver keys cannot be (non-symbol) formulas ({key})')
|
|
87
|
+
if generate_str_keys:
|
|
88
|
+
# Remake dictionary with string keys for faster access
|
|
89
|
+
self._param_dict_with_str_keys = {
|
|
90
|
+
(key.name if isinstance(key, sympy.Symbol) else key): value
|
|
91
|
+
for key, value in self._param_dict.items()
|
|
92
|
+
}
|
|
81
93
|
self._deep_eval_map: ParamDictType = {}
|
|
82
94
|
|
|
83
95
|
@property
|
|
@@ -118,32 +130,33 @@ class ParamResolver:
|
|
|
118
130
|
sympy.SympifyError: If the resulting value cannot be interpreted.
|
|
119
131
|
"""
|
|
120
132
|
|
|
121
|
-
# Input is a pass through type, no resolution needed: return early
|
|
122
|
-
v = _resolve_value(value)
|
|
123
|
-
if v is not NotImplemented:
|
|
124
|
-
return v
|
|
125
|
-
|
|
126
133
|
# Handle string or symbol
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
134
|
+
original_value = value
|
|
135
|
+
if isinstance(value, sympy.Symbol):
|
|
136
|
+
value = value.name
|
|
137
|
+
if isinstance(value, str):
|
|
138
|
+
param_value = self._param_dict_with_str_keys.get(value, _NOT_FOUND)
|
|
139
|
+
if isinstance(param_value, float):
|
|
140
|
+
return param_value
|
|
133
141
|
if param_value is _NOT_FOUND:
|
|
134
142
|
# Symbol or string cannot be resolved if not in param dict; return as symbol.
|
|
135
|
-
return
|
|
143
|
+
return sympy.Symbol(value)
|
|
136
144
|
v = _resolve_value(param_value)
|
|
137
145
|
if v is not NotImplemented:
|
|
138
146
|
return v
|
|
139
147
|
if isinstance(param_value, str):
|
|
140
148
|
param_value = sympy.Symbol(param_value)
|
|
141
149
|
elif not isinstance(param_value, sympy.Basic):
|
|
142
|
-
return
|
|
150
|
+
return original_value
|
|
143
151
|
if recursive:
|
|
144
152
|
param_value = self._value_of_recursive(value)
|
|
145
153
|
return param_value
|
|
146
154
|
|
|
155
|
+
# Input is a pass through type, no resolution needed: return early
|
|
156
|
+
v = _resolve_value(value)
|
|
157
|
+
if v is not NotImplemented:
|
|
158
|
+
return v
|
|
159
|
+
|
|
147
160
|
if not isinstance(value, sympy.Basic):
|
|
148
161
|
# No known way to resolve this variable, return unchanged.
|
|
149
162
|
return value
|
|
@@ -210,7 +223,7 @@ class ParamResolver:
|
|
|
210
223
|
self._deep_eval_map[value] = _RECURSION_FLAG
|
|
211
224
|
|
|
212
225
|
v = self.value_of(value, recursive=False)
|
|
213
|
-
if v == value:
|
|
226
|
+
if v == value or (isinstance(v, sympy.Symbol) and v.name == value):
|
|
214
227
|
self._deep_eval_map[value] = v
|
|
215
228
|
else:
|
|
216
229
|
self._deep_eval_map[value] = self.value_of(v, recursive=True)
|
|
@@ -278,7 +291,7 @@ class ParamResolver:
|
|
|
278
291
|
|
|
279
292
|
|
|
280
293
|
def _resolve_value(val: Any) -> Any:
|
|
281
|
-
if val is None:
|
|
294
|
+
if isinstance(val, float) or val is None:
|
|
282
295
|
return val
|
|
283
296
|
if isinstance(val, numbers.Number) and not isinstance(val, sympy.Basic):
|
|
284
297
|
return val
|
cirq/study/resolver_test.py
CHANGED
cirq/study/result.py
CHANGED
|
@@ -19,7 +19,8 @@ from __future__ import annotations
|
|
|
19
19
|
import abc
|
|
20
20
|
import collections
|
|
21
21
|
import io
|
|
22
|
-
from
|
|
22
|
+
from collections.abc import Callable, Iterable, Mapping, Sequence
|
|
23
|
+
from typing import Any, cast, TYPE_CHECKING, TypeVar, Union
|
|
23
24
|
|
|
24
25
|
import numpy as np
|
|
25
26
|
import pandas as pd
|
cirq/study/sweepable.py
CHANGED
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
19
|
import warnings
|
|
20
|
-
from
|
|
20
|
+
from collections.abc import Iterable, Iterator, Sequence
|
|
21
|
+
from typing import cast, Protocol
|
|
21
22
|
|
|
22
23
|
from cirq._doc import document
|
|
23
24
|
from cirq.study.resolver import ParamResolver, ParamResolverOrSimilarType
|
cirq/study/sweeps.py
CHANGED
|
@@ -17,7 +17,8 @@ from __future__ import annotations
|
|
|
17
17
|
import abc
|
|
18
18
|
import collections
|
|
19
19
|
import itertools
|
|
20
|
-
from
|
|
20
|
+
from collections.abc import Iterable, Iterator, Mapping, Sequence
|
|
21
|
+
from typing import Any, cast, overload, TYPE_CHECKING, Union
|
|
21
22
|
|
|
22
23
|
import sympy
|
|
23
24
|
|
|
@@ -653,3 +654,27 @@ def dict_to_zip_sweep(factor_dict: ProductOrZipSweepLike) -> Zip:
|
|
|
653
654
|
for k, v in factor_dict.items()
|
|
654
655
|
)
|
|
655
656
|
)
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
def list_of_dicts_to_zip(params: Sequence[Mapping[str, float]]) -> cirq.Zip:
|
|
660
|
+
"""Converts a list of dictionaries into a cirq.Zip of cirq.Points.
|
|
661
|
+
|
|
662
|
+
This will convert lists of dictionaries into a more compact
|
|
663
|
+
Sweep format. For large sweeps, this can vastly improve performance.
|
|
664
|
+
|
|
665
|
+
This will change [{'a': 1.0, 'b': 2.0}, {'a': 3.0, 'b': 4.0}]
|
|
666
|
+
into cirq.Zip(cirq.Points('a', [1.0, 3.0]), cirq.Points('b', [2.0, 4.0])_)
|
|
667
|
+
|
|
668
|
+
Raises:
|
|
669
|
+
ValueError if the keys in any of the list items are not the same.
|
|
670
|
+
"""
|
|
671
|
+
param_keys: dict[str, list[float]] = collections.defaultdict(list)
|
|
672
|
+
if len(params) < 1:
|
|
673
|
+
raise ValueError("Input dictionary to convert is empty.")
|
|
674
|
+
sweep_keys = params[0].keys()
|
|
675
|
+
for sweep_point in params:
|
|
676
|
+
if set(sweep_point.keys()) != sweep_keys:
|
|
677
|
+
raise ValueError("Keys must be the same in each sweep point.")
|
|
678
|
+
for key, value in sweep_point.items():
|
|
679
|
+
param_keys[key].append(value)
|
|
680
|
+
return Zip(*(Points(key, points) for key, points in param_keys.items()))
|
cirq/study/sweeps_test.py
CHANGED
|
@@ -529,3 +529,27 @@ def test_concat_different_keys_raises() -> None:
|
|
|
529
529
|
def test_concat_empty_sweep_raises() -> None:
|
|
530
530
|
with pytest.raises(ValueError, match="Concat requires at least one sweep."):
|
|
531
531
|
_ = cirq.Concat()
|
|
532
|
+
|
|
533
|
+
|
|
534
|
+
def test_list_of_dicts_to_zip_empty() -> None:
|
|
535
|
+
with pytest.raises(ValueError, match="empty"):
|
|
536
|
+
cirq.list_of_dicts_to_zip([])
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
def test_list_of_dicts_to_zip_mismatched_keys() -> None:
|
|
540
|
+
with pytest.raises(ValueError, match="Keys must be the same"):
|
|
541
|
+
cirq.list_of_dicts_to_zip([{'a': 4.0}, {'a': 2.0, 'b': 1.0}])
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
def test_list_of_dicts_to_zip() -> None:
|
|
545
|
+
param_dict = [
|
|
546
|
+
{'a': 1.0, 'b': 2.0, 'c': 10.0},
|
|
547
|
+
{'a': 2.0, 'b': 4.0, 'c': 9.0},
|
|
548
|
+
{'a': 3.0, 'b': 8.0, 'c': 8.0},
|
|
549
|
+
]
|
|
550
|
+
param_zip = cirq.Zip(
|
|
551
|
+
cirq.Points('a', [1.0, 2.0, 3.0]),
|
|
552
|
+
cirq.Points('b', [2.0, 4.0, 8.0]),
|
|
553
|
+
cirq.Points('c', [10.0, 9.0, 8.0]),
|
|
554
|
+
)
|
|
555
|
+
assert cirq.list_of_dicts_to_zip(param_dict) == param_zip
|
|
@@ -64,11 +64,11 @@ _compat.deprecated_submodule(
|
|
|
64
64
|
|
|
65
65
|
# simulates a move of child module to a top level module.
|
|
66
66
|
# this will be the case with cirq.google -> cirq_google
|
|
67
|
-
#
|
|
67
|
+
# fake_numpy -> numpy
|
|
68
68
|
_compat.deprecated_submodule(
|
|
69
|
-
new_module_name="
|
|
69
|
+
new_module_name="numpy",
|
|
70
70
|
old_parent=__name__,
|
|
71
|
-
old_child="
|
|
71
|
+
old_child="fake_numpy",
|
|
72
72
|
deadline="v0.20",
|
|
73
73
|
create_attribute=False,
|
|
74
74
|
)
|
cirq/testing/circuit_compare.py
CHANGED
|
@@ -17,7 +17,8 @@ from __future__ import annotations
|
|
|
17
17
|
import itertools
|
|
18
18
|
import random
|
|
19
19
|
from collections import defaultdict
|
|
20
|
-
from
|
|
20
|
+
from collections.abc import Iterable, Sequence
|
|
21
|
+
from typing import Any
|
|
21
22
|
|
|
22
23
|
import numpy as np
|
|
23
24
|
import sympy
|