cirq-core 1.7.0.dev20250825174419__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 +19 -17
- cirq/circuits/circuit_operation.py +2 -1
- cirq/circuits/circuit_operation_test.py +19 -0
- cirq/circuits/circuit_test.py +31 -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 +81 -178
- cirq/contrib/paulistring/recombine.py +5 -2
- cirq/contrib/paulistring/separate.py +1 -1
- cirq/contrib/qasm_import/_lexer.py +6 -1
- cirq/contrib/qasm_import/_lexer_test.py +1 -1
- cirq/contrib/qasm_import/_parser.py +24 -8
- cirq/contrib/qasm_import/_parser_test.py +44 -6
- cirq/contrib/qcircuit/qcircuit_pdf_test.py +6 -9
- 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 +33 -4
- cirq/experiments/qubit_characterizations_test.py +16 -0
- 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 +3 -2
- cirq/ops/arithmetic_operation.py +4 -3
- cirq/ops/arithmetic_operation_test.py +1 -1
- cirq/ops/boolean_hamiltonian.py +4 -3
- cirq/ops/classically_controlled_operation.py +11 -11
- cirq/ops/classically_controlled_operation_test.py +26 -2
- cirq/ops/clifford_gate.py +3 -2
- cirq/ops/clifford_gate_test.py +1 -2
- cirq/ops/common_channels.py +2 -1
- cirq/ops/common_gates.py +3 -2
- 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 +44 -81
- cirq/ops/dense_pauli_string_test.py +21 -0
- 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 +23 -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 +12 -17
- cirq/ops/linear_combinations_test.py +23 -1
- cirq/ops/matrix_gates.py +2 -1
- cirq/ops/measure_util.py +8 -6
- 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/parity_gates_test.py +35 -0
- cirq/ops/pauli_interaction_gate.py +2 -1
- cirq/ops/pauli_measurement_gate.py +2 -1
- cirq/ops/pauli_string.py +37 -57
- cirq/ops/pauli_string_phasor.py +6 -5
- cirq/ops/pauli_string_raw_types.py +2 -1
- cirq/ops/pauli_string_test.py +49 -6
- 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 +33 -16
- 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/control_key_protocol.py +7 -0
- cirq/protocols/decompose_protocol.py +2 -12
- cirq/protocols/has_stabilizer_effect_protocol.py +1 -1
- cirq/protocols/has_stabilizer_effect_protocol_test.py +11 -9
- cirq/protocols/has_unitary_protocol_test.py +3 -3
- cirq/protocols/hash_from_pickle_test.py +2 -2
- cirq/protocols/inverse_protocol.py +2 -1
- cirq/protocols/json_serialization.py +5 -4
- cirq/protocols/json_serialization_test.py +31 -31
- cirq/protocols/kraus_protocol.py +4 -3
- cirq/protocols/kraus_protocol_test.py +7 -7
- cirq/protocols/measurement_key_protocol.py +32 -8
- cirq/protocols/mixture_protocol.py +3 -2
- cirq/protocols/mixture_protocol_test.py +7 -7
- cirq/protocols/mul_protocol_test.py +4 -4
- cirq/protocols/phase_protocol.py +13 -4
- cirq/protocols/pow_protocol.py +2 -1
- cirq/protocols/pow_protocol_test.py +5 -5
- cirq/protocols/qasm.py +2 -1
- cirq/protocols/qid_shape_protocol.py +2 -1
- cirq/protocols/resolve_parameters.py +17 -15
- cirq/protocols/trace_distance_bound.py +2 -1
- cirq/protocols/unitary_protocol.py +21 -21
- cirq/protocols/unitary_protocol_test.py +31 -19
- cirq/qis/channels.py +1 -1
- cirq/qis/channels_test.py +1 -1
- cirq/qis/clifford_tableau.py +16 -15
- cirq/qis/clifford_tableau_test.py +17 -17
- cirq/qis/entropy.py +3 -3
- cirq/qis/entropy_test.py +1 -1
- cirq/qis/quantum_state_representation.py +2 -1
- cirq/qis/states.py +7 -2
- cirq/qis/states_test.py +54 -54
- cirq/sim/classical_simulator.py +25 -14
- cirq/sim/classical_simulator_test.py +85 -30
- cirq/sim/clifford/clifford_simulator.py +7 -6
- cirq/sim/clifford/clifford_simulator_test.py +51 -50
- 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 +16 -15
- cirq/sim/clifford/stabilizer_state_ch_form_test.py +0 -1
- cirq/sim/density_matrix_simulation_state.py +7 -6
- cirq/sim/density_matrix_simulator.py +3 -2
- cirq/sim/density_matrix_simulator_test.py +94 -84
- cirq/sim/density_matrix_utils.py +2 -1
- cirq/sim/density_matrix_utils_test.py +1 -1
- cirq/sim/mux.py +35 -8
- cirq/sim/mux_test.py +39 -26
- cirq/sim/simulation_product_state.py +2 -1
- cirq/sim/simulation_product_state_test.py +8 -7
- cirq/sim/simulation_state.py +6 -5
- cirq/sim/simulation_state_base.py +3 -2
- cirq/sim/simulation_state_test.py +7 -6
- cirq/sim/simulation_utils.py +2 -1
- cirq/sim/simulator.py +4 -3
- cirq/sim/simulator_base.py +2 -1
- cirq/sim/simulator_base_test.py +51 -36
- cirq/sim/simulator_test.py +41 -36
- cirq/sim/sparse_simulator.py +3 -2
- cirq/sim/sparse_simulator_test.py +92 -82
- cirq/sim/state_vector.py +5 -6
- cirq/sim/state_vector_simulation_state.py +10 -9
- cirq/sim/state_vector_simulator.py +2 -1
- cirq/sim/state_vector_simulator_test.py +9 -9
- cirq/sim/state_vector_test.py +40 -39
- 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/result_test.py +20 -20
- cirq/study/sweepable.py +2 -1
- cirq/study/sweepable_test.py +20 -20
- cirq/study/sweeps.py +26 -1
- cirq/study/sweeps_test.py +67 -43
- cirq/testing/_compat_test_data/__init__.py +3 -3
- cirq/testing/circuit_compare.py +2 -1
- cirq/testing/circuit_compare_test.py +16 -14
- cirq/testing/consistent_act_on_test.py +1 -1
- cirq/testing/consistent_channels.py +2 -2
- cirq/testing/consistent_controlled_gate_op.py +2 -2
- cirq/testing/consistent_controlled_gate_op_test.py +2 -1
- cirq/testing/consistent_decomposition.py +4 -2
- cirq/testing/consistent_phase_by.py +1 -1
- cirq/testing/consistent_protocols.py +2 -1
- cirq/testing/consistent_protocols_test.py +3 -3
- cirq/testing/consistent_qasm.py +4 -3
- cirq/testing/consistent_qasm_test.py +3 -3
- 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/lin_alg_utils.py +1 -1
- 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 +5 -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 +13 -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 +225 -0
- cirq/transformers/gauge_compiling/idle_moments_gauge_test.py +193 -0
- 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 +3 -2
- 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 +9 -5
- 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.dev20250825174419.dist-info → cirq_core-1.7.0.dev20251203004401.dist-info}/METADATA +5 -6
- {cirq_core-1.7.0.dev20250825174419.dist-info → cirq_core-1.7.0.dev20251203004401.dist-info}/RECORD +425 -406
- cirq/contrib/json_test.py +0 -33
- {cirq_core-1.7.0.dev20250825174419.dist-info → cirq_core-1.7.0.dev20251203004401.dist-info}/WHEEL +0 -0
- {cirq_core-1.7.0.dev20250825174419.dist-info → cirq_core-1.7.0.dev20251203004401.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.7.0.dev20250825174419.dist-info → cirq_core-1.7.0.dev20251203004401.dist-info}/top_level.txt +0 -0
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
+
import multiprocessing
|
|
18
|
+
from collections.abc import Iterator
|
|
19
|
+
|
|
17
20
|
import numpy as np
|
|
18
21
|
import pandas as pd
|
|
19
22
|
import pytest
|
|
@@ -31,6 +34,15 @@ _ANGLES = ['theta', 'phi', 'chi', 'zeta', 'gamma']
|
|
|
31
34
|
# fix random generator seed to ensure reproducibility and faster convergence
|
|
32
35
|
_SEED = 276154030
|
|
33
36
|
|
|
37
|
+
_POOL_NUM_PROCESSES = min(4, multiprocessing.cpu_count())
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@pytest.fixture
|
|
41
|
+
def pool() -> Iterator[multiprocessing.pool.Pool]:
|
|
42
|
+
ctx = multiprocessing.get_context()
|
|
43
|
+
with ctx.Pool(_POOL_NUM_PROCESSES) as pool:
|
|
44
|
+
yield pool
|
|
45
|
+
|
|
34
46
|
|
|
35
47
|
def _create_tests(n, with_options: bool = False):
|
|
36
48
|
rng = np.random.default_rng(_SEED)
|
|
@@ -88,7 +100,7 @@ class _TestSimulator(cirq.Simulator):
|
|
|
88
100
|
@pytest.mark.parametrize(
|
|
89
101
|
['angles', 'error', 'characterization_flags'], _create_tests(n=10, with_options=True)
|
|
90
102
|
)
|
|
91
|
-
def test_calibrate_z_phases(angles, error, characterization_flags) -> None:
|
|
103
|
+
def test_calibrate_z_phases(pool, angles, error, characterization_flags) -> None:
|
|
92
104
|
|
|
93
105
|
original_gate = cirq.PhasedFSimGate(**{k: v for k, v in zip(_ANGLES, angles)})
|
|
94
106
|
actual_gate = cirq.PhasedFSimGate(**{k: v + e for k, v, e in zip(_ANGLES, angles, error)})
|
|
@@ -109,6 +121,7 @@ def test_calibrate_z_phases(angles, error, characterization_flags) -> None:
|
|
|
109
121
|
n_circuits=10,
|
|
110
122
|
cycle_depths=range(3, 10),
|
|
111
123
|
random_state=_SEED,
|
|
124
|
+
num_workers_or_pool=pool,
|
|
112
125
|
)[qubits]
|
|
113
126
|
|
|
114
127
|
initial_unitary = cirq.unitary(original_gate)
|
|
@@ -127,7 +140,7 @@ def test_calibrate_z_phases(angles, error, characterization_flags) -> None:
|
|
|
127
140
|
|
|
128
141
|
|
|
129
142
|
@pytest.mark.parametrize(['angles', 'error'], _create_tests(n=3))
|
|
130
|
-
def test_calibrate_z_phases_no_options(angles, error) -> None:
|
|
143
|
+
def test_calibrate_z_phases_no_options(pool, angles, error) -> None:
|
|
131
144
|
|
|
132
145
|
original_gate = cirq.PhasedFSimGate(**{k: v for k, v in zip(_ANGLES, angles)})
|
|
133
146
|
actual_gate = cirq.PhasedFSimGate(**{k: v + e for k, v, e in zip(_ANGLES, angles, error)})
|
|
@@ -144,6 +157,7 @@ def test_calibrate_z_phases_no_options(angles, error) -> None:
|
|
|
144
157
|
n_circuits=10,
|
|
145
158
|
cycle_depths=range(3, 10),
|
|
146
159
|
random_state=_SEED,
|
|
160
|
+
num_workers_or_pool=pool,
|
|
147
161
|
)[qubits]
|
|
148
162
|
|
|
149
163
|
initial_unitary = cirq.unitary(original_gate)
|
|
@@ -162,7 +176,7 @@ def test_calibrate_z_phases_no_options(angles, error) -> None:
|
|
|
162
176
|
|
|
163
177
|
|
|
164
178
|
@pytest.mark.parametrize(['angles', 'error'], _create_tests(n=3))
|
|
165
|
-
def test_calibrate_z_phases_workflow_no_options(angles, error) -> None:
|
|
179
|
+
def test_calibrate_z_phases_workflow_no_options(pool, angles, error) -> None:
|
|
166
180
|
|
|
167
181
|
original_gate = cirq.PhasedFSimGate(**{k: v for k, v in zip(_ANGLES, angles)})
|
|
168
182
|
actual_gate = cirq.PhasedFSimGate(**{k: v + e for k, v, e in zip(_ANGLES, angles, error)})
|
|
@@ -179,6 +193,7 @@ def test_calibrate_z_phases_workflow_no_options(angles, error) -> None:
|
|
|
179
193
|
n_circuits=1,
|
|
180
194
|
cycle_depths=(1, 2),
|
|
181
195
|
random_state=_SEED,
|
|
196
|
+
num_workers_or_pool=pool,
|
|
182
197
|
)
|
|
183
198
|
|
|
184
199
|
for params in result.final_params.values():
|
|
@@ -36,5 +36,4 @@ from cirq.interop.quirk.cells.input_rotation_cells import (
|
|
|
36
36
|
QuirkInputRotationOperation as QuirkInputRotationOperation,
|
|
37
37
|
)
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
import cirq.interop.quirk.cells.control_cells # noqa: F401
|
|
39
|
+
from cirq.interop.quirk.cells import control_cells as control_cells, swap_cell as swap_cell
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from
|
|
17
|
+
from collections.abc import Iterator
|
|
18
|
+
from typing import TYPE_CHECKING
|
|
18
19
|
|
|
19
20
|
from cirq.interop.quirk.cells.arithmetic_cells import generate_all_arithmetic_cell_makers
|
|
20
21
|
from cirq.interop.quirk.cells.control_cells import generate_all_control_cell_makers
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
import inspect
|
|
18
|
-
from
|
|
18
|
+
from collections.abc import Callable, Iterable, Iterator, Sequence
|
|
19
|
+
from typing import Any, cast, TYPE_CHECKING
|
|
19
20
|
|
|
20
21
|
from cirq import ops, value
|
|
21
22
|
from cirq.interop.quirk.cells.cell import Cell, CELL_SIZES, CellMaker
|
cirq/interop/quirk/cells/cell.py
CHANGED
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
import abc
|
|
18
|
-
from
|
|
18
|
+
from collections.abc import Callable, Iterable, Sequence
|
|
19
|
+
from typing import Any, NamedTuple, TYPE_CHECKING, Union
|
|
19
20
|
|
|
20
21
|
from cirq import devices, ops, value
|
|
21
22
|
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from
|
|
17
|
+
from collections.abc import Callable, Iterable, Iterator, Sequence
|
|
18
|
+
from typing import cast, TYPE_CHECKING, TypeVar
|
|
18
19
|
|
|
19
20
|
from cirq import circuits
|
|
20
21
|
from cirq.interop.quirk.cells.cell import Cell
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from
|
|
17
|
+
from collections.abc import Iterable, Iterator
|
|
18
|
+
from typing import Any, TYPE_CHECKING
|
|
18
19
|
|
|
19
20
|
from cirq import ops, value
|
|
20
21
|
from cirq.interop.quirk.cells.cell import Cell, CellMaker
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from
|
|
17
|
+
from collections.abc import Callable, Iterable, Iterator
|
|
18
|
+
from typing import TYPE_CHECKING
|
|
18
19
|
|
|
19
20
|
from cirq.interop.quirk.cells.cell import Cell, CELL_SIZES, CellMaker
|
|
20
21
|
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from
|
|
17
|
+
from collections.abc import Iterable, Iterator
|
|
18
|
+
from typing import cast, TYPE_CHECKING
|
|
18
19
|
|
|
19
20
|
from cirq import ops
|
|
20
21
|
from cirq.interop.quirk.cells.cell import CellMaker, ExplicitOperationsCell
|
|
@@ -16,17 +16,8 @@ from __future__ import annotations
|
|
|
16
16
|
|
|
17
17
|
import cmath
|
|
18
18
|
import re
|
|
19
|
-
from
|
|
20
|
-
|
|
21
|
-
Callable,
|
|
22
|
-
cast,
|
|
23
|
-
Iterable,
|
|
24
|
-
Iterator,
|
|
25
|
-
Mapping,
|
|
26
|
-
SupportsFloat,
|
|
27
|
-
TypeAlias,
|
|
28
|
-
TypeVar,
|
|
29
|
-
)
|
|
19
|
+
from collections.abc import Callable, Iterable, Iterator, Mapping
|
|
20
|
+
from typing import Any, cast, SupportsFloat, TypeAlias, TypeVar
|
|
30
21
|
|
|
31
22
|
import numpy as np
|
|
32
23
|
import sympy
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from
|
|
17
|
+
from collections.abc import Callable, Iterator, Sequence
|
|
18
|
+
from typing import TYPE_CHECKING
|
|
18
19
|
|
|
19
20
|
from cirq import ops, value
|
|
20
21
|
from cirq.interop.quirk.cells.cell import CELL_SIZES, CellMaker
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from
|
|
17
|
+
from collections.abc import Iterable, Iterator
|
|
18
|
+
from typing import Any, TYPE_CHECKING
|
|
18
19
|
|
|
19
20
|
from cirq import ops, value
|
|
20
21
|
from cirq.interop.quirk.cells.cell import Cell, CellMaker
|
|
@@ -16,7 +16,8 @@ from __future__ import annotations
|
|
|
16
16
|
|
|
17
17
|
import json
|
|
18
18
|
import urllib.parse
|
|
19
|
-
from
|
|
19
|
+
from collections.abc import Iterable, Mapping, Sequence
|
|
20
|
+
from typing import Any, cast, TYPE_CHECKING
|
|
20
21
|
|
|
21
22
|
import numpy as np
|
|
22
23
|
|
cirq/json_resolver_cache.py
CHANGED
cirq/linalg/decompositions.py
CHANGED
|
@@ -18,7 +18,8 @@ from __future__ import annotations
|
|
|
18
18
|
|
|
19
19
|
import cmath
|
|
20
20
|
import math
|
|
21
|
-
from
|
|
21
|
+
from collections.abc import Callable, Iterable
|
|
22
|
+
from typing import Any, cast, TYPE_CHECKING, TypeVar
|
|
22
23
|
|
|
23
24
|
import matplotlib.pyplot as plt
|
|
24
25
|
import numpy as np
|
|
@@ -243,7 +244,7 @@ def so4_to_magic_su2s(
|
|
|
243
244
|
|
|
244
245
|
@value.value_equality(approximate=True)
|
|
245
246
|
class AxisAngleDecomposition:
|
|
246
|
-
"""Represents a unitary operation as an axis, angle, and global phase.
|
|
247
|
+
r"""Represents a unitary operation as an axis, angle, and global phase.
|
|
247
248
|
|
|
248
249
|
The unitary $U$ is decomposed as follows:
|
|
249
250
|
|
|
@@ -472,6 +473,9 @@ class KakDecomposition:
|
|
|
472
473
|
f' global_phase={self.global_phase!r})'
|
|
473
474
|
)
|
|
474
475
|
|
|
476
|
+
def _has_unitary_(self) -> bool:
|
|
477
|
+
return True
|
|
478
|
+
|
|
475
479
|
def _unitary_(self) -> np.ndarray:
|
|
476
480
|
"""Returns the decomposition's two-qubit unitary matrix.
|
|
477
481
|
|
cirq/linalg/diagonalize.py
CHANGED
cirq/linalg/predicates.py
CHANGED
cirq/linalg/tolerance.py
CHANGED
cirq/linalg/transformations.py
CHANGED
|
@@ -18,8 +18,9 @@ from __future__ import annotations
|
|
|
18
18
|
|
|
19
19
|
import dataclasses
|
|
20
20
|
import functools
|
|
21
|
+
from collections.abc import Sequence
|
|
21
22
|
from types import EllipsisType
|
|
22
|
-
from typing import Any
|
|
23
|
+
from typing import Any
|
|
23
24
|
|
|
24
25
|
import numpy as np
|
|
25
26
|
|
|
@@ -82,7 +83,7 @@ def match_global_phase(a: np.ndarray, b: np.ndarray) -> tuple[np.ndarray, np.nda
|
|
|
82
83
|
return np.copy(a), np.copy(b)
|
|
83
84
|
|
|
84
85
|
# Find the entry with the largest magnitude in one of the matrices.
|
|
85
|
-
k = max(np.ndindex(*a.shape), key=lambda t: abs(b[t]))
|
|
86
|
+
k = max(np.ndindex(*a.shape), key=lambda t: abs(b[t].item()))
|
|
86
87
|
|
|
87
88
|
def dephase(v):
|
|
88
89
|
r = np.real(v)
|
cirq/ops/arithmetic_operation.py
CHANGED
|
@@ -17,7 +17,8 @@ from __future__ import annotations
|
|
|
17
17
|
|
|
18
18
|
import abc
|
|
19
19
|
import itertools
|
|
20
|
-
from
|
|
20
|
+
from collections.abc import Iterable, Sequence
|
|
21
|
+
from typing import cast, Self, TYPE_CHECKING
|
|
21
22
|
|
|
22
23
|
import numpy as np
|
|
23
24
|
|
|
@@ -130,9 +131,9 @@ class ArithmeticGate(Gate, metaclass=abc.ABCMeta):
|
|
|
130
131
|
1. The `apply` method is permitted to return values that have more bits
|
|
131
132
|
than the registers they will be stored into. The extra bits are
|
|
132
133
|
simply dropped. For example, if the value 5 is returned for a 2
|
|
133
|
-
qubit register then 5 % 2**2 = 1 will be used instead. Negative
|
|
134
|
+
qubit register then ``5 % 2**2 = 1`` will be used instead. Negative
|
|
134
135
|
values are also permitted. For example, for a 3 qubit register the
|
|
135
|
-
value -2 becomes
|
|
136
|
+
value -2 becomes ``-2 % 2**3 = 6``.
|
|
136
137
|
2. When the value of the last `k` registers is not changed by the
|
|
137
138
|
gate, the `apply` method is permitted to omit these values
|
|
138
139
|
from the result. That is to say, when the length of the output is
|
cirq/ops/boolean_hamiltonian.py
CHANGED
|
@@ -27,7 +27,8 @@ from __future__ import annotations
|
|
|
27
27
|
|
|
28
28
|
import functools
|
|
29
29
|
import itertools
|
|
30
|
-
from
|
|
30
|
+
from collections.abc import Generator, Sequence
|
|
31
|
+
from typing import Any
|
|
31
32
|
|
|
32
33
|
import sympy.parsing.sympy_parser as sympy_parser
|
|
33
34
|
|
|
@@ -334,8 +335,8 @@ def _get_gates_from_hamiltonians(
|
|
|
334
335
|
|
|
335
336
|
cnots = _simplify_cnots(cnots)
|
|
336
337
|
|
|
337
|
-
for
|
|
338
|
-
yield
|
|
338
|
+
for c, t in cnots:
|
|
339
|
+
yield cirq.CNOT(qubits[c], qubits[t])
|
|
339
340
|
|
|
340
341
|
sorted_hamiltonian_keys = sorted(
|
|
341
342
|
hamiltonians.keys(), key=functools.cmp_to_key(_gray_code_comparator)
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from
|
|
17
|
+
from collections.abc import Mapping, Sequence, Set
|
|
18
|
+
from typing import Any, TYPE_CHECKING
|
|
18
19
|
|
|
19
20
|
import sympy
|
|
20
21
|
|
|
@@ -150,7 +151,7 @@ class ClassicallyControlledOperation(raw_types.Operation):
|
|
|
150
151
|
def _is_parameterized_(self) -> bool:
|
|
151
152
|
return protocols.is_parameterized(self._sub_operation)
|
|
152
153
|
|
|
153
|
-
def _parameter_names_(self) ->
|
|
154
|
+
def _parameter_names_(self) -> Set[str]:
|
|
154
155
|
return protocols.parameter_names(self._sub_operation)
|
|
155
156
|
|
|
156
157
|
def _resolve_parameters_(
|
|
@@ -207,17 +208,13 @@ class ClassicallyControlledOperation(raw_types.Operation):
|
|
|
207
208
|
conditions = [protocols.with_measurement_key_mapping(c, key_map) for c in self._conditions]
|
|
208
209
|
sub_operation = protocols.with_measurement_key_mapping(self._sub_operation, key_map)
|
|
209
210
|
sub_operation = self._sub_operation if sub_operation is NotImplemented else sub_operation
|
|
210
|
-
return
|
|
211
|
-
ClassicallyControlledOperation, sub_operation.with_classical_controls(*conditions)
|
|
212
|
-
)
|
|
211
|
+
return sub_operation.with_classical_controls(*conditions)
|
|
213
212
|
|
|
214
213
|
def _with_key_path_prefix_(self, prefix: tuple[str, ...]) -> ClassicallyControlledOperation:
|
|
215
214
|
conditions = [protocols.with_key_path_prefix(c, prefix) for c in self._conditions]
|
|
216
215
|
sub_operation = protocols.with_key_path_prefix(self._sub_operation, prefix)
|
|
217
216
|
sub_operation = self._sub_operation if sub_operation is NotImplemented else sub_operation
|
|
218
|
-
return
|
|
219
|
-
ClassicallyControlledOperation, sub_operation.with_classical_controls(*conditions)
|
|
220
|
-
)
|
|
217
|
+
return sub_operation.with_classical_controls(*conditions)
|
|
221
218
|
|
|
222
219
|
def _with_rescoped_keys_(
|
|
223
220
|
self, path: tuple[str, ...], bindable_keys: frozenset[cirq.MeasurementKey]
|
|
@@ -234,9 +231,12 @@ class ClassicallyControlledOperation(raw_types.Operation):
|
|
|
234
231
|
|
|
235
232
|
def _qasm_(self, args: cirq.QasmArgs) -> str | None:
|
|
236
233
|
args.validate_version('2.0', '3.0')
|
|
237
|
-
if len(self._conditions) > 1:
|
|
238
|
-
raise ValueError(
|
|
234
|
+
if args.version == "2.0" and len(self._conditions) > 1:
|
|
235
|
+
raise ValueError(
|
|
236
|
+
'QASM 2.0 does not support multiple conditions. Consider exporting with QASM 3.0.'
|
|
237
|
+
)
|
|
239
238
|
subop_qasm = protocols.qasm(self._sub_operation, args=args)
|
|
240
239
|
if not self._conditions:
|
|
241
240
|
return subop_qasm
|
|
242
|
-
|
|
241
|
+
condition_qasm = " && ".join(protocols.qasm(c, args=args) for c in self._conditions)
|
|
242
|
+
return f'if ({condition_qasm}) {subop_qasm}'
|
|
@@ -281,8 +281,32 @@ def test_qasm_multiple_conditions() -> None:
|
|
|
281
281
|
sympy.Eq(sympy.Symbol('a'), 0), sympy.Eq(sympy.Symbol('b'), 0)
|
|
282
282
|
),
|
|
283
283
|
)
|
|
284
|
-
with pytest.raises(
|
|
285
|
-
|
|
284
|
+
with pytest.raises(
|
|
285
|
+
ValueError,
|
|
286
|
+
match='QASM 2.0 does not support multiple conditions. Consider exporting with QASM 3.0.',
|
|
287
|
+
):
|
|
288
|
+
_ = cirq.qasm(circuit, args=cirq.QasmArgs(version='2.0'))
|
|
289
|
+
|
|
290
|
+
qasm = cirq.qasm(circuit, args=cirq.QasmArgs(version='3.0'))
|
|
291
|
+
assert (
|
|
292
|
+
qasm
|
|
293
|
+
== f"""// Generated from Cirq v{cirq.__version__}
|
|
294
|
+
|
|
295
|
+
OPENQASM 3.0;
|
|
296
|
+
include "stdgates.inc";
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
// Qubits: [q(0), q(1)]
|
|
300
|
+
qubit[2] q;
|
|
301
|
+
bit[1] m_a;
|
|
302
|
+
bit[1] m_b;
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
m_a[0] = measure q[0];
|
|
306
|
+
m_b[0] = measure q[0];
|
|
307
|
+
if (m_a==0 && m_b==0) x q[1];
|
|
308
|
+
"""
|
|
309
|
+
)
|
|
286
310
|
|
|
287
311
|
|
|
288
312
|
@pytest.mark.parametrize('sim', ALL_SIMULATORS)
|
cirq/ops/clifford_gate.py
CHANGED
|
@@ -15,9 +15,10 @@
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
import functools
|
|
18
|
+
from collections.abc import Sequence
|
|
18
19
|
from dataclasses import dataclass
|
|
19
20
|
from types import NotImplementedType
|
|
20
|
-
from typing import Any,
|
|
21
|
+
from typing import Any, TYPE_CHECKING
|
|
21
22
|
|
|
22
23
|
import numpy as np
|
|
23
24
|
|
|
@@ -639,7 +640,7 @@ class SingleQubitCliffordGate(CliffordGate):
|
|
|
639
640
|
return None
|
|
640
641
|
# Find the entry with the largest magnitude in the input unitary, to find
|
|
641
642
|
# the global phase difference between the input unitary and the gate unitary.
|
|
642
|
-
k = max(np.ndindex(*u.shape), key=lambda t: abs(u[t]))
|
|
643
|
+
k = max(np.ndindex(*u.shape), key=lambda t: abs(u[t].item()))
|
|
643
644
|
return gate, u[k] / protocols.unitary(gate)[k]
|
|
644
645
|
|
|
645
646
|
def pauli_tuple(self, pauli: Pauli) -> tuple[Pauli, bool]:
|
cirq/ops/clifford_gate_test.py
CHANGED
cirq/ops/common_channels.py
CHANGED
cirq/ops/common_gates.py
CHANGED
|
@@ -27,8 +27,9 @@ raised to a power (i.e. cirq.H**0.5). See the definition in EigenGate.
|
|
|
27
27
|
|
|
28
28
|
from __future__ import annotations
|
|
29
29
|
|
|
30
|
+
from collections.abc import Collection, Sequence
|
|
30
31
|
from types import NotImplementedType
|
|
31
|
-
from typing import Any, cast
|
|
32
|
+
from typing import Any, cast
|
|
32
33
|
|
|
33
34
|
import numpy as np
|
|
34
35
|
import sympy
|
|
@@ -391,7 +392,7 @@ class YPowGate(eigen_gate.EigenGate):
|
|
|
391
392
|
Unlike `cirq.XPowGate` and `cirq.ZPowGate`, this gate has no generalization
|
|
392
393
|
to qudits and hence does not take the dimension argument. Ignoring the
|
|
393
394
|
global phase all generalized Pauli operators on a d-level system may be
|
|
394
|
-
written as X**a Z**b for a,b=0,1,...,d-1. For a qubit, there is only one
|
|
395
|
+
written as ``X**a Z**b`` for a,b=0,1,...,d-1. For a qubit, there is only one
|
|
395
396
|
"mixed" operator: XZ, conventionally denoted -iY. However, when d > 2 there
|
|
396
397
|
are (d-1)*(d-1) > 1 such "mixed" operators (still ignoring the global phase).
|
|
397
398
|
Due to this ambiguity, qudit Y gate is not well defined. The "mixed" operators
|
cirq/ops/control_values.py
CHANGED
|
@@ -16,8 +16,9 @@ from __future__ import annotations
|
|
|
16
16
|
|
|
17
17
|
import abc
|
|
18
18
|
import itertools
|
|
19
|
+
from collections.abc import Collection, Iterator, Sequence
|
|
19
20
|
from functools import cached_property
|
|
20
|
-
from typing import Any,
|
|
21
|
+
from typing import Any, TYPE_CHECKING
|
|
21
22
|
|
|
22
23
|
from cirq import protocols, value
|
|
23
24
|
|
cirq/ops/controlled_gate.py
CHANGED
|
@@ -14,8 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
+
from collections.abc import Collection, Sequence, Set
|
|
17
18
|
from types import NotImplementedType
|
|
18
|
-
from typing import
|
|
19
|
+
from typing import Any, TYPE_CHECKING
|
|
19
20
|
|
|
20
21
|
import numpy as np
|
|
21
22
|
|
|
@@ -244,7 +245,7 @@ class ControlledGate(raw_types.Gate):
|
|
|
244
245
|
def _is_parameterized_(self) -> bool:
|
|
245
246
|
return protocols.is_parameterized(self.sub_gate)
|
|
246
247
|
|
|
247
|
-
def _parameter_names_(self) ->
|
|
248
|
+
def _parameter_names_(self) -> Set[str]:
|
|
248
249
|
return protocols.parameter_names(self.sub_gate)
|
|
249
250
|
|
|
250
251
|
def _resolve_parameters_(self, resolver: cirq.ParamResolver, recursive: bool) -> ControlledGate:
|
cirq/ops/controlled_gate_test.py
CHANGED