cirq-core 1.4.0.dev20240529225110__py3-none-any.whl → 1.5.0__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/__init__.py +587 -569
- cirq/_compat.py +9 -0
- cirq/_compat_test.py +11 -9
- cirq/_import.py +7 -8
- cirq/_version.py +31 -1
- cirq/_version_test.py +1 -1
- cirq/circuits/__init__.py +15 -9
- cirq/circuits/_block_diagram_drawer.py +1 -2
- cirq/circuits/_block_diagram_drawer_test.py +3 -3
- cirq/circuits/_box_drawing_character_data.py +0 -1
- cirq/circuits/_box_drawing_character_data_test.py +2 -2
- cirq/circuits/_bucket_priority_queue.py +0 -1
- cirq/circuits/_bucket_priority_queue_test.py +1 -1
- cirq/circuits/circuit.py +336 -234
- cirq/circuits/circuit_operation.py +102 -52
- cirq/circuits/circuit_operation_test.py +85 -4
- cirq/circuits/circuit_test.py +101 -32
- cirq/circuits/frozen_circuit.py +36 -32
- cirq/circuits/insert_strategy.py +10 -0
- cirq/circuits/insert_strategy_test.py +20 -0
- cirq/circuits/moment.py +79 -80
- cirq/circuits/moment_test.py +105 -2
- cirq/circuits/optimization_pass.py +15 -15
- cirq/circuits/optimization_pass_test.py +8 -9
- cirq/circuits/qasm_output.py +64 -33
- cirq/circuits/qasm_output_test.py +63 -2
- cirq/circuits/text_diagram_drawer.py +26 -56
- cirq/circuits/text_diagram_drawer_test.py +5 -4
- cirq/contrib/__init__.py +2 -2
- cirq/contrib/acquaintance/__init__.py +44 -29
- cirq/contrib/acquaintance/bipartite.py +8 -7
- cirq/contrib/acquaintance/bipartite_test.py +11 -1
- cirq/contrib/acquaintance/devices.py +5 -4
- cirq/contrib/acquaintance/devices_test.py +5 -1
- cirq/contrib/acquaintance/executor.py +18 -21
- cirq/contrib/acquaintance/executor_test.py +3 -2
- cirq/contrib/acquaintance/gates.py +36 -27
- cirq/contrib/acquaintance/gates_test.py +1 -1
- cirq/contrib/acquaintance/inspection_utils.py +10 -9
- cirq/contrib/acquaintance/inspection_utils_test.py +6 -1
- cirq/contrib/acquaintance/mutation_utils.py +10 -10
- cirq/contrib/acquaintance/optimizers.py +7 -6
- cirq/contrib/acquaintance/optimizers_test.py +1 -1
- cirq/contrib/acquaintance/permutation.py +22 -21
- cirq/contrib/acquaintance/permutation_test.py +1 -1
- cirq/contrib/acquaintance/shift.py +8 -6
- cirq/contrib/acquaintance/shift_swap_network.py +6 -4
- cirq/contrib/acquaintance/strategies/__init__.py +9 -3
- cirq/contrib/acquaintance/strategies/complete.py +4 -3
- cirq/contrib/acquaintance/strategies/cubic.py +5 -3
- cirq/contrib/acquaintance/strategies/quartic_paired.py +8 -6
- cirq/contrib/acquaintance/topological_sort.py +4 -2
- cirq/contrib/bayesian_network/__init__.py +3 -1
- cirq/contrib/bayesian_network/bayesian_network_gate.py +5 -3
- cirq/contrib/circuitdag/__init__.py +1 -1
- cirq/contrib/circuitdag/circuit_dag.py +24 -24
- cirq/contrib/circuitdag/circuit_dag_test.py +1 -1
- cirq/contrib/custom_simulators/custom_state_simulator.py +10 -8
- cirq/contrib/custom_simulators/custom_state_simulator_test.py +15 -11
- cirq/contrib/graph_device/__init__.py +8 -8
- cirq/contrib/graph_device/graph_device.py +8 -8
- cirq/contrib/graph_device/graph_device_test.py +0 -1
- cirq/contrib/graph_device/hypergraph_test.py +1 -0
- cirq/contrib/json.py +1 -2
- cirq/contrib/json_test.py +2 -2
- cirq/contrib/noise_models/__init__.py +5 -6
- cirq/contrib/noise_models/noise_models.py +8 -6
- cirq/contrib/paulistring/__init__.py +22 -10
- cirq/contrib/paulistring/clifford_optimize.py +1 -1
- cirq/contrib/paulistring/clifford_optimize_test.py +0 -1
- cirq/contrib/paulistring/clifford_target_gateset.py +15 -12
- cirq/contrib/paulistring/optimize.py +2 -2
- cirq/contrib/paulistring/optimize_test.py +0 -1
- cirq/contrib/paulistring/pauli_string_dag_test.py +0 -1
- cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation.py +379 -0
- cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation_test.py +523 -0
- cirq/contrib/paulistring/pauli_string_optimize.py +3 -1
- cirq/contrib/paulistring/pauli_string_optimize_test.py +1 -3
- cirq/contrib/paulistring/recombine.py +2 -2
- cirq/contrib/paulistring/recombine_test.py +2 -2
- cirq/contrib/paulistring/separate.py +3 -4
- cirq/contrib/qasm_import/__init__.py +2 -2
- cirq/contrib/qasm_import/_lexer.py +21 -26
- cirq/contrib/qasm_import/_lexer_test.py +90 -6
- cirq/contrib/qasm_import/_parser.py +238 -47
- cirq/contrib/qasm_import/_parser_test.py +514 -59
- cirq/contrib/qasm_import/qasm_test.py +1 -1
- cirq/contrib/qcircuit/__init__.py +6 -4
- cirq/contrib/qcircuit/qcircuit_diagram.py +5 -2
- cirq/contrib/qcircuit/qcircuit_pdf.py +1 -2
- cirq/{experiments/grid_parallel_two_qubit_xeb_test.py → contrib/qcircuit/qcircuit_pdf_test.py} +13 -12
- cirq/contrib/qcircuit/qcircuit_test.py +1 -1
- cirq/contrib/quantum_volume/__init__.py +7 -7
- cirq/contrib/quantum_volume/quantum_volume.py +6 -11
- cirq/contrib/quantum_volume/quantum_volume_test.py +3 -1
- cirq/contrib/quimb/__init__.py +16 -13
- cirq/contrib/quimb/density_matrix.py +1 -1
- cirq/contrib/quimb/mps_simulator.py +27 -28
- cirq/contrib/quimb/mps_simulator_test.py +5 -0
- cirq/contrib/quimb/state_vector.py +3 -10
- cirq/contrib/quirk/__init__.py +1 -1
- cirq/contrib/quirk/export_to_quirk.py +3 -3
- cirq/contrib/routing/__init__.py +12 -9
- cirq/contrib/routing/device.py +1 -1
- cirq/contrib/routing/device_test.py +1 -2
- cirq/contrib/routing/greedy.py +7 -5
- cirq/contrib/routing/greedy_test.py +5 -3
- cirq/contrib/routing/initialization.py +3 -1
- cirq/contrib/routing/initialization_test.py +1 -1
- cirq/contrib/routing/swap_network.py +6 -6
- cirq/contrib/routing/utils.py +6 -4
- cirq/contrib/routing/utils_test.py +1 -2
- cirq/{type_workarounds.py → contrib/shuffle_circuits/__init__.py} +5 -10
- cirq/contrib/shuffle_circuits/shuffle_circuits_with_readout_benchmarking.py +250 -0
- cirq/contrib/shuffle_circuits/shuffle_circuits_with_readout_benchmarking_test.py +363 -0
- cirq/contrib/svg/__init__.py +1 -1
- cirq/contrib/svg/svg.py +12 -10
- cirq/contrib/svg/svg_test.py +3 -2
- cirq/devices/__init__.py +34 -25
- cirq/devices/device.py +16 -12
- cirq/devices/device_test.py +1 -0
- cirq/devices/grid_device_metadata.py +16 -12
- cirq/devices/grid_device_metadata_test.py +2 -1
- cirq/devices/grid_qubit.py +31 -26
- cirq/devices/grid_qubit_test.py +30 -1
- cirq/devices/insertion_noise_model.py +6 -6
- cirq/devices/insertion_noise_model_test.py +1 -1
- cirq/devices/line_qubit.py +28 -20
- cirq/devices/line_qubit_test.py +26 -0
- cirq/devices/named_topologies.py +12 -10
- cirq/devices/named_topologies_test.py +5 -4
- cirq/devices/noise_model.py +29 -33
- cirq/devices/noise_properties.py +2 -2
- cirq/devices/noise_properties_test.py +2 -2
- cirq/devices/noise_utils.py +3 -3
- cirq/devices/superconducting_qubits_noise_properties.py +2 -2
- cirq/devices/superconducting_qubits_noise_properties_test.py +3 -3
- cirq/devices/thermal_noise_model.py +2 -1
- cirq/devices/unconstrained_device.py +1 -1
- cirq/devices/unconstrained_device_test.py +6 -0
- cirq/experiments/__init__.py +51 -34
- cirq/experiments/qubit_characterizations.py +17 -15
- cirq/experiments/qubit_characterizations_test.py +4 -6
- cirq/experiments/random_quantum_circuit_generation.py +10 -9
- cirq/experiments/random_quantum_circuit_generation_test.py +21 -4
- cirq/experiments/readout_confusion_matrix.py +73 -8
- cirq/experiments/readout_confusion_matrix_test.py +104 -1
- cirq/experiments/single_qubit_readout_calibration.py +8 -6
- cirq/experiments/single_qubit_readout_calibration_test.py +1 -1
- cirq/experiments/t1_decay_experiment.py +4 -5
- cirq/experiments/t1_decay_experiment_test.py +1 -2
- cirq/experiments/t2_decay_experiment.py +0 -1
- cirq/experiments/t2_decay_experiment_test.py +1 -2
- cirq/experiments/two_qubit_xeb.py +157 -33
- cirq/experiments/two_qubit_xeb_test.py +38 -22
- cirq/experiments/xeb_fitting.py +99 -19
- cirq/experiments/xeb_fitting_test.py +64 -25
- cirq/experiments/xeb_sampling.py +14 -18
- cirq/experiments/xeb_simulation.py +4 -3
- cirq/experiments/xeb_simulation_test.py +20 -14
- cirq/experiments/z_phase_calibration.py +368 -0
- cirq/experiments/z_phase_calibration_test.py +241 -0
- cirq/interop/__init__.py +4 -1
- cirq/interop/quirk/__init__.py +7 -4
- cirq/interop/quirk/cells/__init__.py +17 -6
- cirq/interop/quirk/cells/arithmetic_cells.py +8 -8
- cirq/interop/quirk/cells/arithmetic_cells_test.py +1 -1
- cirq/interop/quirk/cells/cell.py +6 -6
- cirq/interop/quirk/cells/composite_cell.py +5 -5
- cirq/interop/quirk/cells/composite_cell_test.py +1 -1
- cirq/interop/quirk/cells/control_cells.py +1 -1
- cirq/interop/quirk/cells/frequency_space_cells.py +2 -2
- cirq/interop/quirk/cells/ignored_cells.py +1 -1
- cirq/interop/quirk/cells/input_cells.py +1 -1
- cirq/interop/quirk/cells/input_cells_test.py +1 -1
- cirq/interop/quirk/cells/input_rotation_cells.py +1 -1
- cirq/interop/quirk/cells/input_rotation_cells_test.py +1 -1
- cirq/interop/quirk/cells/measurement_cells.py +1 -1
- cirq/interop/quirk/cells/parse.py +8 -7
- cirq/interop/quirk/cells/parse_test.py +2 -2
- cirq/interop/quirk/cells/single_qubit_rotation_cells.py +1 -1
- cirq/interop/quirk/cells/swap_cell_test.py +1 -1
- cirq/interop/quirk/cells/unsupported_cells.py +1 -1
- cirq/interop/quirk/url_to_circuit.py +7 -7
- cirq/interop/quirk/url_to_circuit_test.py +1 -1
- cirq/ion/__init__.py +4 -2
- cirq/json_resolver_cache.py +15 -7
- cirq/linalg/__init__.py +62 -51
- cirq/linalg/combinators.py +4 -4
- cirq/linalg/combinators_test.py +4 -1
- cirq/linalg/decompositions.py +15 -40
- cirq/linalg/decompositions_test.py +16 -22
- cirq/linalg/diagonalize.py +1 -1
- cirq/linalg/diagonalize_test.py +1 -1
- cirq/linalg/operator_spaces.py +20 -4
- cirq/linalg/operator_spaces_test.py +15 -2
- cirq/linalg/predicates.py +3 -3
- cirq/linalg/predicates_test.py +1 -0
- cirq/linalg/tolerance.py +2 -2
- cirq/linalg/transformations.py +30 -12
- cirq/linalg/transformations_test.py +13 -0
- cirq/neutral_atoms/__init__.py +2 -2
- cirq/neutral_atoms/convert_to_neutral_atom_gates_test.py +0 -1
- cirq/ops/__init__.py +172 -132
- cirq/ops/arithmetic_operation.py +2 -2
- cirq/ops/arithmetic_operation_test.py +2 -2
- cirq/ops/boolean_hamiltonian.py +3 -2
- cirq/ops/classically_controlled_operation.py +39 -12
- cirq/ops/classically_controlled_operation_test.py +147 -1
- cirq/ops/clifford_gate.py +38 -36
- cirq/ops/clifford_gate_test.py +75 -1
- cirq/ops/common_channels.py +16 -45
- cirq/ops/common_channels_test.py +10 -0
- cirq/ops/common_gate_families.py +1 -1
- cirq/ops/common_gate_families_test.py +1 -0
- cirq/ops/common_gates.py +48 -49
- cirq/ops/common_gates_test.py +18 -2
- cirq/ops/control_values.py +3 -3
- cirq/ops/control_values_test.py +2 -1
- cirq/ops/controlled_gate.py +36 -23
- cirq/ops/controlled_gate_test.py +70 -3
- cirq/ops/controlled_operation.py +6 -5
- cirq/ops/controlled_operation_test.py +7 -3
- cirq/ops/dense_pauli_string.py +11 -11
- cirq/ops/diagonal_gate.py +2 -2
- cirq/ops/diagonal_gate_test.py +1 -0
- cirq/ops/eigen_gate.py +16 -36
- cirq/ops/eigen_gate_test.py +60 -10
- cirq/ops/fourier_transform.py +1 -3
- cirq/ops/fourier_transform_test.py +2 -1
- cirq/ops/fsim_gate.py +42 -3
- cirq/ops/fsim_gate_test.py +21 -0
- cirq/ops/gate_operation.py +8 -8
- cirq/ops/gate_operation_test.py +4 -2
- cirq/ops/gateset_test.py +11 -2
- cirq/ops/global_phase_op.py +8 -7
- cirq/ops/global_phase_op_test.py +1 -1
- cirq/ops/greedy_qubit_manager_test.py +5 -0
- cirq/ops/identity.py +14 -4
- cirq/ops/identity_test.py +24 -0
- cirq/ops/kraus_channel.py +1 -0
- cirq/ops/kraus_channel_test.py +3 -1
- cirq/ops/linear_combinations.py +27 -21
- cirq/ops/linear_combinations_test.py +23 -4
- cirq/ops/matrix_gates.py +24 -8
- cirq/ops/measure_util.py +2 -2
- cirq/ops/measurement_gate.py +7 -4
- cirq/ops/measurement_gate_test.py +2 -1
- cirq/ops/mixed_unitary_channel.py +1 -0
- cirq/ops/mixed_unitary_channel_test.py +3 -1
- cirq/ops/named_qubit.py +8 -1
- cirq/ops/op_tree.py +3 -30
- cirq/ops/op_tree_test.py +4 -0
- cirq/ops/parallel_gate.py +2 -3
- cirq/ops/parallel_gate_test.py +2 -1
- cirq/ops/parity_gates.py +7 -8
- cirq/ops/parity_gates_test.py +1 -0
- cirq/ops/pauli_gates.py +5 -11
- cirq/ops/pauli_gates_test.py +1 -0
- cirq/ops/pauli_interaction_gate.py +11 -5
- cirq/ops/pauli_interaction_gate_test.py +2 -3
- cirq/ops/pauli_measurement_gate.py +6 -5
- cirq/ops/pauli_measurement_gate_test.py +1 -0
- cirq/ops/pauli_string.py +115 -130
- cirq/ops/pauli_string_phasor.py +21 -20
- cirq/ops/pauli_string_phasor_test.py +13 -3
- cirq/ops/pauli_string_raw_types.py +1 -0
- cirq/ops/pauli_string_test.py +192 -55
- cirq/ops/pauli_sum_exponential.py +3 -4
- cirq/ops/pauli_sum_exponential_test.py +0 -1
- cirq/ops/permutation_gate.py +2 -2
- cirq/ops/permutation_gate_test.py +1 -1
- cirq/ops/phased_iswap_gate.py +6 -7
- cirq/ops/phased_iswap_gate_test.py +21 -5
- cirq/ops/phased_x_gate.py +11 -25
- cirq/ops/phased_x_gate_test.py +19 -3
- cirq/ops/phased_x_z_gate.py +12 -11
- cirq/ops/projector.py +4 -5
- cirq/ops/qubit_manager.py +2 -1
- cirq/ops/qubit_manager_test.py +2 -1
- cirq/ops/qubit_order.py +1 -1
- cirq/ops/random_gate_channel.py +1 -1
- cirq/ops/random_gate_channel_test.py +0 -6
- cirq/ops/raw_types.py +146 -50
- cirq/ops/raw_types_test.py +37 -3
- cirq/ops/state_preparation_channel.py +2 -2
- cirq/ops/state_preparation_channel_test.py +2 -1
- cirq/ops/swap_gates.py +9 -4
- cirq/ops/three_qubit_gates.py +8 -8
- cirq/ops/three_qubit_gates_test.py +1 -0
- cirq/ops/two_qubit_diagonal_gate.py +4 -3
- cirq/ops/uniform_superposition_gate.py +4 -4
- cirq/ops/uniform_superposition_gate_test.py +1 -0
- cirq/ops/wait_gate.py +6 -8
- cirq/protocols/__init__.py +135 -83
- cirq/protocols/act_on_protocol.py +1 -1
- cirq/protocols/act_on_protocol_test.py +1 -1
- cirq/protocols/apply_channel_protocol.py +3 -3
- cirq/protocols/apply_mixture_protocol.py +15 -9
- cirq/protocols/apply_mixture_protocol_test.py +11 -0
- cirq/protocols/apply_unitary_protocol.py +2 -2
- cirq/protocols/apply_unitary_protocol_test.py +2 -1
- cirq/protocols/approximate_equality_protocol.py +7 -8
- cirq/protocols/approximate_equality_protocol_test.py +3 -1
- cirq/protocols/circuit_diagram_info_protocol.py +8 -6
- cirq/protocols/circuit_diagram_info_protocol_test.py +5 -0
- cirq/protocols/commutes_protocol.py +6 -6
- cirq/protocols/control_key_protocol.py +1 -1
- cirq/protocols/decompose_protocol.py +4 -5
- cirq/protocols/decompose_protocol_test.py +2 -1
- cirq/protocols/equal_up_to_global_phase_protocol.py +3 -3
- cirq/protocols/equal_up_to_global_phase_protocol_test.py +7 -0
- cirq/protocols/has_stabilizer_effect_protocol.py +5 -5
- cirq/protocols/has_unitary_protocol.py +1 -1
- cirq/protocols/has_unitary_protocol_test.py +8 -7
- cirq/protocols/hash_from_pickle_test.py +120 -0
- cirq/protocols/inverse_protocol.py +1 -1
- cirq/protocols/json_serialization.py +14 -1
- cirq/protocols/json_serialization_test.py +28 -7
- cirq/protocols/json_test_data/BitMaskKeyCondition.json +86 -0
- cirq/protocols/json_test_data/BitMaskKeyCondition.repr +7 -0
- cirq/protocols/json_test_data/Concat.json +19 -0
- cirq/protocols/json_test_data/Concat.repr +1 -0
- cirq/protocols/json_test_data/README.md +4 -2
- cirq/protocols/json_test_data/SympyCondition.json +60 -15
- cirq/protocols/json_test_data/SympyCondition.repr +4 -1
- cirq/protocols/json_test_data/_InverseCompositeGate.json +10 -0
- cirq/protocols/json_test_data/_InverseCompositeGate.repr +1 -0
- cirq/protocols/json_test_data/__init__.py +1 -1
- cirq/protocols/json_test_data/sympy.And.json +13 -0
- cirq/protocols/json_test_data/sympy.And.repr +1 -0
- cirq/protocols/json_test_data/sympy.Indexed.json +18 -0
- cirq/protocols/json_test_data/sympy.Indexed.repr +1 -0
- cirq/protocols/json_test_data/sympy.IndexedBase.json +9 -0
- cirq/protocols/json_test_data/sympy.IndexedBase.repr +1 -0
- cirq/protocols/json_test_data/sympy.Not.json +9 -0
- cirq/protocols/json_test_data/sympy.Not.repr +1 -0
- cirq/protocols/json_test_data/sympy.Or.json +13 -0
- cirq/protocols/json_test_data/sympy.Or.repr +1 -0
- cirq/protocols/json_test_data/sympy.Xor.json +13 -0
- cirq/protocols/json_test_data/sympy.Xor.repr +1 -0
- cirq/protocols/kraus_protocol.py +8 -8
- cirq/protocols/kraus_protocol_test.py +0 -1
- cirq/protocols/measurement_key_protocol.py +1 -1
- cirq/protocols/measurement_key_protocol_test.py +7 -7
- cirq/protocols/mixture_protocol.py +6 -4
- cirq/protocols/mixture_protocol_test.py +21 -13
- cirq/protocols/pauli_expansion_protocol.py +1 -0
- cirq/protocols/pow_protocol.py +1 -1
- cirq/protocols/qasm.py +25 -6
- cirq/protocols/qasm_test.py +17 -0
- cirq/protocols/qid_shape_protocol.py +2 -2
- cirq/protocols/resolve_parameters.py +2 -3
- cirq/protocols/resolve_parameters_test.py +2 -1
- cirq/protocols/trace_distance_bound.py +1 -1
- cirq/protocols/trace_distance_bound_test.py +1 -0
- cirq/protocols/unitary_protocol.py +3 -3
- cirq/protocols/unitary_protocol_test.py +1 -1
- cirq/qis/__init__.py +48 -35
- cirq/qis/channels_test.py +0 -9
- cirq/qis/clifford_tableau.py +46 -26
- cirq/qis/clifford_tableau_test.py +2 -1
- cirq/qis/entropy.py +115 -0
- cirq/qis/entropy_test.py +43 -0
- cirq/qis/measures.py +5 -4
- cirq/qis/measures_test.py +7 -0
- cirq/qis/noise_utils_test.py +4 -4
- cirq/qis/quantum_state_representation.py +1 -1
- cirq/qis/states.py +7 -7
- cirq/sim/__init__.py +55 -37
- cirq/sim/classical_simulator.py +7 -6
- cirq/sim/classical_simulator_test.py +3 -1
- cirq/sim/clifford/__init__.py +17 -9
- cirq/sim/clifford/clifford_simulator.py +5 -4
- cirq/sim/clifford/clifford_simulator_test.py +32 -9
- cirq/sim/clifford/clifford_tableau_simulation_state.py +1 -1
- cirq/sim/clifford/stabilizer_simulation_state.py +1 -1
- cirq/sim/clifford/stabilizer_state_ch_form.py +4 -3
- cirq/sim/density_matrix_simulator.py +3 -2
- cirq/sim/density_matrix_simulator_test.py +12 -4
- cirq/sim/density_matrix_utils.py +1 -1
- cirq/sim/mux.py +2 -2
- cirq/sim/simulation_state.py +4 -5
- cirq/sim/simulation_state_base.py +2 -2
- cirq/sim/simulation_state_test.py +1 -1
- cirq/sim/simulation_utils.py +3 -1
- cirq/sim/simulation_utils_test.py +2 -3
- cirq/sim/simulator.py +7 -6
- cirq/sim/simulator_base.py +5 -5
- cirq/sim/simulator_test.py +14 -3
- cirq/sim/sparse_simulator.py +4 -3
- cirq/sim/sparse_simulator_test.py +17 -9
- cirq/sim/state_vector.py +2 -2
- cirq/sim/state_vector_simulation_state_test.py +1 -1
- cirq/sim/state_vector_simulator.py +4 -4
- cirq/sim/state_vector_test.py +27 -32
- cirq/study/__init__.py +27 -21
- cirq/study/flatten_expressions.py +5 -6
- cirq/study/flatten_expressions_test.py +1 -1
- cirq/study/resolver.py +14 -11
- cirq/study/resolver_test.py +10 -1
- cirq/study/result.py +3 -3
- cirq/study/sweepable.py +15 -9
- cirq/study/sweepable_test.py +27 -0
- cirq/study/sweeps.py +65 -10
- cirq/study/sweeps_test.py +123 -0
- cirq/testing/__init__.py +86 -57
- cirq/testing/_compat_test_data/module_a/__init__.py +2 -2
- cirq/testing/_compat_test_data/module_a/sub/subsub/__init__.py +1 -1
- cirq/testing/circuit_compare.py +3 -4
- cirq/testing/circuit_compare_test.py +7 -8
- cirq/testing/consistent_act_on.py +3 -3
- cirq/testing/consistent_channels_test.py +2 -1
- cirq/testing/consistent_controlled_gate_op.py +3 -2
- cirq/testing/consistent_controlled_gate_op_test.py +2 -3
- cirq/testing/consistent_decomposition.py +1 -1
- cirq/testing/consistent_decomposition_test.py +1 -2
- cirq/testing/consistent_pauli_expansion_test.py +1 -1
- cirq/testing/consistent_phase_by.py +1 -1
- cirq/testing/consistent_phase_by_test.py +1 -2
- cirq/testing/consistent_protocols.py +11 -11
- cirq/testing/consistent_protocols_test.py +4 -5
- cirq/testing/consistent_qasm.py +8 -12
- cirq/testing/consistent_qasm_test.py +1 -1
- cirq/testing/consistent_resolve_parameters.py +2 -1
- cirq/testing/consistent_specified_has_unitary_test.py +1 -1
- cirq/testing/consistent_unitary.py +3 -1
- cirq/testing/consistent_unitary_test.py +3 -3
- cirq/testing/devices.py +1 -1
- cirq/testing/devices_test.py +1 -0
- cirq/testing/equals_tester.py +2 -4
- cirq/testing/equals_tester_test.py +6 -5
- cirq/testing/equivalent_basis_map.py +1 -0
- cirq/testing/equivalent_basis_map_test.py +0 -1
- cirq/testing/gate_features_test.py +5 -0
- cirq/testing/json.py +4 -4
- cirq/testing/lin_alg_utils_test.py +1 -1
- cirq/testing/order_tester.py +1 -1
- cirq/testing/order_tester_test.py +1 -1
- cirq/testing/pytest_utils.py +57 -0
- cirq/testing/pytest_utils_test.py +35 -0
- cirq/testing/random_circuit.py +2 -2
- cirq/testing/random_circuit_test.py +2 -2
- cirq/testing/routing_devices_test.py +2 -1
- cirq/testing/sample_circuits.py +1 -1
- cirq/testing/sample_gates.py +5 -4
- cirq/testing/sample_gates_test.py +2 -2
- cirq/transformers/__init__.py +101 -82
- cirq/transformers/align.py +12 -1
- cirq/transformers/align_test.py +13 -0
- cirq/transformers/analytical_decompositions/__init__.py +27 -24
- cirq/transformers/analytical_decompositions/clifford_decomposition.py +2 -1
- cirq/transformers/analytical_decompositions/clifford_decomposition_test.py +1 -1
- cirq/transformers/analytical_decompositions/controlled_gate_decomposition.py +1 -1
- cirq/transformers/analytical_decompositions/controlled_gate_decomposition_test.py +2 -0
- cirq/transformers/analytical_decompositions/cphase_to_fsim.py +1 -1
- cirq/transformers/analytical_decompositions/cphase_to_fsim_test.py +1 -1
- cirq/transformers/analytical_decompositions/pauli_string_decomposition.py +2 -2
- cirq/transformers/analytical_decompositions/pauli_string_decomposition_test.py +4 -4
- cirq/transformers/analytical_decompositions/quantum_shannon_decomposition.py +99 -24
- cirq/transformers/analytical_decompositions/quantum_shannon_decomposition_test.py +105 -14
- cirq/transformers/analytical_decompositions/single_qubit_decompositions.py +1 -1
- cirq/transformers/analytical_decompositions/single_to_two_qubit_isometry.py +1 -1
- cirq/transformers/analytical_decompositions/single_to_two_qubit_isometry_test.py +1 -0
- cirq/transformers/analytical_decompositions/three_qubit_decomposition.py +3 -4
- cirq/transformers/analytical_decompositions/three_qubit_decomposition_test.py +1 -1
- cirq/transformers/analytical_decompositions/two_qubit_state_preparation.py +2 -1
- cirq/transformers/analytical_decompositions/two_qubit_state_preparation_test.py +2 -1
- cirq/transformers/analytical_decompositions/two_qubit_to_cz.py +5 -6
- cirq/transformers/analytical_decompositions/two_qubit_to_cz_test.py +2 -2
- cirq/transformers/analytical_decompositions/two_qubit_to_fsim.py +1 -1
- cirq/transformers/analytical_decompositions/two_qubit_to_fsim_test.py +1 -2
- cirq/transformers/analytical_decompositions/two_qubit_to_ms.py +2 -2
- cirq/transformers/analytical_decompositions/two_qubit_to_sqrt_iswap.py +2 -2
- cirq/transformers/analytical_decompositions/two_qubit_to_sqrt_iswap_test.py +2 -1
- cirq/transformers/drop_empty_moments.py +1 -0
- cirq/transformers/drop_negligible_operations.py +1 -0
- cirq/transformers/dynamical_decoupling.py +255 -43
- cirq/transformers/dynamical_decoupling_test.py +730 -17
- cirq/transformers/eject_phased_paulis.py +29 -15
- cirq/transformers/eject_phased_paulis_test.py +3 -8
- cirq/transformers/eject_z.py +3 -2
- cirq/transformers/eject_z_test.py +3 -3
- cirq/transformers/gauge_compiling/__init__.py +25 -9
- cirq/transformers/gauge_compiling/cphase_gauge.py +146 -0
- cirq/transformers/gauge_compiling/cphase_gauge_test.py +42 -0
- cirq/transformers/gauge_compiling/cz_gauge.py +4 -4
- cirq/transformers/gauge_compiling/gauge_compiling.py +245 -6
- cirq/transformers/gauge_compiling/gauge_compiling_test.py +107 -2
- cirq/transformers/gauge_compiling/gauge_compiling_test_utils.py +39 -2
- cirq/transformers/gauge_compiling/gauge_compiling_test_utils_test.py +10 -1
- cirq/transformers/gauge_compiling/iswap_gauge.py +2 -2
- cirq/transformers/gauge_compiling/spin_inversion_gauge.py +2 -2
- cirq/transformers/gauge_compiling/sqrt_cz_gauge.py +23 -5
- cirq/transformers/gauge_compiling/sqrt_iswap_gauge.py +3 -2
- cirq/transformers/heuristic_decompositions/__init__.py +3 -3
- cirq/transformers/heuristic_decompositions/gate_tabulation_math_utils.py +2 -1
- cirq/transformers/heuristic_decompositions/gate_tabulation_math_utils_test.py +1 -1
- cirq/transformers/heuristic_decompositions/two_qubit_gate_tabulation.py +4 -4
- cirq/transformers/heuristic_decompositions/two_qubit_gate_tabulation_test.py +4 -4
- cirq/transformers/insertion_sort.py +64 -0
- cirq/transformers/insertion_sort_test.py +34 -0
- cirq/transformers/measurement_transformers.py +14 -1
- cirq/transformers/measurement_transformers_test.py +35 -0
- cirq/transformers/merge_k_qubit_gates.py +2 -2
- cirq/transformers/merge_single_qubit_gates.py +1 -1
- cirq/transformers/merge_single_qubit_gates_test.py +1 -1
- cirq/transformers/noise_adding.py +115 -0
- cirq/transformers/noise_adding_test.py +54 -0
- cirq/transformers/optimize_for_target_gateset.py +1 -1
- cirq/transformers/optimize_for_target_gateset_test.py +3 -2
- cirq/transformers/qubit_management_transformers.py +1 -1
- cirq/transformers/randomized_measurements.py +171 -0
- cirq/transformers/randomized_measurements_test.py +68 -0
- cirq/transformers/routing/__init__.py +14 -5
- cirq/transformers/routing/initial_mapper.py +1 -1
- cirq/transformers/routing/initial_mapper_test.py +1 -0
- cirq/transformers/routing/line_initial_mapper.py +3 -2
- cirq/transformers/routing/mapping_manager.py +2 -2
- cirq/transformers/routing/mapping_manager_test.py +2 -2
- cirq/transformers/routing/route_circuit_cqc.py +3 -2
- cirq/transformers/routing/route_circuit_cqc_test.py +2 -1
- cirq/transformers/routing/visualize_routed_circuit.py +1 -0
- cirq/transformers/routing/visualize_routed_circuit_test.py +1 -0
- cirq/transformers/stratify.py +2 -2
- cirq/transformers/synchronize_terminal_measurements.py +2 -1
- cirq/transformers/target_gatesets/__init__.py +7 -5
- cirq/transformers/target_gatesets/compilation_target_gateset.py +16 -3
- cirq/transformers/target_gatesets/compilation_target_gateset_test.py +2 -0
- cirq/transformers/target_gatesets/cz_gateset.py +5 -1
- cirq/transformers/target_gatesets/cz_gateset_test.py +23 -2
- cirq/transformers/target_gatesets/sqrt_iswap_gateset.py +1 -1
- cirq/transformers/target_gatesets/sqrt_iswap_gateset_test.py +3 -2
- cirq/transformers/transformer_api.py +5 -4
- cirq/transformers/transformer_api_test.py +11 -3
- cirq/transformers/transformer_primitives.py +9 -31
- cirq/transformers/transformer_primitives_test.py +6 -5
- cirq/value/__init__.py +51 -30
- cirq/value/abc_alt.py +1 -2
- cirq/value/angle.py +2 -0
- cirq/value/classical_data.py +1 -0
- cirq/value/condition.py +149 -3
- cirq/value/condition_test.py +254 -0
- cirq/value/digits.py +1 -1
- cirq/value/duration.py +4 -4
- cirq/value/duration_test.py +2 -1
- cirq/value/linear_dict.py +85 -24
- cirq/value/linear_dict_test.py +94 -3
- cirq/value/measurement_key.py +9 -2
- cirq/value/periodic_value.py +2 -3
- cirq/value/periodic_value_test.py +5 -0
- cirq/value/probability.py +1 -0
- cirq/value/random_state.py +1 -1
- cirq/value/timestamp.py +2 -4
- cirq/value/timestamp_test.py +2 -1
- cirq/value/type_alias.py +2 -2
- cirq/value/value_equality_attr.py +14 -2
- cirq/value/value_equality_attr_test.py +1 -1
- cirq/vis/__init__.py +9 -6
- cirq/vis/density_matrix.py +1 -1
- cirq/vis/density_matrix_test.py +2 -5
- cirq/vis/heatmap.py +49 -12
- cirq/vis/heatmap_test.py +168 -4
- cirq/vis/histogram.py +1 -1
- cirq/vis/histogram_test.py +1 -2
- cirq/vis/state_histogram.py +7 -5
- cirq/vis/state_histogram_test.py +2 -2
- cirq/work/__init__.py +19 -13
- cirq/work/collector.py +2 -2
- cirq/work/observable_grouping.py +2 -2
- cirq/work/observable_measurement.py +3 -3
- cirq/work/observable_measurement_data.py +5 -2
- cirq/work/observable_measurement_test.py +8 -8
- cirq/work/observable_readout_calibration.py +2 -2
- cirq/work/observable_readout_calibration_test.py +2 -1
- cirq/work/observable_settings.py +8 -7
- cirq/work/observable_settings_test.py +3 -2
- cirq/work/pauli_sum_collector.py +1 -1
- cirq/work/sampler.py +8 -20
- cirq/work/sampler_test.py +4 -3
- cirq/work/zeros_sampler.py +1 -1
- cirq_core-1.5.0.dist-info/METADATA +125 -0
- {cirq_core-1.4.0.dev20240529225110.dist-info → cirq_core-1.5.0.dist-info}/RECORD +586 -552
- {cirq_core-1.4.0.dev20240529225110.dist-info → cirq_core-1.5.0.dist-info}/WHEEL +1 -1
- cirq/experiments/grid_parallel_two_qubit_xeb.py +0 -62
- cirq/protocols/json_test_data/GridParallelXEBMetadata.json +0 -119
- cirq/protocols/json_test_data/GridParallelXEBMetadata.repr +0 -1
- cirq_core-1.4.0.dev20240529225110.dist-info/METADATA +0 -50
- {cirq_core-1.4.0.dev20240529225110.dist-info → cirq_core-1.5.0.dist-info}/LICENSE +0 -0
- {cirq_core-1.4.0.dev20240529225110.dist-info → cirq_core-1.5.0.dist-info}/top_level.txt +0 -0
cirq/devices/noise_model.py
CHANGED
|
@@ -12,11 +12,13 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
from typing import Any, Callable, Dict, Iterable, Sequence, TYPE_CHECKING, Union
|
|
16
18
|
|
|
17
19
|
from cirq import ops, protocols, value
|
|
18
|
-
from cirq._import import LazyLoader
|
|
19
20
|
from cirq._doc import document
|
|
21
|
+
from cirq._import import LazyLoader
|
|
20
22
|
|
|
21
23
|
moment_module = LazyLoader("moment_module", globals(), "cirq.circuits.moment")
|
|
22
24
|
|
|
@@ -41,7 +43,7 @@ class NoiseModel(metaclass=value.ABCMetaImplementAnyOneOf):
|
|
|
41
43
|
"""
|
|
42
44
|
|
|
43
45
|
@classmethod
|
|
44
|
-
def from_noise_model_like(cls, noise:
|
|
46
|
+
def from_noise_model_like(cls, noise: cirq.NOISE_MODEL_LIKE) -> cirq.NoiseModel:
|
|
45
47
|
"""Transforms an object into a noise model if unambiguously possible.
|
|
46
48
|
|
|
47
49
|
Args:
|
|
@@ -76,7 +78,7 @@ class NoiseModel(metaclass=value.ABCMetaImplementAnyOneOf):
|
|
|
76
78
|
f'or a single qubit gate). Got {noise!r}'
|
|
77
79
|
)
|
|
78
80
|
|
|
79
|
-
def is_virtual_moment(self, moment:
|
|
81
|
+
def is_virtual_moment(self, moment: cirq.Moment) -> bool:
|
|
80
82
|
"""Returns true iff the given moment is non-empty and all of its
|
|
81
83
|
operations are virtual.
|
|
82
84
|
|
|
@@ -95,16 +97,16 @@ class NoiseModel(metaclass=value.ABCMetaImplementAnyOneOf):
|
|
|
95
97
|
return all(ops.VirtualTag() in op.tags for op in moment)
|
|
96
98
|
|
|
97
99
|
def _noisy_moments_impl_moment(
|
|
98
|
-
self, moments: Iterable[
|
|
99
|
-
) -> Sequence[
|
|
100
|
+
self, moments: Iterable[cirq.Moment], system_qubits: Sequence[cirq.Qid]
|
|
101
|
+
) -> Sequence[cirq.OP_TREE]:
|
|
100
102
|
result = []
|
|
101
103
|
for moment in moments:
|
|
102
104
|
result.append(self.noisy_moment(moment, system_qubits))
|
|
103
105
|
return result
|
|
104
106
|
|
|
105
107
|
def _noisy_moments_impl_operation(
|
|
106
|
-
self, moments: Iterable[
|
|
107
|
-
) -> Sequence[
|
|
108
|
+
self, moments: Iterable[cirq.Moment], system_qubits: Sequence[cirq.Qid]
|
|
109
|
+
) -> Sequence[cirq.OP_TREE]:
|
|
108
110
|
result = []
|
|
109
111
|
for moment in moments:
|
|
110
112
|
result.append([self.noisy_operation(op) for op in moment])
|
|
@@ -113,8 +115,8 @@ class NoiseModel(metaclass=value.ABCMetaImplementAnyOneOf):
|
|
|
113
115
|
@value.alternative(requires='noisy_moment', implementation=_noisy_moments_impl_moment)
|
|
114
116
|
@value.alternative(requires='noisy_operation', implementation=_noisy_moments_impl_operation)
|
|
115
117
|
def noisy_moments(
|
|
116
|
-
self, moments: Iterable[
|
|
117
|
-
) -> Sequence[
|
|
118
|
+
self, moments: Iterable[cirq.Moment], system_qubits: Sequence[cirq.Qid]
|
|
119
|
+
) -> Sequence[cirq.OP_TREE]:
|
|
118
120
|
"""Adds possibly stateful noise to a series of moments.
|
|
119
121
|
|
|
120
122
|
Args:
|
|
@@ -128,20 +130,18 @@ class NoiseModel(metaclass=value.ABCMetaImplementAnyOneOf):
|
|
|
128
130
|
raise NotImplementedError
|
|
129
131
|
|
|
130
132
|
def _noisy_moment_impl_moments(
|
|
131
|
-
self, moment:
|
|
132
|
-
) ->
|
|
133
|
+
self, moment: cirq.Moment, system_qubits: Sequence[cirq.Qid]
|
|
134
|
+
) -> cirq.OP_TREE:
|
|
133
135
|
return self.noisy_moments([moment], system_qubits)
|
|
134
136
|
|
|
135
137
|
def _noisy_moment_impl_operation(
|
|
136
|
-
self, moment:
|
|
137
|
-
) ->
|
|
138
|
+
self, moment: cirq.Moment, system_qubits: Sequence[cirq.Qid]
|
|
139
|
+
) -> cirq.OP_TREE:
|
|
138
140
|
return [self.noisy_operation(op) for op in moment]
|
|
139
141
|
|
|
140
142
|
@value.alternative(requires='noisy_moments', implementation=_noisy_moment_impl_moments)
|
|
141
143
|
@value.alternative(requires='noisy_operation', implementation=_noisy_moment_impl_operation)
|
|
142
|
-
def noisy_moment(
|
|
143
|
-
self, moment: 'cirq.Moment', system_qubits: Sequence['cirq.Qid']
|
|
144
|
-
) -> 'cirq.OP_TREE':
|
|
144
|
+
def noisy_moment(self, moment: cirq.Moment, system_qubits: Sequence[cirq.Qid]) -> cirq.OP_TREE:
|
|
145
145
|
"""Adds noise to the operations from a moment.
|
|
146
146
|
|
|
147
147
|
Args:
|
|
@@ -153,15 +153,15 @@ class NoiseModel(metaclass=value.ABCMetaImplementAnyOneOf):
|
|
|
153
153
|
"""
|
|
154
154
|
raise NotImplementedError
|
|
155
155
|
|
|
156
|
-
def _noisy_operation_impl_moments(self, operation:
|
|
156
|
+
def _noisy_operation_impl_moments(self, operation: cirq.Operation) -> cirq.OP_TREE:
|
|
157
157
|
return self.noisy_moments([moment_module.Moment([operation])], operation.qubits)
|
|
158
158
|
|
|
159
|
-
def _noisy_operation_impl_moment(self, operation:
|
|
159
|
+
def _noisy_operation_impl_moment(self, operation: cirq.Operation) -> cirq.OP_TREE:
|
|
160
160
|
return self.noisy_moment(moment_module.Moment([operation]), operation.qubits)
|
|
161
161
|
|
|
162
162
|
@value.alternative(requires='noisy_moments', implementation=_noisy_operation_impl_moments)
|
|
163
163
|
@value.alternative(requires='noisy_moment', implementation=_noisy_operation_impl_moment)
|
|
164
|
-
def noisy_operation(self, operation:
|
|
164
|
+
def noisy_operation(self, operation: cirq.Operation) -> cirq.OP_TREE:
|
|
165
165
|
"""Adds noise to an individual operation.
|
|
166
166
|
|
|
167
167
|
Args:
|
|
@@ -178,15 +178,13 @@ class NoiseModel(metaclass=value.ABCMetaImplementAnyOneOf):
|
|
|
178
178
|
class _NoNoiseModel(NoiseModel):
|
|
179
179
|
"""A default noise model that adds no noise."""
|
|
180
180
|
|
|
181
|
-
def noisy_moments(self, moments: Iterable[
|
|
181
|
+
def noisy_moments(self, moments: Iterable[cirq.Moment], system_qubits: Sequence[cirq.Qid]):
|
|
182
182
|
return list(moments)
|
|
183
183
|
|
|
184
|
-
def noisy_moment(
|
|
185
|
-
self, moment: 'cirq.Moment', system_qubits: Sequence['cirq.Qid']
|
|
186
|
-
) -> 'cirq.Moment':
|
|
184
|
+
def noisy_moment(self, moment: cirq.Moment, system_qubits: Sequence[cirq.Qid]) -> cirq.Moment:
|
|
187
185
|
return moment
|
|
188
186
|
|
|
189
|
-
def noisy_operation(self, operation:
|
|
187
|
+
def noisy_operation(self, operation: cirq.Operation) -> cirq.Operation:
|
|
190
188
|
return operation
|
|
191
189
|
|
|
192
190
|
def _value_equality_values_(self) -> Any:
|
|
@@ -216,7 +214,7 @@ class ConstantQubitNoiseModel(NoiseModel):
|
|
|
216
214
|
operation is given as "the noise to use" for a `NOISE_MODEL_LIKE` parameter.
|
|
217
215
|
"""
|
|
218
216
|
|
|
219
|
-
def __init__(self, qubit_noise_gate:
|
|
217
|
+
def __init__(self, qubit_noise_gate: cirq.Gate, prepend: bool = False):
|
|
220
218
|
"""Noise model which applies a specific gate as noise to all gates.
|
|
221
219
|
|
|
222
220
|
Args:
|
|
@@ -237,7 +235,7 @@ class ConstantQubitNoiseModel(NoiseModel):
|
|
|
237
235
|
def __repr__(self) -> str:
|
|
238
236
|
return f'cirq.ConstantQubitNoiseModel({self.qubit_noise_gate!r})'
|
|
239
237
|
|
|
240
|
-
def noisy_moment(self, moment:
|
|
238
|
+
def noisy_moment(self, moment: cirq.Moment, system_qubits: Sequence[cirq.Qid]):
|
|
241
239
|
# Noise should not be appended to previously-added noise.
|
|
242
240
|
if self.is_virtual_moment(moment):
|
|
243
241
|
return moment
|
|
@@ -260,7 +258,7 @@ class ConstantQubitNoiseModel(NoiseModel):
|
|
|
260
258
|
|
|
261
259
|
|
|
262
260
|
class GateSubstitutionNoiseModel(NoiseModel):
|
|
263
|
-
def __init__(self, substitution_func: Callable[[
|
|
261
|
+
def __init__(self, substitution_func: Callable[[cirq.Operation], cirq.Operation]):
|
|
264
262
|
"""Noise model which replaces operations using a substitution function.
|
|
265
263
|
|
|
266
264
|
Args:
|
|
@@ -268,13 +266,11 @@ class GateSubstitutionNoiseModel(NoiseModel):
|
|
|
268
266
|
"""
|
|
269
267
|
self.substitution_func = substitution_func
|
|
270
268
|
|
|
271
|
-
def noisy_moment(
|
|
272
|
-
self, moment: 'cirq.Moment', system_qubits: Sequence['cirq.Qid']
|
|
273
|
-
) -> 'cirq.OP_TREE':
|
|
269
|
+
def noisy_moment(self, moment: cirq.Moment, system_qubits: Sequence[cirq.Qid]) -> cirq.OP_TREE:
|
|
274
270
|
return moment_module.Moment([self.substitution_func(op) for op in moment.operations])
|
|
275
271
|
|
|
276
272
|
|
|
277
|
-
NO_NOISE:
|
|
273
|
+
NO_NOISE: cirq.NoiseModel = _NoNoiseModel()
|
|
278
274
|
document(
|
|
279
275
|
NO_NOISE,
|
|
280
276
|
"""The trivial noise model with no effects.
|
|
@@ -298,7 +294,7 @@ document(
|
|
|
298
294
|
)
|
|
299
295
|
|
|
300
296
|
|
|
301
|
-
def validate_all_measurements(moment:
|
|
297
|
+
def validate_all_measurements(moment: cirq.Moment) -> bool:
|
|
302
298
|
"""Ensures that the moment is homogenous and returns whether all ops are measurement gates.
|
|
303
299
|
|
|
304
300
|
Args:
|
cirq/devices/noise_properties.py
CHANGED
|
@@ -20,9 +20,9 @@ noise models to produce a single noise model which replicates device noise.
|
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
22
|
import abc
|
|
23
|
-
from typing import Iterable, Sequence, TYPE_CHECKING
|
|
23
|
+
from typing import Iterable, List, Sequence, TYPE_CHECKING
|
|
24
24
|
|
|
25
|
-
from cirq import _import, ops, protocols
|
|
25
|
+
from cirq import _import, devices, ops, protocols
|
|
26
26
|
from cirq.devices.noise_utils import PHYSICAL_GATE_TAG
|
|
27
27
|
|
|
28
28
|
circuits = _import.LazyLoader("circuits", globals(), "cirq.circuits.circuit")
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
from typing import List, Tuple
|
|
16
|
-
import cirq
|
|
17
16
|
|
|
17
|
+
import cirq
|
|
18
18
|
from cirq.devices.insertion_noise_model import InsertionNoiseModel
|
|
19
|
-
from cirq.devices.noise_properties import
|
|
19
|
+
from cirq.devices.noise_properties import NoiseModelFromNoiseProperties, NoiseProperties
|
|
20
20
|
from cirq.devices.noise_utils import OpIdentifier, PHYSICAL_GATE_TAG
|
|
21
21
|
|
|
22
22
|
|
cirq/devices/noise_utils.py
CHANGED
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from typing import
|
|
15
|
+
from typing import Any, Dict, Tuple, Type, TYPE_CHECKING, Union
|
|
16
16
|
|
|
17
|
-
from cirq import ops, protocols,
|
|
18
|
-
from cirq._compat import
|
|
17
|
+
from cirq import ops, protocols, qis, value
|
|
18
|
+
from cirq._compat import deprecated, proper_repr
|
|
19
19
|
|
|
20
20
|
if TYPE_CHECKING:
|
|
21
21
|
import cirq
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
import abc
|
|
19
19
|
from dataclasses import dataclass, field
|
|
20
20
|
from functools import cached_property
|
|
21
|
-
from typing import Dict,
|
|
21
|
+
from typing import Dict, List, Set, Type, TYPE_CHECKING
|
|
22
22
|
|
|
23
|
-
from cirq import
|
|
23
|
+
from cirq import devices, ops, qis
|
|
24
24
|
from cirq.devices import noise_utils
|
|
25
25
|
|
|
26
26
|
if TYPE_CHECKING:
|
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
from typing import Dict, List, Set, Tuple
|
|
16
|
+
|
|
16
17
|
import numpy as np
|
|
17
|
-
import cirq
|
|
18
18
|
import pytest
|
|
19
19
|
|
|
20
|
+
import cirq
|
|
20
21
|
from cirq.devices.noise_properties import NoiseModelFromNoiseProperties
|
|
22
|
+
from cirq.devices.noise_utils import OpIdentifier, PHYSICAL_GATE_TAG
|
|
21
23
|
from cirq.devices.superconducting_qubits_noise_properties import (
|
|
22
24
|
SuperconductingQubitsNoiseProperties,
|
|
23
25
|
)
|
|
24
|
-
from cirq.devices.noise_utils import OpIdentifier, PHYSICAL_GATE_TAG
|
|
25
|
-
|
|
26
26
|
|
|
27
27
|
DEFAULT_GATE_NS: Dict[type, float] = {
|
|
28
28
|
cirq.ZPowGate: 25.0,
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
import dataclasses
|
|
16
16
|
import functools
|
|
17
|
-
from typing import
|
|
17
|
+
from typing import Dict, List, Optional, Sequence, Set, Tuple, TYPE_CHECKING, Union
|
|
18
|
+
|
|
18
19
|
import numpy as np
|
|
19
20
|
import sympy
|
|
20
21
|
|
|
@@ -23,3 +23,9 @@ def test_infinitely_fast():
|
|
|
23
23
|
assert cirq.UNCONSTRAINED_DEVICE.duration_of(cirq.X(cirq.NamedQubit('a'))) == cirq.Duration(
|
|
24
24
|
picos=0
|
|
25
25
|
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_any_qubit_works():
|
|
29
|
+
moment = cirq.Moment([cirq.X(cirq.LineQubit(987654321))])
|
|
30
|
+
cirq.UNCONSTRAINED_DEVICE.validate_moment(moment)
|
|
31
|
+
cirq.UNCONSTRAINED_DEVICE.validate_circuit(cirq.Circuit(moment))
|
cirq/experiments/__init__.py
CHANGED
|
@@ -14,60 +14,77 @@
|
|
|
14
14
|
"""Experiments and tools for characterizing quantum operations."""
|
|
15
15
|
|
|
16
16
|
from cirq.experiments.qubit_characterizations import (
|
|
17
|
-
RandomizedBenchMarkResult,
|
|
18
|
-
single_qubit_randomized_benchmarking,
|
|
19
|
-
single_qubit_state_tomography,
|
|
20
|
-
TomographyResult,
|
|
21
|
-
two_qubit_randomized_benchmarking,
|
|
22
|
-
two_qubit_state_tomography,
|
|
23
|
-
parallel_single_qubit_randomized_benchmarking,
|
|
17
|
+
RandomizedBenchMarkResult as RandomizedBenchMarkResult,
|
|
18
|
+
single_qubit_randomized_benchmarking as single_qubit_randomized_benchmarking,
|
|
19
|
+
single_qubit_state_tomography as single_qubit_state_tomography,
|
|
20
|
+
TomographyResult as TomographyResult,
|
|
21
|
+
two_qubit_randomized_benchmarking as two_qubit_randomized_benchmarking,
|
|
22
|
+
two_qubit_state_tomography as two_qubit_state_tomography,
|
|
23
|
+
parallel_single_qubit_randomized_benchmarking as parallel_single_qubit_randomized_benchmarking,
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
from cirq.experiments.fidelity_estimation import (
|
|
27
|
-
hog_score_xeb_fidelity_from_probabilities,
|
|
28
|
-
linear_xeb_fidelity_from_probabilities,
|
|
29
|
-
linear_xeb_fidelity,
|
|
30
|
-
log_xeb_fidelity,
|
|
31
|
-
log_xeb_fidelity_from_probabilities,
|
|
32
|
-
xeb_fidelity,
|
|
27
|
+
hog_score_xeb_fidelity_from_probabilities as hog_score_xeb_fidelity_from_probabilities,
|
|
28
|
+
linear_xeb_fidelity_from_probabilities as linear_xeb_fidelity_from_probabilities,
|
|
29
|
+
linear_xeb_fidelity as linear_xeb_fidelity,
|
|
30
|
+
log_xeb_fidelity as log_xeb_fidelity,
|
|
31
|
+
log_xeb_fidelity_from_probabilities as log_xeb_fidelity_from_probabilities,
|
|
32
|
+
xeb_fidelity as xeb_fidelity,
|
|
33
33
|
)
|
|
34
34
|
|
|
35
|
-
from cirq.experiments.purity_estimation import
|
|
35
|
+
from cirq.experiments.purity_estimation import (
|
|
36
|
+
purity_from_probabilities as purity_from_probabilities,
|
|
37
|
+
)
|
|
36
38
|
|
|
37
39
|
from cirq.experiments.random_quantum_circuit_generation import (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
# pylint: disable=line-too-long
|
|
41
|
+
GRID_ALIGNED_PATTERN as GRID_ALIGNED_PATTERN,
|
|
42
|
+
GRID_STAGGERED_PATTERN as GRID_STAGGERED_PATTERN,
|
|
43
|
+
HALF_GRID_STAGGERED_PATTERN as HALF_GRID_STAGGERED_PATTERN,
|
|
44
|
+
GridInteractionLayer as GridInteractionLayer,
|
|
45
|
+
random_rotations_between_grid_interaction_layers_circuit as random_rotations_between_grid_interaction_layers_circuit,
|
|
43
46
|
)
|
|
44
47
|
|
|
45
48
|
from cirq.experiments.readout_confusion_matrix import (
|
|
46
|
-
TensoredConfusionMatrices,
|
|
47
|
-
measure_confusion_matrix,
|
|
49
|
+
TensoredConfusionMatrices as TensoredConfusionMatrices,
|
|
50
|
+
measure_confusion_matrix as measure_confusion_matrix,
|
|
48
51
|
)
|
|
49
52
|
|
|
50
53
|
from cirq.experiments.n_qubit_tomography import (
|
|
51
|
-
get_state_tomography_data,
|
|
52
|
-
state_tomography,
|
|
53
|
-
StateTomographyExperiment,
|
|
54
|
+
get_state_tomography_data as get_state_tomography_data,
|
|
55
|
+
state_tomography as state_tomography,
|
|
56
|
+
StateTomographyExperiment as StateTomographyExperiment,
|
|
54
57
|
)
|
|
55
58
|
|
|
56
59
|
from cirq.experiments.single_qubit_readout_calibration import (
|
|
57
|
-
estimate_parallel_single_qubit_readout_errors,
|
|
58
|
-
estimate_single_qubit_readout_errors,
|
|
59
|
-
SingleQubitReadoutCalibrationResult,
|
|
60
|
+
estimate_parallel_single_qubit_readout_errors as estimate_parallel_single_qubit_readout_errors,
|
|
61
|
+
estimate_single_qubit_readout_errors as estimate_single_qubit_readout_errors,
|
|
62
|
+
SingleQubitReadoutCalibrationResult as SingleQubitReadoutCalibrationResult,
|
|
60
63
|
)
|
|
61
64
|
|
|
62
|
-
from cirq.experiments.t1_decay_experiment import
|
|
65
|
+
from cirq.experiments.t1_decay_experiment import (
|
|
66
|
+
t1_decay as t1_decay,
|
|
67
|
+
T1DecayResult as T1DecayResult,
|
|
68
|
+
)
|
|
63
69
|
|
|
64
|
-
from cirq.experiments.t2_decay_experiment import
|
|
70
|
+
from cirq.experiments.t2_decay_experiment import (
|
|
71
|
+
t2_decay as t2_decay,
|
|
72
|
+
T2DecayResult as T2DecayResult,
|
|
73
|
+
)
|
|
65
74
|
|
|
66
|
-
from cirq.experiments.xeb_fitting import
|
|
75
|
+
from cirq.experiments.xeb_fitting import (
|
|
76
|
+
XEBPhasedFSimCharacterizationOptions as XEBPhasedFSimCharacterizationOptions,
|
|
77
|
+
)
|
|
67
78
|
|
|
68
79
|
from cirq.experiments.two_qubit_xeb import (
|
|
69
|
-
InferredXEBResult,
|
|
70
|
-
TwoQubitXEBResult,
|
|
71
|
-
parallel_two_qubit_xeb,
|
|
72
|
-
run_rb_and_xeb,
|
|
80
|
+
InferredXEBResult as InferredXEBResult,
|
|
81
|
+
TwoQubitXEBResult as TwoQubitXEBResult,
|
|
82
|
+
parallel_two_qubit_xeb as parallel_two_qubit_xeb,
|
|
83
|
+
run_rb_and_xeb as run_rb_and_xeb,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
from cirq.experiments.z_phase_calibration import (
|
|
88
|
+
z_phase_calibration_workflow as z_phase_calibration_workflow,
|
|
89
|
+
calibrate_z_phases as calibrate_z_phases,
|
|
73
90
|
)
|
|
@@ -13,34 +13,33 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
import dataclasses
|
|
16
|
-
import itertools
|
|
17
16
|
import functools
|
|
18
|
-
|
|
17
|
+
import itertools
|
|
19
18
|
from typing import (
|
|
20
19
|
Any,
|
|
21
20
|
cast,
|
|
21
|
+
Dict,
|
|
22
22
|
Iterator,
|
|
23
23
|
List,
|
|
24
|
+
Mapping,
|
|
24
25
|
Optional,
|
|
25
26
|
Sequence,
|
|
26
27
|
Tuple,
|
|
27
28
|
TYPE_CHECKING,
|
|
28
|
-
Mapping,
|
|
29
|
-
Dict,
|
|
30
29
|
)
|
|
31
|
-
import numpy as np
|
|
32
|
-
from scipy.optimize import curve_fit
|
|
33
30
|
|
|
31
|
+
import numpy as np
|
|
34
32
|
from matplotlib import pyplot as plt
|
|
35
|
-
import cirq.vis.heatmap as cirq_heatmap
|
|
36
|
-
import cirq.vis.histogram as cirq_histogram
|
|
37
33
|
|
|
38
34
|
# this is for older systems with matplotlib <3.2 otherwise 3d projections fail
|
|
39
35
|
from mpl_toolkits import mplot3d
|
|
36
|
+
from scipy.optimize import curve_fit
|
|
37
|
+
|
|
38
|
+
import cirq.vis.heatmap as cirq_heatmap
|
|
39
|
+
import cirq.vis.histogram as cirq_histogram
|
|
40
40
|
from cirq import circuits, ops, protocols
|
|
41
41
|
from cirq.devices import grid_qubit
|
|
42
42
|
|
|
43
|
-
|
|
44
43
|
if TYPE_CHECKING:
|
|
45
44
|
import cirq
|
|
46
45
|
|
|
@@ -105,9 +104,8 @@ class RandomizedBenchMarkResult:
|
|
|
105
104
|
The plt.Axes containing the plot.
|
|
106
105
|
"""
|
|
107
106
|
show_plot = not ax
|
|
108
|
-
if
|
|
107
|
+
if ax is None:
|
|
109
108
|
fig, ax = plt.subplots(1, 1, figsize=(8, 8)) # pragma: no cover
|
|
110
|
-
ax = cast(plt.Axes, ax) # pragma: no cover
|
|
111
109
|
ax.set_ylim((0.0, 1.0)) # pragma: no cover
|
|
112
110
|
ax.plot(self._num_cfds_seq, self._gnd_state_probs, 'ro', label='data', **plot_kwargs)
|
|
113
111
|
x = np.linspace(self._num_cfds_seq[0], self._num_cfds_seq[-1], 100)
|
|
@@ -131,7 +129,7 @@ class RandomizedBenchMarkResult:
|
|
|
131
129
|
|
|
132
130
|
$$r_p = (1 - 1/d^2) * (1 - p),$$
|
|
133
131
|
|
|
134
|
-
where $d = 2^N_Q$ is the Hilbert space dimension and $N_Q$ is the number of qubits.
|
|
132
|
+
where $d = 2^{N_Q}$ is the Hilbert space dimension and $N_Q$ is the number of qubits.
|
|
135
133
|
"""
|
|
136
134
|
opt_params, _ = self._fit_exponential()
|
|
137
135
|
p = opt_params[2]
|
|
@@ -287,7 +285,9 @@ class TomographyResult:
|
|
|
287
285
|
"""
|
|
288
286
|
return self._density_matrix
|
|
289
287
|
|
|
290
|
-
def plot(
|
|
288
|
+
def plot(
|
|
289
|
+
self, axes: Optional[List[plt.Axes]] = None, **plot_kwargs: Any
|
|
290
|
+
) -> List[plt.Axes]: # pragma: no cover
|
|
291
291
|
"""Plots the real and imaginary parts of the density matrix as two 3D bar plots.
|
|
292
292
|
|
|
293
293
|
Args:
|
|
@@ -304,7 +304,9 @@ class TomographyResult:
|
|
|
304
304
|
"""
|
|
305
305
|
show_plot = axes is None
|
|
306
306
|
if axes is None:
|
|
307
|
-
fig,
|
|
307
|
+
fig, axes_v = plt.subplots(1, 2, figsize=(12.0, 5.0), subplot_kw={'projection': '3d'})
|
|
308
|
+
axes_v = cast(np.ndarray, axes_v)
|
|
309
|
+
axes = list(axes_v)
|
|
308
310
|
elif len(axes) != 2:
|
|
309
311
|
raise ValueError('A TomographyResult needs 2 axes to plot.')
|
|
310
312
|
mat = self._density_matrix
|
|
@@ -780,7 +782,7 @@ def _matrix_bar_plot(
|
|
|
780
782
|
title: Optional[str] = None,
|
|
781
783
|
ylim: Tuple[int, int] = (-1, 1),
|
|
782
784
|
**bar3d_kwargs: Any,
|
|
783
|
-
) -> None:
|
|
785
|
+
) -> None: # pragma: no cover
|
|
784
786
|
num_rows, num_cols = mat.shape
|
|
785
787
|
indices = np.meshgrid(range(num_cols), range(num_rows))
|
|
786
788
|
x_indices = np.array(indices[1]).flatten()
|
|
@@ -12,21 +12,19 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
import matplotlib.pyplot as plt
|
|
15
16
|
import numpy as np
|
|
16
17
|
import pytest
|
|
17
18
|
|
|
18
|
-
import matplotlib.pyplot as plt
|
|
19
|
-
|
|
20
19
|
import cirq
|
|
21
20
|
import cirq.experiments.qubit_characterizations as ceqc
|
|
22
|
-
from cirq import GridQubit
|
|
23
|
-
from cirq import circuits, ops, sim
|
|
21
|
+
from cirq import circuits, GridQubit, ops, sim
|
|
24
22
|
from cirq.experiments import (
|
|
23
|
+
parallel_single_qubit_randomized_benchmarking,
|
|
25
24
|
single_qubit_randomized_benchmarking,
|
|
26
|
-
two_qubit_randomized_benchmarking,
|
|
27
25
|
single_qubit_state_tomography,
|
|
26
|
+
two_qubit_randomized_benchmarking,
|
|
28
27
|
two_qubit_state_tomography,
|
|
29
|
-
parallel_single_qubit_randomized_benchmarking,
|
|
30
28
|
)
|
|
31
29
|
|
|
32
30
|
|
|
@@ -18,17 +18,17 @@ import itertools
|
|
|
18
18
|
from typing import (
|
|
19
19
|
Any,
|
|
20
20
|
Callable,
|
|
21
|
+
cast,
|
|
21
22
|
Container,
|
|
22
23
|
Dict,
|
|
23
24
|
Iterable,
|
|
25
|
+
Iterator,
|
|
24
26
|
List,
|
|
27
|
+
Optional,
|
|
25
28
|
Sequence,
|
|
26
|
-
TYPE_CHECKING,
|
|
27
29
|
Tuple,
|
|
30
|
+
TYPE_CHECKING,
|
|
28
31
|
Union,
|
|
29
|
-
Optional,
|
|
30
|
-
cast,
|
|
31
|
-
Iterator,
|
|
32
32
|
)
|
|
33
33
|
|
|
34
34
|
import networkx as nx
|
|
@@ -249,6 +249,7 @@ def generate_library_of_2q_circuits(
|
|
|
249
249
|
q0: 'cirq.Qid' = devices.LineQubit(0),
|
|
250
250
|
q1: 'cirq.Qid' = devices.LineQubit(1),
|
|
251
251
|
random_state: 'cirq.RANDOM_STATE_OR_SEED_LIKE' = None,
|
|
252
|
+
tags: Sequence[Any] = (),
|
|
252
253
|
) -> List['cirq.Circuit']:
|
|
253
254
|
"""Generate a library of two-qubit Circuits.
|
|
254
255
|
|
|
@@ -265,6 +266,7 @@ def generate_library_of_2q_circuits(
|
|
|
265
266
|
q0: The first qubit to use when constructing the circuits.
|
|
266
267
|
q1: The second qubit to use when constructing the circuits
|
|
267
268
|
random_state: A random state or seed used to deterministically sample the random circuits.
|
|
269
|
+
tags: Tags to add to the two qubit operations.
|
|
268
270
|
"""
|
|
269
271
|
rs = value.parse_random_state(random_state)
|
|
270
272
|
exponents = np.linspace(0, 7 / 4, 8)
|
|
@@ -277,7 +279,7 @@ def generate_library_of_2q_circuits(
|
|
|
277
279
|
q0,
|
|
278
280
|
q1,
|
|
279
281
|
depth=max_cycle_depth,
|
|
280
|
-
two_qubit_op_factory=lambda a, b, _: two_qubit_gate(a, b),
|
|
282
|
+
two_qubit_op_factory=lambda a, b, _: two_qubit_gate(a, b).with_tags(*tags),
|
|
281
283
|
single_qubit_gates=single_qubit_gates,
|
|
282
284
|
seed=rs,
|
|
283
285
|
)
|
|
@@ -539,9 +541,8 @@ def get_grid_interaction_layer_circuit(
|
|
|
539
541
|
moments = []
|
|
540
542
|
for layer in pattern:
|
|
541
543
|
pairs = sorted(_get_active_pairs(device_graph, layer))
|
|
542
|
-
if
|
|
543
|
-
|
|
544
|
-
moments += [circuits.Moment(two_qubit_gate.on(*pair) for pair in pairs)]
|
|
544
|
+
if pairs:
|
|
545
|
+
moments += [circuits.Moment(two_qubit_gate.on(*pair) for pair in pairs)]
|
|
545
546
|
return circuits.Circuit(moments)
|
|
546
547
|
|
|
547
548
|
|
|
@@ -691,7 +692,7 @@ def _two_qubit_layer(
|
|
|
691
692
|
],
|
|
692
693
|
layer: GridInteractionLayer,
|
|
693
694
|
prng: 'np.random.RandomState',
|
|
694
|
-
) -> 'cirq.OP_TREE':
|
|
695
|
+
) -> Iterator['cirq.OP_TREE']:
|
|
695
696
|
for a, b in coupled_qubit_pairs:
|
|
696
697
|
if (a, b) in layer or (b, a) in layer:
|
|
697
698
|
yield two_qubit_op_factory(a, b, prng)
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
import itertools
|
|
15
|
-
from typing import Callable, Dict, Iterable, List, Optional, Sequence, Set, Tuple
|
|
15
|
+
from typing import Callable, cast, Dict, Iterable, List, Optional, Sequence, Set, Tuple
|
|
16
16
|
|
|
17
17
|
import networkx as nx
|
|
18
18
|
import numpy as np
|
|
@@ -24,12 +24,12 @@ from cirq.experiments import (
|
|
|
24
24
|
random_rotations_between_grid_interaction_layers_circuit,
|
|
25
25
|
)
|
|
26
26
|
from cirq.experiments.random_quantum_circuit_generation import (
|
|
27
|
-
random_rotations_between_two_qubit_circuit,
|
|
28
27
|
generate_library_of_2q_circuits,
|
|
28
|
+
get_grid_interaction_layer_circuit,
|
|
29
29
|
get_random_combinations_for_device,
|
|
30
|
-
get_random_combinations_for_pairs,
|
|
31
30
|
get_random_combinations_for_layer_circuit,
|
|
32
|
-
|
|
31
|
+
get_random_combinations_for_pairs,
|
|
32
|
+
random_rotations_between_two_qubit_circuit,
|
|
33
33
|
)
|
|
34
34
|
|
|
35
35
|
SINGLE_QUBIT_LAYER = Dict[cirq.GridQubit, Optional[cirq.Gate]]
|
|
@@ -457,3 +457,20 @@ def _coupled_qubit_pairs(
|
|
|
457
457
|
add_pair(cirq.GridQubit(qubit.row + 1, qubit.col))
|
|
458
458
|
|
|
459
459
|
return pairs
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
def test_generate_library_of_2q_circuits_with_tags():
|
|
463
|
+
circuits = generate_library_of_2q_circuits(
|
|
464
|
+
n_library_circuits=5,
|
|
465
|
+
two_qubit_gate=cirq.FSimGate(3, 4),
|
|
466
|
+
max_cycle_depth=13,
|
|
467
|
+
random_state=9,
|
|
468
|
+
tags=('test_tag',),
|
|
469
|
+
)
|
|
470
|
+
assert len(circuits) == 5
|
|
471
|
+
for circuit in circuits:
|
|
472
|
+
for op in circuit.all_operations():
|
|
473
|
+
if cirq.num_qubits(op) == 1:
|
|
474
|
+
continue
|
|
475
|
+
assert op.tags == ('test_tag',)
|
|
476
|
+
assert op.gate == cirq.FSimGate(3, 4)
|