diff --git a/cirq-aqt/cirq_aqt/__init__.py b/cirq-aqt/cirq_aqt/__init__.py index 7a5be7e17e0..770a351467c 100644 --- a/cirq-aqt/cirq_aqt/__init__.py +++ b/cirq-aqt/cirq_aqt/__init__.py @@ -14,7 +14,9 @@ """Types and methods related to the AQT ion trap device""" -from cirq_aqt._version import __version__ - -from cirq_aqt.aqt_sampler import AQTSampler, AQTSamplerLocalSimulator -from cirq_aqt.aqt_device import AQTSimulator +from cirq_aqt._version import __version__ as __version__ +from cirq_aqt.aqt_sampler import ( + AQTSampler as AQTSampler, + AQTSamplerLocalSimulator as AQTSamplerLocalSimulator, +) +from cirq_aqt.aqt_device import AQTSimulator as AQTSimulator diff --git a/cirq-aqt/cirq_aqt/json_test_data/__init__.py b/cirq-aqt/cirq_aqt/json_test_data/__init__.py index 2e3b8935226..5a78a371191 100644 --- a/cirq-aqt/cirq_aqt/json_test_data/__init__.py +++ b/cirq-aqt/cirq_aqt/json_test_data/__init__.py @@ -17,4 +17,4 @@ # cirq/protocols/json_serialization_test.py which checks for coverage of # public classes and tests the correctness of repr and json results -from cirq_aqt.json_test_data.spec import TestSpec +from cirq_aqt.json_test_data.spec import TestSpec as TestSpec diff --git a/cirq-core/cirq/__init__.py b/cirq-core/cirq/__init__.py index 0a35b2b5687..15a014d16f1 100644 --- a/cirq-core/cirq/__init__.py +++ b/cirq-core/cirq/__init__.py @@ -16,7 +16,7 @@ from cirq import _import -from cirq._compat import __cirq_debug__, with_debug +from cirq._compat import __cirq_debug__ as __cirq_debug__, with_debug as with_debug # A module can only depend on modules imported earlier in this list of modules # at import time. Pytest will fail otherwise (enforced by @@ -59,615 +59,632 @@ # End dependency order list of sub-modules -from cirq._version import __version__ +from cirq._version import __version__ as __version__ # Flattened sub-modules. from cirq.circuits import ( - AbstractCircuit, - Alignment, - Circuit, - CircuitOperation, - FrozenCircuit, - InsertStrategy, - Moment, - PointOptimizationSummary, - PointOptimizer, - QasmOutput, - TextDiagramDrawer, + AbstractCircuit as AbstractCircuit, + Alignment as Alignment, + Circuit as Circuit, + CircuitOperation as CircuitOperation, + FrozenCircuit as FrozenCircuit, + InsertStrategy as InsertStrategy, + Moment as Moment, + PointOptimizationSummary as PointOptimizationSummary, + PointOptimizer as PointOptimizer, + QasmOutput as QasmOutput, + TextDiagramDrawer as TextDiagramDrawer, ) from cirq.devices import ( - ConstantQubitNoiseModel, - Device, - DeviceMetadata, - GridDeviceMetadata, - GridQid, - GridQubit, - LineQid, - LineQubit, - NO_NOISE, - NOISE_MODEL_LIKE, - NoiseModel, - NoiseModelFromNoiseProperties, - NoiseProperties, - OpIdentifier, - SuperconductingQubitsNoiseProperties, - UNCONSTRAINED_DEVICE, - NamedTopology, - draw_gridlike, - LineTopology, - TiltedSquareLattice, - get_placements, - is_valid_placement, - draw_placements, + ConstantQubitNoiseModel as ConstantQubitNoiseModel, + Device as Device, + DeviceMetadata as DeviceMetadata, + GridDeviceMetadata as GridDeviceMetadata, + GridQid as GridQid, + GridQubit as GridQubit, + LineQid as LineQid, + LineQubit as LineQubit, + NO_NOISE as NO_NOISE, + NOISE_MODEL_LIKE as NOISE_MODEL_LIKE, + NoiseModel as NoiseModel, + NoiseModelFromNoiseProperties as NoiseModelFromNoiseProperties, + NoiseProperties as NoiseProperties, + OpIdentifier as OpIdentifier, + SuperconductingQubitsNoiseProperties as SuperconductingQubitsNoiseProperties, + UNCONSTRAINED_DEVICE as UNCONSTRAINED_DEVICE, + NamedTopology as NamedTopology, + draw_gridlike as draw_gridlike, + LineTopology as LineTopology, + TiltedSquareLattice as TiltedSquareLattice, + get_placements as get_placements, + is_valid_placement as is_valid_placement, + draw_placements as draw_placements, ) from cirq.experiments import ( - TensoredConfusionMatrices, - estimate_parallel_single_qubit_readout_errors, - estimate_single_qubit_readout_errors, - hog_score_xeb_fidelity_from_probabilities, - linear_xeb_fidelity, - linear_xeb_fidelity_from_probabilities, - log_xeb_fidelity, - log_xeb_fidelity_from_probabilities, - measure_confusion_matrix, - xeb_fidelity, + TensoredConfusionMatrices as TensoredConfusionMatrices, + estimate_parallel_single_qubit_readout_errors as estimate_parallel_single_qubit_readout_errors, + estimate_single_qubit_readout_errors as estimate_single_qubit_readout_errors, + hog_score_xeb_fidelity_from_probabilities as hog_score_xeb_fidelity_from_probabilities, + linear_xeb_fidelity as linear_xeb_fidelity, + linear_xeb_fidelity_from_probabilities as linear_xeb_fidelity_from_probabilities, + log_xeb_fidelity as log_xeb_fidelity, + log_xeb_fidelity_from_probabilities as log_xeb_fidelity_from_probabilities, + measure_confusion_matrix as measure_confusion_matrix, + xeb_fidelity as xeb_fidelity, ) -from cirq.interop import quirk_json_to_circuit, quirk_url_to_circuit +from cirq.interop import ( + quirk_json_to_circuit as quirk_json_to_circuit, + quirk_url_to_circuit as quirk_url_to_circuit, +) from cirq.linalg import ( - all_near_zero, - all_near_zero_mod, - allclose_up_to_global_phase, - apply_matrix_to_slices, - axis_angle, - AxisAngleDecomposition, - bidiagonalize_real_matrix_pair_with_symmetric_products, - bidiagonalize_unitary_with_special_orthogonals, - block_diag, - CONTROL_TAG, - deconstruct_single_qubit_matrix_into_angles, - density_matrix_kronecker_product, - diagonalize_real_symmetric_and_sorted_diagonal_matrices, - diagonalize_real_symmetric_matrix, - dot, - expand_matrix_in_orthogonal_basis, - hilbert_schmidt_inner_product, - is_cptp, - is_diagonal, - is_hermitian, - is_normal, - is_orthogonal, - is_special_orthogonal, - is_special_unitary, - is_unitary, - kak_canonicalize_vector, - kak_decomposition, - kak_vector, - KakDecomposition, - kron, - kron_bases, - kron_factor_4x4_to_2x2s, - kron_with_controls, - map_eigenvalues, - match_global_phase, - matrix_commutes, - matrix_from_basis_coefficients, - num_cnots_required, - partial_trace, - partial_trace_of_state_vector_as_mixture, - PAULI_BASIS, - scatter_plot_normalized_kak_interaction_coefficients, - pow_pauli_combination, - reflection_matrix_pow, - slice_for_qubits_equal_to, - state_vector_kronecker_product, - so4_to_magic_su2s, - sub_state_vector, - targeted_conjugate_about, - targeted_left_multiply, - to_special, - unitary_eig, + # pylint: disable=line-too-long + all_near_zero as all_near_zero, + all_near_zero_mod as all_near_zero_mod, + allclose_up_to_global_phase as allclose_up_to_global_phase, + apply_matrix_to_slices as apply_matrix_to_slices, + axis_angle as axis_angle, + AxisAngleDecomposition as AxisAngleDecomposition, + bidiagonalize_real_matrix_pair_with_symmetric_products as bidiagonalize_real_matrix_pair_with_symmetric_products, + bidiagonalize_unitary_with_special_orthogonals as bidiagonalize_unitary_with_special_orthogonals, + block_diag as block_diag, + CONTROL_TAG as CONTROL_TAG, + deconstruct_single_qubit_matrix_into_angles as deconstruct_single_qubit_matrix_into_angles, + density_matrix_kronecker_product as density_matrix_kronecker_product, + diagonalize_real_symmetric_and_sorted_diagonal_matrices as diagonalize_real_symmetric_and_sorted_diagonal_matrices, + diagonalize_real_symmetric_matrix as diagonalize_real_symmetric_matrix, + dot as dot, + expand_matrix_in_orthogonal_basis as expand_matrix_in_orthogonal_basis, + hilbert_schmidt_inner_product as hilbert_schmidt_inner_product, + is_cptp as is_cptp, + is_diagonal as is_diagonal, + is_hermitian as is_hermitian, + is_normal as is_normal, + is_orthogonal as is_orthogonal, + is_special_orthogonal as is_special_orthogonal, + is_special_unitary as is_special_unitary, + is_unitary as is_unitary, + kak_canonicalize_vector as kak_canonicalize_vector, + kak_decomposition as kak_decomposition, + kak_vector as kak_vector, + KakDecomposition as KakDecomposition, + kron as kron, + kron_bases as kron_bases, + kron_factor_4x4_to_2x2s as kron_factor_4x4_to_2x2s, + kron_with_controls as kron_with_controls, + map_eigenvalues as map_eigenvalues, + match_global_phase as match_global_phase, + matrix_commutes as matrix_commutes, + matrix_from_basis_coefficients as matrix_from_basis_coefficients, + num_cnots_required as num_cnots_required, + partial_trace as partial_trace, + partial_trace_of_state_vector_as_mixture as partial_trace_of_state_vector_as_mixture, + PAULI_BASIS as PAULI_BASIS, + scatter_plot_normalized_kak_interaction_coefficients as scatter_plot_normalized_kak_interaction_coefficients, + pow_pauli_combination as pow_pauli_combination, + reflection_matrix_pow as reflection_matrix_pow, + slice_for_qubits_equal_to as slice_for_qubits_equal_to, + state_vector_kronecker_product as state_vector_kronecker_product, + so4_to_magic_su2s as so4_to_magic_su2s, + sub_state_vector as sub_state_vector, + targeted_conjugate_about as targeted_conjugate_about, + targeted_left_multiply as targeted_left_multiply, + to_special as to_special, + unitary_eig as unitary_eig, ) from cirq.ops import ( - amplitude_damp, - AmplitudeDampingChannel, - AnyIntegerPowerGateFamily, - AnyUnitaryGateFamily, - ArithmeticGate, - asymmetric_depolarize, - AsymmetricDepolarizingChannel, - BaseDensePauliString, - bit_flip, - BitFlipChannel, - BooleanHamiltonianGate, - CCX, - CCXPowGate, - CCZ, - CCZPowGate, - CCNOT, - CCNotPowGate, - ClassicallyControlledOperation, - CliffordGate, - CNOT, - CNotPowGate, - ControlledGate, - ControlledOperation, - cphase, - CSWAP, - CSwapGate, - CX, - CXPowGate, - CZ, - CZPowGate, - DensePauliString, - depolarize, - DepolarizingChannel, - DiagonalGate, - EigenGate, - flatten_op_tree, - flatten_to_ops, - flatten_to_ops_or_moments, - FREDKIN, - freeze_op_tree, - FSimGate, - Gate, - GateFamily, - GateOperation, - Gateset, - generalized_amplitude_damp, - GeneralizedAmplitudeDampingChannel, - givens, - GlobalPhaseGate, - global_phase_operation, - GreedyQubitManager, - H, - HPowGate, - I, - identity_each, - IdentityGate, - InterchangeableQubitsGate, - ISWAP, - ISwapPowGate, - ISWAP_INV, - KrausChannel, - LinearCombinationOfGates, - LinearCombinationOfOperations, - MatrixGate, - MixedUnitaryChannel, - M, - MSGate, - measure, - measure_each, - measure_paulistring_terms, - measure_single_paulistring, - MeasurementGate, - MutableDensePauliString, - MutablePauliString, - ms, - NamedQubit, - NamedQid, - OP_TREE, - Operation, - ParallelGate, - ParallelGateFamily, - parallel_gate_op, - Pauli, - PAULI_GATE_LIKE, - PAULI_STRING_LIKE, - PauliInteractionGate, - PauliMeasurementGate, - PauliString, - PauliStringGateOperation, - PauliStringPhasor, - PauliStringPhasorGate, - PauliSum, - PauliSumExponential, - PauliSumLike, - phase_damp, - phase_flip, - PhaseDampingChannel, - PhaseGradientGate, - PhasedFSimGate, - PhasedISwapPowGate, - PhasedXPowGate, - PhasedXZGate, - PhaseFlipChannel, - StatePreparationChannel, - ProductOfSums, - ProjectorString, - ProjectorSum, - RandomGateChannel, - q, - qft, - Qid, - QuantumFourierTransformGate, - QubitManager, - QubitOrder, - QubitOrderOrList, - QubitPermutationGate, - R, - reset, - reset_each, - ResetChannel, - RoutingSwapTag, - riswap, - Rx, - Ry, - Rz, - rx, - ry, - rz, - S, - SimpleQubitManager, - SingleQubitCliffordGate, - SingleQubitPauliStringGateOperation, - SQRT_ISWAP, - SQRT_ISWAP_INV, - SWAP, - SwapPowGate, - SumOfProducts, - T, - TaggedOperation, - ThreeQubitDiagonalGate, - TOFFOLI, - transform_op_tree, - TwoQubitDiagonalGate, - VirtualTag, - wait, - WaitGate, - X, - XPowGate, - XX, - XXPowGate, - Y, - YPowGate, - YY, - YYPowGate, - Z, - ZPowGate, - ZZ, - ZZPowGate, - UniformSuperpositionGate, + amplitude_damp as amplitude_damp, + AmplitudeDampingChannel as AmplitudeDampingChannel, + AnyIntegerPowerGateFamily as AnyIntegerPowerGateFamily, + AnyUnitaryGateFamily as AnyUnitaryGateFamily, + ArithmeticGate as ArithmeticGate, + asymmetric_depolarize as asymmetric_depolarize, + AsymmetricDepolarizingChannel as AsymmetricDepolarizingChannel, + BaseDensePauliString as BaseDensePauliString, + bit_flip as bit_flip, + BitFlipChannel as BitFlipChannel, + BooleanHamiltonianGate as BooleanHamiltonianGate, + CCX as CCX, + CCXPowGate as CCXPowGate, + CCZ as CCZ, + CCZPowGate as CCZPowGate, + CCNOT as CCNOT, + CCNotPowGate as CCNotPowGate, + ClassicallyControlledOperation as ClassicallyControlledOperation, + CliffordGate as CliffordGate, + CNOT as CNOT, + CNotPowGate as CNotPowGate, + ControlledGate as ControlledGate, + ControlledOperation as ControlledOperation, + cphase as cphase, + CSWAP as CSWAP, + CSwapGate as CSwapGate, + CX as CX, + CXPowGate as CXPowGate, + CZ as CZ, + CZPowGate as CZPowGate, + DensePauliString as DensePauliString, + depolarize as depolarize, + DepolarizingChannel as DepolarizingChannel, + DiagonalGate as DiagonalGate, + EigenGate as EigenGate, + flatten_op_tree as flatten_op_tree, + flatten_to_ops as flatten_to_ops, + flatten_to_ops_or_moments as flatten_to_ops_or_moments, + FREDKIN as FREDKIN, + freeze_op_tree as freeze_op_tree, + FSimGate as FSimGate, + Gate as Gate, + GateFamily as GateFamily, + GateOperation as GateOperation, + Gateset as Gateset, + generalized_amplitude_damp as generalized_amplitude_damp, + GeneralizedAmplitudeDampingChannel as GeneralizedAmplitudeDampingChannel, + givens as givens, + GlobalPhaseGate as GlobalPhaseGate, + global_phase_operation as global_phase_operation, + GreedyQubitManager as GreedyQubitManager, + H as H, + HPowGate as HPowGate, + I as I, + identity_each as identity_each, + IdentityGate as IdentityGate, + InterchangeableQubitsGate as InterchangeableQubitsGate, + ISWAP as ISWAP, + ISwapPowGate as ISwapPowGate, + ISWAP_INV as ISWAP_INV, + KrausChannel as KrausChannel, + LinearCombinationOfGates as LinearCombinationOfGates, + LinearCombinationOfOperations as LinearCombinationOfOperations, + MatrixGate as MatrixGate, + MixedUnitaryChannel as MixedUnitaryChannel, + M as M, + MSGate as MSGate, + measure as measure, + measure_each as measure_each, + measure_paulistring_terms as measure_paulistring_terms, + measure_single_paulistring as measure_single_paulistring, + MeasurementGate as MeasurementGate, + MutableDensePauliString as MutableDensePauliString, + MutablePauliString as MutablePauliString, + ms as ms, + NamedQubit as NamedQubit, + NamedQid as NamedQid, + OP_TREE as OP_TREE, + Operation as Operation, + ParallelGate as ParallelGate, + ParallelGateFamily as ParallelGateFamily, + parallel_gate_op as parallel_gate_op, + Pauli as Pauli, + PAULI_GATE_LIKE as PAULI_GATE_LIKE, + PAULI_STRING_LIKE as PAULI_STRING_LIKE, + PauliInteractionGate as PauliInteractionGate, + PauliMeasurementGate as PauliMeasurementGate, + PauliString as PauliString, + PauliStringGateOperation as PauliStringGateOperation, + PauliStringPhasor as PauliStringPhasor, + PauliStringPhasorGate as PauliStringPhasorGate, + PauliSum as PauliSum, + PauliSumExponential as PauliSumExponential, + PauliSumLike as PauliSumLike, + phase_damp as phase_damp, + phase_flip as phase_flip, + PhaseDampingChannel as PhaseDampingChannel, + PhaseGradientGate as PhaseGradientGate, + PhasedFSimGate as PhasedFSimGate, + PhasedISwapPowGate as PhasedISwapPowGate, + PhasedXPowGate as PhasedXPowGate, + PhasedXZGate as PhasedXZGate, + PhaseFlipChannel as PhaseFlipChannel, + StatePreparationChannel as StatePreparationChannel, + ProductOfSums as ProductOfSums, + ProjectorString as ProjectorString, + ProjectorSum as ProjectorSum, + RandomGateChannel as RandomGateChannel, + q as q, + qft as qft, + Qid as Qid, + QuantumFourierTransformGate as QuantumFourierTransformGate, + QubitManager as QubitManager, + QubitOrder as QubitOrder, + QubitOrderOrList as QubitOrderOrList, + QubitPermutationGate as QubitPermutationGate, + R as R, + reset as reset, + reset_each as reset_each, + ResetChannel as ResetChannel, + RoutingSwapTag as RoutingSwapTag, + riswap as riswap, + Rx as Rx, + Ry as Ry, + Rz as Rz, + rx as rx, + ry as ry, + rz as rz, + S as S, + SimpleQubitManager as SimpleQubitManager, + SingleQubitCliffordGate as SingleQubitCliffordGate, + SingleQubitPauliStringGateOperation as SingleQubitPauliStringGateOperation, + SQRT_ISWAP as SQRT_ISWAP, + SQRT_ISWAP_INV as SQRT_ISWAP_INV, + SWAP as SWAP, + SwapPowGate as SwapPowGate, + SumOfProducts as SumOfProducts, + T as T, + TaggedOperation as TaggedOperation, + ThreeQubitDiagonalGate as ThreeQubitDiagonalGate, + TOFFOLI as TOFFOLI, + transform_op_tree as transform_op_tree, + TwoQubitDiagonalGate as TwoQubitDiagonalGate, + VirtualTag as VirtualTag, + wait as wait, + WaitGate as WaitGate, + X as X, + XPowGate as XPowGate, + XX as XX, + XXPowGate as XXPowGate, + Y as Y, + YPowGate as YPowGate, + YY as YY, + YYPowGate as YYPowGate, + Z as Z, + ZPowGate as ZPowGate, + ZZ as ZZ, + ZZPowGate as ZZPowGate, + UniformSuperpositionGate as UniformSuperpositionGate, ) + from cirq.transformers import ( - AbstractInitialMapper, - add_dynamical_decoupling, - align_left, - align_right, - CompilationTargetGateset, - CZTargetGateset, - compute_cphase_exponents_for_fsim_decomposition, - create_transformer_with_kwargs, - decompose_clifford_tableau_to_operations, - decompose_cphase_into_two_fsim, - decompose_multi_controlled_x, - decompose_multi_controlled_rotation, - decompose_two_qubit_interaction_into_four_fsim_gates, - defer_measurements, - dephase_measurements, - drop_empty_moments, - drop_negligible_operations, - drop_terminal_measurements, - eject_phased_paulis, - eject_z, - expand_composite, - HardCodedInitialMapper, - is_negligible_turn, - LineInitialMapper, - MappingManager, - map_clean_and_borrowable_qubits, - map_moments, - map_operations, - map_operations_and_unroll, - merge_k_qubit_unitaries, - merge_k_qubit_unitaries_to_circuit_op, - merge_moments, - merge_operations, - merge_operations_to_circuit_op, - merge_single_qubit_gates_to_phased_x_and_z, - merge_single_qubit_gates_to_phxz, - merge_single_qubit_moments_to_phxz, - optimize_for_target_gateset, - parameterized_2q_op_to_sqrt_iswap_operations, - prepare_two_qubit_state_using_cz, - prepare_two_qubit_state_using_iswap, - prepare_two_qubit_state_using_sqrt_iswap, - quantum_shannon_decomposition, - RouteCQC, - routed_circuit_with_mapping, - SqrtIswapTargetGateset, - single_qubit_matrix_to_gates, - single_qubit_matrix_to_pauli_rotations, - single_qubit_matrix_to_phased_x_z, - single_qubit_matrix_to_phxz, - single_qubit_op_to_framed_phase_form, - stratified_circuit, - synchronize_terminal_measurements, - TRANSFORMER, - TransformerContext, - TransformerLogger, - three_qubit_matrix_to_operations, - transformer, - two_qubit_matrix_to_cz_isometry, - two_qubit_matrix_to_cz_operations, - two_qubit_matrix_to_diagonal_and_cz_operations, - two_qubit_matrix_to_ion_operations, - two_qubit_matrix_to_sqrt_iswap_operations, - two_qubit_gate_product_tabulation, - TwoQubitCompilationTargetGateset, - TwoQubitGateTabulation, - TwoQubitGateTabulationResult, - toggle_tags, - unroll_circuit_op, - unroll_circuit_op_greedy_earliest, - unroll_circuit_op_greedy_frontier, + # pylint: disable=line-too-long + AbstractInitialMapper as AbstractInitialMapper, + add_dynamical_decoupling as add_dynamical_decoupling, + align_left as align_left, + align_right as align_right, + CompilationTargetGateset as CompilationTargetGateset, + CZTargetGateset as CZTargetGateset, + compute_cphase_exponents_for_fsim_decomposition as compute_cphase_exponents_for_fsim_decomposition, + create_transformer_with_kwargs as create_transformer_with_kwargs, + decompose_clifford_tableau_to_operations as decompose_clifford_tableau_to_operations, + decompose_cphase_into_two_fsim as decompose_cphase_into_two_fsim, + decompose_multi_controlled_x as decompose_multi_controlled_x, + decompose_multi_controlled_rotation as decompose_multi_controlled_rotation, + decompose_two_qubit_interaction_into_four_fsim_gates as decompose_two_qubit_interaction_into_four_fsim_gates, + defer_measurements as defer_measurements, + dephase_measurements as dephase_measurements, + drop_empty_moments as drop_empty_moments, + drop_negligible_operations as drop_negligible_operations, + drop_terminal_measurements as drop_terminal_measurements, + eject_phased_paulis as eject_phased_paulis, + eject_z as eject_z, + expand_composite as expand_composite, + HardCodedInitialMapper as HardCodedInitialMapper, + is_negligible_turn as is_negligible_turn, + LineInitialMapper as LineInitialMapper, + MappingManager as MappingManager, + map_clean_and_borrowable_qubits as map_clean_and_borrowable_qubits, + map_moments as map_moments, + map_operations as map_operations, + map_operations_and_unroll as map_operations_and_unroll, + merge_k_qubit_unitaries as merge_k_qubit_unitaries, + merge_k_qubit_unitaries_to_circuit_op as merge_k_qubit_unitaries_to_circuit_op, + merge_moments as merge_moments, + merge_operations as merge_operations, + merge_operations_to_circuit_op as merge_operations_to_circuit_op, + merge_single_qubit_gates_to_phased_x_and_z as merge_single_qubit_gates_to_phased_x_and_z, + merge_single_qubit_gates_to_phxz as merge_single_qubit_gates_to_phxz, + merge_single_qubit_moments_to_phxz as merge_single_qubit_moments_to_phxz, + optimize_for_target_gateset as optimize_for_target_gateset, + parameterized_2q_op_to_sqrt_iswap_operations as parameterized_2q_op_to_sqrt_iswap_operations, + prepare_two_qubit_state_using_cz as prepare_two_qubit_state_using_cz, + prepare_two_qubit_state_using_iswap as prepare_two_qubit_state_using_iswap, + prepare_two_qubit_state_using_sqrt_iswap as prepare_two_qubit_state_using_sqrt_iswap, + quantum_shannon_decomposition as quantum_shannon_decomposition, + RouteCQC as RouteCQC, + routed_circuit_with_mapping as routed_circuit_with_mapping, + SqrtIswapTargetGateset as SqrtIswapTargetGateset, + single_qubit_matrix_to_gates as single_qubit_matrix_to_gates, + single_qubit_matrix_to_pauli_rotations as single_qubit_matrix_to_pauli_rotations, + single_qubit_matrix_to_phased_x_z as single_qubit_matrix_to_phased_x_z, + single_qubit_matrix_to_phxz as single_qubit_matrix_to_phxz, + single_qubit_op_to_framed_phase_form as single_qubit_op_to_framed_phase_form, + stratified_circuit as stratified_circuit, + synchronize_terminal_measurements as synchronize_terminal_measurements, + TRANSFORMER as TRANSFORMER, + TransformerContext as TransformerContext, + TransformerLogger as TransformerLogger, + three_qubit_matrix_to_operations as three_qubit_matrix_to_operations, + transformer as transformer, + two_qubit_matrix_to_cz_isometry as two_qubit_matrix_to_cz_isometry, + two_qubit_matrix_to_cz_operations as two_qubit_matrix_to_cz_operations, + two_qubit_matrix_to_diagonal_and_cz_operations as two_qubit_matrix_to_diagonal_and_cz_operations, + two_qubit_matrix_to_ion_operations as two_qubit_matrix_to_ion_operations, + two_qubit_matrix_to_sqrt_iswap_operations as two_qubit_matrix_to_sqrt_iswap_operations, + two_qubit_gate_product_tabulation as two_qubit_gate_product_tabulation, + TwoQubitCompilationTargetGateset as TwoQubitCompilationTargetGateset, + TwoQubitGateTabulation as TwoQubitGateTabulation, + TwoQubitGateTabulationResult as TwoQubitGateTabulationResult, + toggle_tags as toggle_tags, + unroll_circuit_op as unroll_circuit_op, + unroll_circuit_op_greedy_earliest as unroll_circuit_op_greedy_earliest, + unroll_circuit_op_greedy_frontier as unroll_circuit_op_greedy_frontier, ) from cirq.qis import ( - bloch_vector_from_state_vector, - choi_to_kraus, - choi_to_superoperator, - CliffordTableau, - density_matrix, - density_matrix_from_state_vector, - dirac_notation, - entanglement_fidelity, - eye_tensor, - fidelity, - kraus_to_choi, - kraus_to_superoperator, - one_hot, - operation_to_choi, - operation_to_superoperator, - QUANTUM_STATE_LIKE, - QuantumState, - QuantumStateRepresentation, - quantum_state, - STATE_VECTOR_LIKE, - StabilizerState, - superoperator_to_choi, - superoperator_to_kraus, - to_valid_density_matrix, - to_valid_state_vector, - validate_density_matrix, - validate_indices, - validate_normalized_state_vector, - validate_qid_shape, - von_neumann_entropy, + bloch_vector_from_state_vector as bloch_vector_from_state_vector, + choi_to_kraus as choi_to_kraus, + choi_to_superoperator as choi_to_superoperator, + CliffordTableau as CliffordTableau, + density_matrix as density_matrix, + density_matrix_from_state_vector as density_matrix_from_state_vector, + dirac_notation as dirac_notation, + entanglement_fidelity as entanglement_fidelity, + eye_tensor as eye_tensor, + fidelity as fidelity, + kraus_to_choi as kraus_to_choi, + kraus_to_superoperator as kraus_to_superoperator, + one_hot as one_hot, + operation_to_choi as operation_to_choi, + operation_to_superoperator as operation_to_superoperator, + QUANTUM_STATE_LIKE as QUANTUM_STATE_LIKE, + QuantumState as QuantumState, + QuantumStateRepresentation as QuantumStateRepresentation, + quantum_state as quantum_state, + STATE_VECTOR_LIKE as STATE_VECTOR_LIKE, + StabilizerState as StabilizerState, + superoperator_to_choi as superoperator_to_choi, + superoperator_to_kraus as superoperator_to_kraus, + to_valid_density_matrix as to_valid_density_matrix, + to_valid_state_vector as to_valid_state_vector, + validate_density_matrix as validate_density_matrix, + validate_indices as validate_indices, + validate_normalized_state_vector as validate_normalized_state_vector, + validate_qid_shape as validate_qid_shape, + von_neumann_entropy as von_neumann_entropy, ) from cirq.sim import ( - CIRCUIT_LIKE, - ClassicalStateSimulator, - CliffordSimulator, - CliffordState, - CliffordSimulatorStepResult, - CliffordTableauSimulationState, - CliffordTrialResult, - DensityMatrixSimulationState, - DensityMatrixSimulator, - DensityMatrixStepResult, - DensityMatrixTrialResult, - measure_density_matrix, - measure_state_vector, - final_density_matrix, - final_state_vector, - sample, - sample_density_matrix, - sample_state_vector, - sample_sweep, - SimulatesAmplitudes, - SimulatesExpectationValues, - SimulatesFinalState, - SimulatesIntermediateState, - SimulatesIntermediateStateVector, - SimulatesSamples, - SimulationProductState, - SimulationState, - SimulationStateBase, - SimulationTrialResult, - SimulationTrialResultBase, - Simulator, - SimulatorBase, - SparseSimulatorStep, - StabilizerChFormSimulationState, - StabilizerSampler, - StabilizerSimulationState, - StabilizerStateChForm, - StateVectorMixin, - StateVectorSimulationState, - StateVectorStepResult, - StateVectorTrialResult, - StepResult, - StepResultBase, + CIRCUIT_LIKE as CIRCUIT_LIKE, + ClassicalStateSimulator as ClassicalStateSimulator, + CliffordSimulator as CliffordSimulator, + CliffordState as CliffordState, + CliffordSimulatorStepResult as CliffordSimulatorStepResult, + CliffordTableauSimulationState as CliffordTableauSimulationState, + CliffordTrialResult as CliffordTrialResult, + DensityMatrixSimulationState as DensityMatrixSimulationState, + DensityMatrixSimulator as DensityMatrixSimulator, + DensityMatrixStepResult as DensityMatrixStepResult, + DensityMatrixTrialResult as DensityMatrixTrialResult, + measure_density_matrix as measure_density_matrix, + measure_state_vector as measure_state_vector, + final_density_matrix as final_density_matrix, + final_state_vector as final_state_vector, + sample as sample, + sample_density_matrix as sample_density_matrix, + sample_state_vector as sample_state_vector, + sample_sweep as sample_sweep, + SimulatesAmplitudes as SimulatesAmplitudes, + SimulatesExpectationValues as SimulatesExpectationValues, + SimulatesFinalState as SimulatesFinalState, + SimulatesIntermediateState as SimulatesIntermediateState, + SimulatesIntermediateStateVector as SimulatesIntermediateStateVector, + SimulatesSamples as SimulatesSamples, + SimulationProductState as SimulationProductState, + SimulationState as SimulationState, + SimulationStateBase as SimulationStateBase, + SimulationTrialResult as SimulationTrialResult, + SimulationTrialResultBase as SimulationTrialResultBase, + Simulator as Simulator, + SimulatorBase as SimulatorBase, + SparseSimulatorStep as SparseSimulatorStep, + StabilizerChFormSimulationState as StabilizerChFormSimulationState, + StabilizerSampler as StabilizerSampler, + StabilizerSimulationState as StabilizerSimulationState, + StabilizerStateChForm as StabilizerStateChForm, + StateVectorMixin as StateVectorMixin, + StateVectorSimulationState as StateVectorSimulationState, + StateVectorStepResult as StateVectorStepResult, + StateVectorTrialResult as StateVectorTrialResult, + StepResult as StepResult, + StepResultBase as StepResultBase, ) from cirq.study import ( - dict_to_product_sweep, - dict_to_zip_sweep, - ExpressionMap, - flatten, - flatten_with_params, - flatten_with_sweep, - ResultDict, - Linspace, - ListSweep, - ParamDictType, - ParamMappingType, - ParamResolver, - ParamResolverOrSimilarType, - Points, - Product, - Sweep, - Sweepable, - to_resolvers, - to_sweep, - to_sweeps, - Result, - UnitSweep, - UNIT_SWEEP, - Zip, - ZipLongest, + dict_to_product_sweep as dict_to_product_sweep, + dict_to_zip_sweep as dict_to_zip_sweep, + ExpressionMap as ExpressionMap, + flatten as flatten, + flatten_with_params as flatten_with_params, + flatten_with_sweep as flatten_with_sweep, + ResultDict as ResultDict, + Linspace as Linspace, + ListSweep as ListSweep, + ParamDictType as ParamDictType, + ParamMappingType as ParamMappingType, + ParamResolver as ParamResolver, + ParamResolverOrSimilarType as ParamResolverOrSimilarType, + Points as Points, + Product as Product, + Sweep as Sweep, + Sweepable as Sweepable, + to_resolvers as to_resolvers, + to_sweep as to_sweep, + to_sweeps as to_sweeps, + Result as Result, + UnitSweep as UnitSweep, + UNIT_SWEEP as UNIT_SWEEP, + Zip as Zip, + ZipLongest as ZipLongest, ) + from cirq.value import ( - ABCMetaImplementAnyOneOf, - alternative, - big_endian_bits_to_int, - big_endian_digits_to_int, - big_endian_int_to_bits, - big_endian_int_to_digits, - canonicalize_half_turns, - chosen_angle_to_canonical_half_turns, - chosen_angle_to_half_turns, - ClassicalDataDictionaryStore, - ClassicalDataStore, - ClassicalDataStoreReader, - Condition, - Duration, - DURATION_LIKE, - KeyCondition, - LinearDict, - MEASUREMENT_KEY_SEPARATOR, - MeasurementKey, - MeasurementType, - PeriodicValue, - RANDOM_STATE_OR_SEED_LIKE, - state_vector_to_probabilities, - SympyCondition, - Timestamp, - TParamKey, - TParamVal, - TParamValComplex, - validate_probability, - value_equality, - KET_PLUS, - KET_MINUS, - KET_IMAG, - KET_MINUS_IMAG, - KET_ZERO, - KET_ONE, - PAULI_STATES, - ProductState, + ABCMetaImplementAnyOneOf as ABCMetaImplementAnyOneOf, + alternative as alternative, + big_endian_bits_to_int as big_endian_bits_to_int, + big_endian_digits_to_int as big_endian_digits_to_int, + big_endian_int_to_bits as big_endian_int_to_bits, + big_endian_int_to_digits as big_endian_int_to_digits, + canonicalize_half_turns as canonicalize_half_turns, + chosen_angle_to_canonical_half_turns as chosen_angle_to_canonical_half_turns, + chosen_angle_to_half_turns as chosen_angle_to_half_turns, + ClassicalDataDictionaryStore as ClassicalDataDictionaryStore, + ClassicalDataStore as ClassicalDataStore, + ClassicalDataStoreReader as ClassicalDataStoreReader, + Condition as Condition, + Duration as Duration, + DURATION_LIKE as DURATION_LIKE, + KeyCondition as KeyCondition, + LinearDict as LinearDict, + MEASUREMENT_KEY_SEPARATOR as MEASUREMENT_KEY_SEPARATOR, + MeasurementKey as MeasurementKey, + MeasurementType as MeasurementType, + PeriodicValue as PeriodicValue, + RANDOM_STATE_OR_SEED_LIKE as RANDOM_STATE_OR_SEED_LIKE, + state_vector_to_probabilities as state_vector_to_probabilities, + SympyCondition as SympyCondition, + Timestamp as Timestamp, + TParamKey as TParamKey, + TParamVal as TParamVal, + TParamValComplex as TParamValComplex, + validate_probability as validate_probability, + value_equality as value_equality, + KET_PLUS as KET_PLUS, + KET_MINUS as KET_MINUS, + KET_IMAG as KET_IMAG, + KET_MINUS_IMAG as KET_MINUS_IMAG, + KET_ZERO as KET_ZERO, + KET_ONE as KET_ONE, + PAULI_STATES as PAULI_STATES, + ProductState as ProductState, ) # pylint: disable=redefined-builtin from cirq.protocols import ( - act_on, - apply_channel, - apply_mixture, - apply_unitaries, - apply_unitary, - ApplyChannelArgs, - ApplyMixtureArgs, - ApplyUnitaryArgs, - approx_eq, - circuit_diagram_info, - CircuitDiagramInfo, - CircuitDiagramInfoArgs, - cirq_type_from_json, - commutes, - control_keys, - decompose, - decompose_once, - decompose_once_with_qubits, - DecompositionContext, - DEFAULT_RESOLVERS, - definitely_commutes, - equal_up_to_global_phase, - has_kraus, - has_mixture, - has_stabilizer_effect, - has_unitary, - HasJSONNamespace, - inverse, - is_measurement, - is_parameterized, - JsonResolver, - json_cirq_type, - json_namespace, - dataclass_json_dict, - kraus, - LabelEntity, - measurement_key_name, - measurement_key_obj, - measurement_key_names, - measurement_key_objs, - measurement_keys_touched, - mixture, - mul, - num_qubits, - parameter_names, - parameter_symbols, - pauli_expansion, - phase_by, - pow, - qasm, - QasmArgs, - qid_shape, - read_json_gzip, - read_json, - resolve_parameters, - resolve_parameters_once, - SerializableByKey, - SupportsActOn, - SupportsActOnQubits, - SupportsApplyChannel, - SupportsApplyMixture, - SupportsApproximateEquality, - SupportsConsistentApplyUnitary, - SupportsCircuitDiagramInfo, - SupportsCommutes, - SupportsControlKey, - SupportsDecompose, - SupportsDecomposeWithQubits, - SupportsEqualUpToGlobalPhase, - SupportsExplicitHasUnitary, - SupportsExplicitQidShape, - SupportsExplicitNumQubits, - SupportsJSON, - SupportsKraus, - SupportsMeasurementKey, - SupportsMixture, - SupportsParameterization, - SupportsPauliExpansion, - SupportsPhase, - SupportsQasm, - SupportsQasmWithArgs, - SupportsQasmWithArgsAndQubits, - SupportsTraceDistanceBound, - SupportsUnitary, - to_json_gzip, - to_json, - obj_to_dict_helper, - trace_distance_bound, - trace_distance_from_angle_list, - unitary, - validate_mixture, - with_key_path, - with_key_path_prefix, - with_measurement_key_mapping, - with_rescoped_keys, + act_on as act_on, + apply_channel as apply_channel, + apply_mixture as apply_mixture, + apply_unitaries as apply_unitaries, + apply_unitary as apply_unitary, + ApplyChannelArgs as ApplyChannelArgs, + ApplyMixtureArgs as ApplyMixtureArgs, + ApplyUnitaryArgs as ApplyUnitaryArgs, + approx_eq as approx_eq, + circuit_diagram_info as circuit_diagram_info, + CircuitDiagramInfo as CircuitDiagramInfo, + CircuitDiagramInfoArgs as CircuitDiagramInfoArgs, + cirq_type_from_json as cirq_type_from_json, + commutes as commutes, + control_keys as control_keys, + decompose as decompose, + decompose_once as decompose_once, + decompose_once_with_qubits as decompose_once_with_qubits, + DecompositionContext as DecompositionContext, + DEFAULT_RESOLVERS as DEFAULT_RESOLVERS, + definitely_commutes as definitely_commutes, + equal_up_to_global_phase as equal_up_to_global_phase, + has_kraus as has_kraus, + has_mixture as has_mixture, + has_stabilizer_effect as has_stabilizer_effect, + has_unitary as has_unitary, + HasJSONNamespace as HasJSONNamespace, + inverse as inverse, + is_measurement as is_measurement, + is_parameterized as is_parameterized, + JsonResolver as JsonResolver, + json_cirq_type as json_cirq_type, + json_namespace as json_namespace, + dataclass_json_dict as dataclass_json_dict, + kraus as kraus, + LabelEntity as LabelEntity, + measurement_key_name as measurement_key_name, + measurement_key_obj as measurement_key_obj, + measurement_key_names as measurement_key_names, + measurement_key_objs as measurement_key_objs, + measurement_keys_touched as measurement_keys_touched, + mixture as mixture, + mul as mul, + num_qubits as num_qubits, + parameter_names as parameter_names, + parameter_symbols as parameter_symbols, + pauli_expansion as pauli_expansion, + phase_by as phase_by, + pow as pow, + qasm as qasm, + QasmArgs as QasmArgs, + qid_shape as qid_shape, + read_json_gzip as read_json_gzip, + read_json as read_json, + resolve_parameters as resolve_parameters, + resolve_parameters_once as resolve_parameters_once, + SerializableByKey as SerializableByKey, + SupportsActOn as SupportsActOn, + SupportsActOnQubits as SupportsActOnQubits, + SupportsApplyChannel as SupportsApplyChannel, + SupportsApplyMixture as SupportsApplyMixture, + SupportsApproximateEquality as SupportsApproximateEquality, + SupportsConsistentApplyUnitary as SupportsConsistentApplyUnitary, + SupportsCircuitDiagramInfo as SupportsCircuitDiagramInfo, + SupportsCommutes as SupportsCommutes, + SupportsControlKey as SupportsControlKey, + SupportsDecompose as SupportsDecompose, + SupportsDecomposeWithQubits as SupportsDecomposeWithQubits, + SupportsEqualUpToGlobalPhase as SupportsEqualUpToGlobalPhase, + SupportsExplicitHasUnitary as SupportsExplicitHasUnitary, + SupportsExplicitQidShape as SupportsExplicitQidShape, + SupportsExplicitNumQubits as SupportsExplicitNumQubits, + SupportsJSON as SupportsJSON, + SupportsKraus as SupportsKraus, + SupportsMeasurementKey as SupportsMeasurementKey, + SupportsMixture as SupportsMixture, + SupportsParameterization as SupportsParameterization, + SupportsPauliExpansion as SupportsPauliExpansion, + SupportsPhase as SupportsPhase, + SupportsQasm as SupportsQasm, + SupportsQasmWithArgs as SupportsQasmWithArgs, + SupportsQasmWithArgsAndQubits as SupportsQasmWithArgsAndQubits, + SupportsTraceDistanceBound as SupportsTraceDistanceBound, + SupportsUnitary as SupportsUnitary, + to_json_gzip as to_json_gzip, + to_json as to_json, + obj_to_dict_helper as obj_to_dict_helper, + trace_distance_bound as trace_distance_bound, + trace_distance_from_angle_list as trace_distance_from_angle_list, + unitary as unitary, + validate_mixture as validate_mixture, + with_key_path as with_key_path, + with_key_path_prefix as with_key_path_prefix, + with_measurement_key_mapping as with_measurement_key_mapping, + with_rescoped_keys as with_rescoped_keys, ) -from cirq.neutral_atoms import is_native_neutral_atom_gate, is_native_neutral_atom_op + +from cirq.neutral_atoms import ( + is_native_neutral_atom_gate as is_native_neutral_atom_gate, + is_native_neutral_atom_op as is_native_neutral_atom_op, +) from cirq.vis import ( - Heatmap, - TwoQubitInteractionHeatmap, - get_state_histogram, - integrated_histogram, - plot_density_matrix, - plot_state_histogram, + Heatmap as Heatmap, + TwoQubitInteractionHeatmap as TwoQubitInteractionHeatmap, + get_state_histogram as get_state_histogram, + integrated_histogram as integrated_histogram, + plot_density_matrix as plot_density_matrix, + plot_state_histogram as plot_state_histogram, ) -from cirq.work import CircuitSampleJob, PauliSumCollector, Sampler, Collector, ZerosSampler +from cirq.work import ( + CircuitSampleJob as CircuitSampleJob, + PauliSumCollector as PauliSumCollector, + Sampler as Sampler, + Collector as Collector, + ZerosSampler as ZerosSampler, +) # pylint: enable=redefined-builtin diff --git a/cirq-core/cirq/circuits/__init__.py b/cirq-core/cirq/circuits/__init__.py index 5f342104b5f..02269ac6889 100644 --- a/cirq-core/cirq/circuits/__init__.py +++ b/cirq-core/cirq/circuits/__init__.py @@ -14,15 +14,21 @@ """Circuit classes, mutators, and outputs.""" -from cirq.circuits.text_diagram_drawer import TextDiagramDrawer +from cirq.circuits.text_diagram_drawer import TextDiagramDrawer as TextDiagramDrawer +from cirq.circuits.qasm_output import QasmOutput as QasmOutput -from cirq.circuits.qasm_output import QasmOutput +from cirq.circuits.circuit import ( + AbstractCircuit as AbstractCircuit, + Alignment as Alignment, + Circuit as Circuit, +) +from cirq.circuits.circuit_operation import CircuitOperation as CircuitOperation +from cirq.circuits.frozen_circuit import FrozenCircuit as FrozenCircuit +from cirq.circuits.insert_strategy import InsertStrategy as InsertStrategy -from cirq.circuits.circuit import AbstractCircuit, Alignment, Circuit -from cirq.circuits.circuit_operation import CircuitOperation -from cirq.circuits.frozen_circuit import FrozenCircuit -from cirq.circuits.insert_strategy import InsertStrategy +from cirq.circuits.moment import Moment as Moment -from cirq.circuits.moment import Moment - -from cirq.circuits.optimization_pass import PointOptimizer, PointOptimizationSummary +from cirq.circuits.optimization_pass import ( + PointOptimizer as PointOptimizer, + PointOptimizationSummary as PointOptimizationSummary, +) diff --git a/cirq-core/cirq/contrib/__init__.py b/cirq-core/cirq/contrib/__init__.py index 53888be889f..926c6bb6baf 100644 --- a/cirq-core/cirq/contrib/__init__.py +++ b/cirq-core/cirq/contrib/__init__.py @@ -21,6 +21,6 @@ from cirq.contrib import acquaintance from cirq.contrib import graph_device from cirq.contrib import quirk -from cirq.contrib.qcircuit import circuit_to_latex_using_qcircuit +from cirq.contrib.qcircuit import circuit_to_latex_using_qcircuit as circuit_to_latex_using_qcircuit from cirq.contrib import json -from cirq.contrib.circuitdag import CircuitDag, Unique +from cirq.contrib.circuitdag import CircuitDag as CircuitDag, Unique as Unique diff --git a/cirq-core/cirq/contrib/acquaintance/__init__.py b/cirq-core/cirq/contrib/acquaintance/__init__.py index fee38bdcd91..8a09bb08840 100644 --- a/cirq-core/cirq/contrib/acquaintance/__init__.py +++ b/cirq-core/cirq/contrib/acquaintance/__init__.py @@ -13,55 +13,70 @@ # limitations under the License. """Tools for creating and using acquaintance strategies.""" +from cirq.contrib.acquaintance.bipartite import ( + BipartiteGraphType as BipartiteGraphType, + BipartiteSwapNetworkGate as BipartiteSwapNetworkGate, +) -from cirq.contrib.acquaintance.bipartite import BipartiteGraphType, BipartiteSwapNetworkGate - -from cirq.contrib.acquaintance.devices import get_acquaintance_size, UnconstrainedAcquaintanceDevice +from cirq.contrib.acquaintance.devices import ( + get_acquaintance_size as get_acquaintance_size, + UnconstrainedAcquaintanceDevice as UnconstrainedAcquaintanceDevice, +) from cirq.contrib.acquaintance.executor import ( - AcquaintanceOperation, - GreedyExecutionStrategy, - StrategyExecutorTransformer, + AcquaintanceOperation as AcquaintanceOperation, + GreedyExecutionStrategy as GreedyExecutionStrategy, + StrategyExecutorTransformer as StrategyExecutorTransformer, ) -from cirq.contrib.acquaintance.gates import acquaint, AcquaintanceOpportunityGate, SwapNetworkGate +from cirq.contrib.acquaintance.gates import ( + acquaint as acquaint, + AcquaintanceOpportunityGate as AcquaintanceOpportunityGate, + SwapNetworkGate as SwapNetworkGate, +) -from cirq.contrib.acquaintance.inspection_utils import get_logical_acquaintance_opportunities +from cirq.contrib.acquaintance.inspection_utils import ( + get_logical_acquaintance_opportunities as get_logical_acquaintance_opportunities, +) from cirq.contrib.acquaintance.mutation_utils import ( - expose_acquaintance_gates, - rectify_acquaintance_strategy, - replace_acquaintance_with_swap_network, + expose_acquaintance_gates as expose_acquaintance_gates, + rectify_acquaintance_strategy as rectify_acquaintance_strategy, + replace_acquaintance_with_swap_network as replace_acquaintance_with_swap_network, ) -from cirq.contrib.acquaintance.optimizers import remove_redundant_acquaintance_opportunities +from cirq.contrib.acquaintance.optimizers import ( + remove_redundant_acquaintance_opportunities as remove_redundant_acquaintance_opportunities, +) from cirq.contrib.acquaintance.permutation import ( - LinearPermutationGate, - PermutationGate, - SwapPermutationGate, - update_mapping, - get_logical_operations, - display_mapping, - return_to_initial_mapping, - uses_consistent_swap_gate, - EXPAND_PERMUTATION_GATES, - DECOMPOSE_PERMUTATION_GATES, + LinearPermutationGate as LinearPermutationGate, + PermutationGate as PermutationGate, + SwapPermutationGate as SwapPermutationGate, + update_mapping as update_mapping, + get_logical_operations as get_logical_operations, + display_mapping as display_mapping, + return_to_initial_mapping as return_to_initial_mapping, + uses_consistent_swap_gate as uses_consistent_swap_gate, + EXPAND_PERMUTATION_GATES as EXPAND_PERMUTATION_GATES, + DECOMPOSE_PERMUTATION_GATES as DECOMPOSE_PERMUTATION_GATES, ) -from cirq.contrib.acquaintance.shift import CircularShiftGate +from cirq.contrib.acquaintance.shift import CircularShiftGate as CircularShiftGate -from cirq.contrib.acquaintance.shift_swap_network import ShiftSwapNetworkGate +from cirq.contrib.acquaintance.shift_swap_network import ( + ShiftSwapNetworkGate as ShiftSwapNetworkGate, +) from cirq.contrib.acquaintance.strategies import ( - complete_acquaintance_strategy, - cubic_acquaintance_strategy, - quartic_paired_acquaintance_strategy, + complete_acquaintance_strategy as complete_acquaintance_strategy, + cubic_acquaintance_strategy as cubic_acquaintance_strategy, + quartic_paired_acquaintance_strategy as quartic_paired_acquaintance_strategy, ) from cirq.contrib.acquaintance.topological_sort import ( - is_topologically_sorted, - random_topological_sort, + is_topologically_sorted as is_topologically_sorted, + random_topological_sort as random_topological_sort, ) from cirq.contrib.acquaintance import testing diff --git a/cirq-core/cirq/contrib/acquaintance/strategies/__init__.py b/cirq-core/cirq/contrib/acquaintance/strategies/__init__.py index e0251ee5282..991f68bb330 100644 --- a/cirq-core/cirq/contrib/acquaintance/strategies/__init__.py +++ b/cirq-core/cirq/contrib/acquaintance/strategies/__init__.py @@ -14,6 +14,12 @@ """Acquaintance strategies.""" -from cirq.contrib.acquaintance.strategies.complete import complete_acquaintance_strategy -from cirq.contrib.acquaintance.strategies.cubic import cubic_acquaintance_strategy -from cirq.contrib.acquaintance.strategies.quartic_paired import quartic_paired_acquaintance_strategy +from cirq.contrib.acquaintance.strategies.complete import ( + complete_acquaintance_strategy as complete_acquaintance_strategy, +) +from cirq.contrib.acquaintance.strategies.cubic import ( + cubic_acquaintance_strategy as cubic_acquaintance_strategy, +) +from cirq.contrib.acquaintance.strategies.quartic_paired import ( + quartic_paired_acquaintance_strategy as quartic_paired_acquaintance_strategy, +) diff --git a/cirq-core/cirq/contrib/bayesian_network/__init__.py b/cirq-core/cirq/contrib/bayesian_network/__init__.py index 4e030d410d5..891c15e829f 100644 --- a/cirq-core/cirq/contrib/bayesian_network/__init__.py +++ b/cirq-core/cirq/contrib/bayesian_network/__init__.py @@ -12,4 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cirq.contrib.bayesian_network.bayesian_network_gate import BayesianNetworkGate +from cirq.contrib.bayesian_network.bayesian_network_gate import ( + BayesianNetworkGate as BayesianNetworkGate, +) diff --git a/cirq-core/cirq/contrib/circuitdag/__init__.py b/cirq-core/cirq/contrib/circuitdag/__init__.py index bb8dafc690e..764fcec2791 100644 --- a/cirq-core/cirq/contrib/circuitdag/__init__.py +++ b/cirq-core/cirq/contrib/circuitdag/__init__.py @@ -14,4 +14,4 @@ """Tools for representing a Circuit as a directed acyclic graph.""" -from cirq.contrib.circuitdag.circuit_dag import CircuitDag, Unique +from cirq.contrib.circuitdag.circuit_dag import CircuitDag as CircuitDag, Unique as Unique diff --git a/cirq-core/cirq/contrib/circuitdag/circuit_dag.py b/cirq-core/cirq/contrib/circuitdag/circuit_dag.py index 6753c4fa2ed..ed7e4f5498a 100644 --- a/cirq-core/cirq/contrib/circuitdag/circuit_dag.py +++ b/cirq-core/cirq/contrib/circuitdag/circuit_dag.py @@ -11,16 +11,14 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -from typing import Any, Callable, Dict, Generic, Iterator, TypeVar, cast, TYPE_CHECKING + +from typing import Any, Callable, Dict, Generic, Iterator, TypeVar, cast import functools import networkx +import cirq from cirq import ops -from cirq.circuits import circuit - -if TYPE_CHECKING: - import cirq T = TypeVar('T') @@ -98,7 +96,7 @@ def make_node(op: 'cirq.Operation') -> Unique: @staticmethod def from_circuit( - circuit: circuit.Circuit, + circuit: cirq.Circuit, can_reorder: Callable[['cirq.Operation', 'cirq.Operation'], bool] = _disjoint_qubits, ) -> 'CircuitDag': return CircuitDag.from_ops(circuit.all_operations(), can_reorder=can_reorder) @@ -179,8 +177,8 @@ def all_operations(self) -> Iterator['cirq.Operation']: def all_qubits(self): return frozenset(q for node in self.nodes for q in node.val.qubits) - def to_circuit(self) -> circuit.Circuit: - return circuit.Circuit(self.all_operations(), strategy=circuit.InsertStrategy.EARLIEST) + def to_circuit(self) -> cirq.Circuit: + return cirq.Circuit(self.all_operations(), strategy=cirq.InsertStrategy.EARLIEST) def findall_nodes_until_blocked( self, is_blocker: Callable[['cirq.Operation'], bool] diff --git a/cirq-core/cirq/contrib/graph_device/__init__.py b/cirq-core/cirq/contrib/graph_device/__init__.py index 91f80c867e8..d0ed8e4194e 100644 --- a/cirq-core/cirq/contrib/graph_device/__init__.py +++ b/cirq-core/cirq/contrib/graph_device/__init__.py @@ -14,17 +14,17 @@ """Tools for representing a device as an edge-labelled graph.""" -from cirq.contrib.graph_device.hypergraph import UndirectedHypergraph +from cirq.contrib.graph_device.hypergraph import UndirectedHypergraph as UndirectedHypergraph from cirq.contrib.graph_device.graph_device import ( - is_undirected_device_graph, - is_crosstalk_graph, - FixedDurationUndirectedGraphDeviceEdge, - UndirectedGraphDevice, - UnconstrainedUndirectedGraphDeviceEdge, + is_undirected_device_graph as is_undirected_device_graph, + is_crosstalk_graph as is_crosstalk_graph, + FixedDurationUndirectedGraphDeviceEdge as FixedDurationUndirectedGraphDeviceEdge, + UndirectedGraphDevice as UndirectedGraphDevice, + UnconstrainedUndirectedGraphDeviceEdge as UnconstrainedUndirectedGraphDeviceEdge, ) from cirq.contrib.graph_device.uniform_graph_device import ( - uniform_undirected_graph_device, - uniform_undirected_linear_device, + uniform_undirected_graph_device as uniform_undirected_graph_device, + uniform_undirected_linear_device as uniform_undirected_linear_device, ) diff --git a/cirq-core/cirq/contrib/noise_models/__init__.py b/cirq-core/cirq/contrib/noise_models/__init__.py index f66b4718364..d40f67e0ac9 100644 --- a/cirq-core/cirq/contrib/noise_models/__init__.py +++ b/cirq-core/cirq/contrib/noise_models/__init__.py @@ -11,11 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. - from cirq.contrib.noise_models.noise_models import ( - DepolarizingNoiseModel, - ReadoutNoiseModel, - DampedReadoutNoiseModel, - DepolarizingWithReadoutNoiseModel, - DepolarizingWithDampedReadoutNoiseModel, + DepolarizingNoiseModel as DepolarizingNoiseModel, + ReadoutNoiseModel as ReadoutNoiseModel, + DampedReadoutNoiseModel as DampedReadoutNoiseModel, + DepolarizingWithReadoutNoiseModel as DepolarizingWithReadoutNoiseModel, + DepolarizingWithDampedReadoutNoiseModel as DepolarizingWithDampedReadoutNoiseModel, ) diff --git a/cirq-core/cirq/contrib/paulistring/__init__.py b/cirq-core/cirq/contrib/paulistring/__init__.py index 9fbc4224e07..a75ce6617d3 100644 --- a/cirq-core/cirq/contrib/paulistring/__init__.py +++ b/cirq-core/cirq/contrib/paulistring/__init__.py @@ -14,23 +14,31 @@ """Methods related to optimizing and transforming PauliStrings.""" -from cirq.contrib.paulistring.clifford_target_gateset import CliffordTargetGateset +from cirq.contrib.paulistring.clifford_target_gateset import ( + CliffordTargetGateset as CliffordTargetGateset, +) from cirq.contrib.paulistring.separate import ( - convert_and_separate_circuit, - pauli_string_half, - regular_half, + convert_and_separate_circuit as convert_and_separate_circuit, + pauli_string_half as pauli_string_half, + regular_half as regular_half, ) from cirq.contrib.paulistring.pauli_string_dag import ( - pauli_string_dag_from_circuit, - pauli_string_reorder_pred, + pauli_string_dag_from_circuit as pauli_string_dag_from_circuit, + pauli_string_reorder_pred as pauli_string_reorder_pred, ) -from cirq.contrib.paulistring.recombine import move_pauli_strings_into_circuit +from cirq.contrib.paulistring.recombine import ( + move_pauli_strings_into_circuit as move_pauli_strings_into_circuit, +) -from cirq.contrib.paulistring.pauli_string_optimize import pauli_string_optimized_circuit +from cirq.contrib.paulistring.pauli_string_optimize import ( + pauli_string_optimized_circuit as pauli_string_optimized_circuit, +) -from cirq.contrib.paulistring.clifford_optimize import clifford_optimized_circuit +from cirq.contrib.paulistring.clifford_optimize import ( + clifford_optimized_circuit as clifford_optimized_circuit, +) -from cirq.contrib.paulistring.optimize import optimized_circuit +from cirq.contrib.paulistring.optimize import optimized_circuit as optimized_circuit diff --git a/cirq-core/cirq/contrib/qasm_import/__init__.py b/cirq-core/cirq/contrib/qasm_import/__init__.py index 00b00b02902..62a7ab3c197 100644 --- a/cirq-core/cirq/contrib/qasm_import/__init__.py +++ b/cirq-core/cirq/contrib/qasm_import/__init__.py @@ -12,5 +12,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cirq.contrib.qasm_import.exception import QasmException -from cirq.contrib.qasm_import.qasm import circuit_from_qasm +from cirq.contrib.qasm_import.exception import QasmException as QasmException +from cirq.contrib.qasm_import.qasm import circuit_from_qasm as circuit_from_qasm diff --git a/cirq-core/cirq/contrib/qcircuit/__init__.py b/cirq-core/cirq/contrib/qcircuit/__init__.py index a187c0b206e..878fe5c841c 100644 --- a/cirq-core/cirq/contrib/qcircuit/__init__.py +++ b/cirq-core/cirq/contrib/qcircuit/__init__.py @@ -14,10 +14,12 @@ """Converts cirq circuits into latex using qcircuit.""" -from cirq.contrib.qcircuit.qcircuit_diagram import circuit_to_latex_using_qcircuit +from cirq.contrib.qcircuit.qcircuit_diagram import ( + circuit_to_latex_using_qcircuit as circuit_to_latex_using_qcircuit, +) from cirq.contrib.qcircuit.qcircuit_diagram_info import ( - escape_text_for_latex, - get_multigate_parameters, - get_qcircuit_diagram_info, + escape_text_for_latex as escape_text_for_latex, + get_multigate_parameters as get_multigate_parameters, + get_qcircuit_diagram_info as get_qcircuit_diagram_info, ) diff --git a/cirq-core/cirq/contrib/quantum_volume/__init__.py b/cirq-core/cirq/contrib/quantum_volume/__init__.py index 054e3c14fd4..7e8705fe42c 100644 --- a/cirq-core/cirq/contrib/quantum_volume/__init__.py +++ b/cirq-core/cirq/contrib/quantum_volume/__init__.py @@ -14,11 +14,11 @@ """Utilities running the Quantum Volume benchmark on devices""" from cirq.contrib.quantum_volume.quantum_volume import ( - generate_model_circuit, - compute_heavy_set, - sample_heavy_set, - compile_circuit, - calculate_quantum_volume, - QuantumVolumeResult, - CompilationResult, + generate_model_circuit as generate_model_circuit, + compute_heavy_set as compute_heavy_set, + sample_heavy_set as sample_heavy_set, + compile_circuit as compile_circuit, + calculate_quantum_volume as calculate_quantum_volume, + QuantumVolumeResult as QuantumVolumeResult, + CompilationResult as CompilationResult, ) diff --git a/cirq-core/cirq/contrib/quimb/__init__.py b/cirq-core/cirq/contrib/quimb/__init__.py index b666f5a3bf5..d2482f611e2 100644 --- a/cirq-core/cirq/contrib/quimb/__init__.py +++ b/cirq-core/cirq/contrib/quimb/__init__.py @@ -1,23 +1,26 @@ # pylint: disable=wrong-or-nonexistent-copyright-notice from cirq.contrib.quimb.state_vector import ( - circuit_for_expectation_value, - tensor_expectation_value, - circuit_to_tensors, - tensor_state_vector, - tensor_unitary, + circuit_for_expectation_value as circuit_for_expectation_value, + tensor_expectation_value as tensor_expectation_value, + circuit_to_tensors as circuit_to_tensors, + tensor_state_vector as tensor_state_vector, + tensor_unitary as tensor_unitary, ) from cirq.contrib.quimb.density_matrix import ( - tensor_density_matrix, - circuit_to_density_matrix_tensors, + tensor_density_matrix as tensor_density_matrix, + circuit_to_density_matrix_tensors as circuit_to_density_matrix_tensors, ) -from cirq.contrib.quimb.grid_circuits import simplify_expectation_value_circuit, get_grid_moments +from cirq.contrib.quimb.grid_circuits import ( + simplify_expectation_value_circuit as simplify_expectation_value_circuit, + get_grid_moments as get_grid_moments, +) from cirq.contrib.quimb.mps_simulator import ( - MPSOptions, - MPSSimulator, - MPSSimulatorStepResult, - MPSState, - MPSTrialResult, + MPSOptions as MPSOptions, + MPSSimulator as MPSSimulator, + MPSSimulatorStepResult as MPSSimulatorStepResult, + MPSState as MPSState, + MPSTrialResult as MPSTrialResult, ) diff --git a/cirq-core/cirq/contrib/quirk/__init__.py b/cirq-core/cirq/contrib/quirk/__init__.py index 250ef97fe66..304a118228a 100644 --- a/cirq-core/cirq/contrib/quirk/__init__.py +++ b/cirq-core/cirq/contrib/quirk/__init__.py @@ -14,4 +14,4 @@ """Converts cirq circuits into quirk circuits.""" -from cirq.contrib.quirk.export_to_quirk import circuit_to_quirk_url +from cirq.contrib.quirk.export_to_quirk import circuit_to_quirk_url as circuit_to_quirk_url diff --git a/cirq-core/cirq/contrib/routing/__init__.py b/cirq-core/cirq/contrib/routing/__init__.py index cc5e72badbd..9eb8c0c9461 100644 --- a/cirq-core/cirq/contrib/routing/__init__.py +++ b/cirq-core/cirq/contrib/routing/__init__.py @@ -14,15 +14,18 @@ """Utilities for routing circuits on devices""" from cirq.contrib.routing.device import ( - get_linear_device_graph, - get_grid_device_graph, - gridqubits_to_graph_device, - nx_qubit_layout, + get_linear_device_graph as get_linear_device_graph, + get_grid_device_graph as get_grid_device_graph, + gridqubits_to_graph_device as gridqubits_to_graph_device, + nx_qubit_layout as nx_qubit_layout, ) -from cirq.contrib.routing.router import route_circuit, ROUTERS -from cirq.contrib.routing.swap_network import SwapNetwork + +from cirq.contrib.routing.router import route_circuit as route_circuit, ROUTERS as ROUTERS + +from cirq.contrib.routing.swap_network import SwapNetwork as SwapNetwork + from cirq.contrib.routing.utils import ( - get_circuit_connectivity, - is_valid_routing, - ops_are_consistent_with_device_graph, + get_circuit_connectivity as get_circuit_connectivity, + is_valid_routing as is_valid_routing, + ops_are_consistent_with_device_graph as ops_are_consistent_with_device_graph, ) diff --git a/cirq-core/cirq/contrib/svg/__init__.py b/cirq-core/cirq/contrib/svg/__init__.py index 03c5ce93113..f8a03e063c7 100644 --- a/cirq-core/cirq/contrib/svg/__init__.py +++ b/cirq-core/cirq/contrib/svg/__init__.py @@ -1,2 +1,2 @@ # pylint: disable=wrong-or-nonexistent-copyright-notice -from cirq.contrib.svg.svg import SVGCircuit, circuit_to_svg +from cirq.contrib.svg.svg import SVGCircuit as SVGCircuit, circuit_to_svg as circuit_to_svg diff --git a/cirq-core/cirq/devices/__init__.py b/cirq-core/cirq/devices/__init__.py index 7ff622946a1..42a36dbe020 100644 --- a/cirq-core/cirq/devices/__init__.py +++ b/cirq-core/cirq/devices/__init__.py @@ -14,45 +14,54 @@ """Device classes, qubits, and topologies, as well as noise models.""" -from cirq.devices.device import Device, DeviceMetadata -from cirq.devices.grid_device_metadata import GridDeviceMetadata +from cirq.devices.device import Device as Device, DeviceMetadata as DeviceMetadata -from cirq.devices.grid_qubit import GridQid, GridQubit +from cirq.devices.grid_device_metadata import GridDeviceMetadata as GridDeviceMetadata -from cirq.devices.line_qubit import LineQubit, LineQid +from cirq.devices.grid_qubit import GridQid as GridQid, GridQubit as GridQubit -from cirq.devices.unconstrained_device import UNCONSTRAINED_DEVICE +from cirq.devices.line_qubit import LineQubit as LineQubit, LineQid as LineQid -from cirq.devices.noise_model import NO_NOISE, NOISE_MODEL_LIKE, NoiseModel, ConstantQubitNoiseModel +from cirq.devices.unconstrained_device import UNCONSTRAINED_DEVICE as UNCONSTRAINED_DEVICE + +from cirq.devices.noise_model import ( + NO_NOISE as NO_NOISE, + NOISE_MODEL_LIKE as NOISE_MODEL_LIKE, + NoiseModel as NoiseModel, + ConstantQubitNoiseModel as ConstantQubitNoiseModel, +) from cirq.devices.named_topologies import ( - NamedTopology, - draw_gridlike, - LineTopology, - TiltedSquareLattice, - get_placements, - is_valid_placement, - draw_placements, + NamedTopology as NamedTopology, + draw_gridlike as draw_gridlike, + LineTopology as LineTopology, + TiltedSquareLattice as TiltedSquareLattice, + get_placements as get_placements, + is_valid_placement as is_valid_placement, + draw_placements as draw_placements, ) -from cirq.devices.insertion_noise_model import InsertionNoiseModel +from cirq.devices.insertion_noise_model import InsertionNoiseModel as InsertionNoiseModel -from cirq.devices.thermal_noise_model import ThermalNoiseModel +from cirq.devices.thermal_noise_model import ThermalNoiseModel as ThermalNoiseModel -from cirq.devices.noise_properties import NoiseModelFromNoiseProperties, NoiseProperties +from cirq.devices.noise_properties import ( + NoiseModelFromNoiseProperties as NoiseModelFromNoiseProperties, + NoiseProperties as NoiseProperties, +) from cirq.devices.superconducting_qubits_noise_properties import ( - SuperconductingQubitsNoiseProperties, + SuperconductingQubitsNoiseProperties as SuperconductingQubitsNoiseProperties, ) from cirq.devices.noise_utils import ( - OpIdentifier, - decay_constant_to_xeb_fidelity, - decay_constant_to_pauli_error, - pauli_error_to_decay_constant, - xeb_fidelity_to_decay_constant, - pauli_error_from_t1, - average_error, - decoherence_pauli_error, + OpIdentifier as OpIdentifier, + decay_constant_to_xeb_fidelity as decay_constant_to_xeb_fidelity, + decay_constant_to_pauli_error as decay_constant_to_pauli_error, + pauli_error_to_decay_constant as pauli_error_to_decay_constant, + xeb_fidelity_to_decay_constant as xeb_fidelity_to_decay_constant, + pauli_error_from_t1 as pauli_error_from_t1, + average_error as average_error, + decoherence_pauli_error as decoherence_pauli_error, ) diff --git a/cirq-core/cirq/experiments/__init__.py b/cirq-core/cirq/experiments/__init__.py index ac4bc8ce29a..71f577d4898 100644 --- a/cirq-core/cirq/experiments/__init__.py +++ b/cirq-core/cirq/experiments/__init__.py @@ -14,60 +14,71 @@ """Experiments and tools for characterizing quantum operations.""" from cirq.experiments.qubit_characterizations import ( - RandomizedBenchMarkResult, - single_qubit_randomized_benchmarking, - single_qubit_state_tomography, - TomographyResult, - two_qubit_randomized_benchmarking, - two_qubit_state_tomography, - parallel_single_qubit_randomized_benchmarking, + RandomizedBenchMarkResult as RandomizedBenchMarkResult, + single_qubit_randomized_benchmarking as single_qubit_randomized_benchmarking, + single_qubit_state_tomography as single_qubit_state_tomography, + TomographyResult as TomographyResult, + two_qubit_randomized_benchmarking as two_qubit_randomized_benchmarking, + two_qubit_state_tomography as two_qubit_state_tomography, + parallel_single_qubit_randomized_benchmarking as parallel_single_qubit_randomized_benchmarking, ) from cirq.experiments.fidelity_estimation import ( - hog_score_xeb_fidelity_from_probabilities, - linear_xeb_fidelity_from_probabilities, - linear_xeb_fidelity, - log_xeb_fidelity, - log_xeb_fidelity_from_probabilities, - xeb_fidelity, + hog_score_xeb_fidelity_from_probabilities as hog_score_xeb_fidelity_from_probabilities, + linear_xeb_fidelity_from_probabilities as linear_xeb_fidelity_from_probabilities, + linear_xeb_fidelity as linear_xeb_fidelity, + log_xeb_fidelity as log_xeb_fidelity, + log_xeb_fidelity_from_probabilities as log_xeb_fidelity_from_probabilities, + xeb_fidelity as xeb_fidelity, ) -from cirq.experiments.purity_estimation import purity_from_probabilities +from cirq.experiments.purity_estimation import ( + purity_from_probabilities as purity_from_probabilities, +) from cirq.experiments.random_quantum_circuit_generation import ( - GRID_ALIGNED_PATTERN, - GRID_STAGGERED_PATTERN, - HALF_GRID_STAGGERED_PATTERN, - GridInteractionLayer, - random_rotations_between_grid_interaction_layers_circuit, + # pylint: disable=line-too-long + GRID_ALIGNED_PATTERN as GRID_ALIGNED_PATTERN, + GRID_STAGGERED_PATTERN as GRID_STAGGERED_PATTERN, + HALF_GRID_STAGGERED_PATTERN as HALF_GRID_STAGGERED_PATTERN, + GridInteractionLayer as GridInteractionLayer, + random_rotations_between_grid_interaction_layers_circuit as random_rotations_between_grid_interaction_layers_circuit, ) from cirq.experiments.readout_confusion_matrix import ( - TensoredConfusionMatrices, - measure_confusion_matrix, + TensoredConfusionMatrices as TensoredConfusionMatrices, + measure_confusion_matrix as measure_confusion_matrix, ) from cirq.experiments.n_qubit_tomography import ( - get_state_tomography_data, - state_tomography, - StateTomographyExperiment, + get_state_tomography_data as get_state_tomography_data, + state_tomography as state_tomography, + StateTomographyExperiment as StateTomographyExperiment, ) from cirq.experiments.single_qubit_readout_calibration import ( - estimate_parallel_single_qubit_readout_errors, - estimate_single_qubit_readout_errors, - SingleQubitReadoutCalibrationResult, + estimate_parallel_single_qubit_readout_errors as estimate_parallel_single_qubit_readout_errors, + estimate_single_qubit_readout_errors as estimate_single_qubit_readout_errors, + SingleQubitReadoutCalibrationResult as SingleQubitReadoutCalibrationResult, ) -from cirq.experiments.t1_decay_experiment import t1_decay, T1DecayResult +from cirq.experiments.t1_decay_experiment import ( + t1_decay as t1_decay, + T1DecayResult as T1DecayResult, +) -from cirq.experiments.t2_decay_experiment import t2_decay, T2DecayResult +from cirq.experiments.t2_decay_experiment import ( + t2_decay as t2_decay, + T2DecayResult as T2DecayResult, +) -from cirq.experiments.xeb_fitting import XEBPhasedFSimCharacterizationOptions +from cirq.experiments.xeb_fitting import ( + XEBPhasedFSimCharacterizationOptions as XEBPhasedFSimCharacterizationOptions, +) from cirq.experiments.two_qubit_xeb import ( - InferredXEBResult, - TwoQubitXEBResult, - parallel_two_qubit_xeb, - run_rb_and_xeb, + InferredXEBResult as InferredXEBResult, + TwoQubitXEBResult as TwoQubitXEBResult, + parallel_two_qubit_xeb as parallel_two_qubit_xeb, + run_rb_and_xeb as run_rb_and_xeb, ) diff --git a/cirq-core/cirq/interop/__init__.py b/cirq-core/cirq/interop/__init__.py index 44978128a99..3f91459e6c9 100644 --- a/cirq-core/cirq/interop/__init__.py +++ b/cirq-core/cirq/interop/__init__.py @@ -13,4 +13,7 @@ # limitations under the License. """Methods for interoperating with other quantum software.""" -from cirq.interop.quirk import quirk_json_to_circuit, quirk_url_to_circuit +from cirq.interop.quirk import ( + quirk_json_to_circuit as quirk_json_to_circuit, + quirk_url_to_circuit as quirk_url_to_circuit, +) diff --git a/cirq-core/cirq/interop/quirk/__init__.py b/cirq-core/cirq/interop/quirk/__init__.py index a23f7177244..a6bc32c5806 100644 --- a/cirq-core/cirq/interop/quirk/__init__.py +++ b/cirq-core/cirq/interop/quirk/__init__.py @@ -20,9 +20,12 @@ # Imports from cells are only to ensure operation reprs work correctly. from cirq.interop.quirk.cells import ( - QuirkArithmeticGate, - QuirkInputRotationOperation, - QuirkQubitPermutationGate, + QuirkArithmeticGate as QuirkArithmeticGate, + QuirkInputRotationOperation as QuirkInputRotationOperation, + QuirkQubitPermutationGate as QuirkQubitPermutationGate, ) -from cirq.interop.quirk.url_to_circuit import quirk_json_to_circuit, quirk_url_to_circuit +from cirq.interop.quirk.url_to_circuit import ( + quirk_json_to_circuit as quirk_json_to_circuit, + quirk_url_to_circuit as quirk_url_to_circuit, +) diff --git a/cirq-core/cirq/interop/quirk/cells/__init__.py b/cirq-core/cirq/interop/quirk/cells/__init__.py index cf8e56a0c0a..2384fd78bfa 100644 --- a/cirq-core/cirq/interop/quirk/cells/__init__.py +++ b/cirq-core/cirq/interop/quirk/cells/__init__.py @@ -13,17 +13,28 @@ # limitations under the License. """This module defines building blocks for parsing Quirk circuits.""" -from cirq.interop.quirk.cells.all_cells import generate_all_quirk_cell_makers +from cirq.interop.quirk.cells.all_cells import ( + generate_all_quirk_cell_makers as generate_all_quirk_cell_makers, +) -from cirq.interop.quirk.cells.cell import Cell, CellMaker, CellMakerArgs, ExplicitOperationsCell +from cirq.interop.quirk.cells.cell import ( + Cell as Cell, + CellMaker as CellMaker, + CellMakerArgs as CellMakerArgs, + ExplicitOperationsCell as ExplicitOperationsCell, +) -from cirq.interop.quirk.cells.composite_cell import CompositeCell +from cirq.interop.quirk.cells.composite_cell import CompositeCell as CompositeCell -from cirq.interop.quirk.cells.qubit_permutation_cells import QuirkQubitPermutationGate +from cirq.interop.quirk.cells.qubit_permutation_cells import ( + QuirkQubitPermutationGate as QuirkQubitPermutationGate, +) -from cirq.interop.quirk.cells.arithmetic_cells import QuirkArithmeticGate +from cirq.interop.quirk.cells.arithmetic_cells import QuirkArithmeticGate as QuirkArithmeticGate -from cirq.interop.quirk.cells.input_rotation_cells import QuirkInputRotationOperation +from cirq.interop.quirk.cells.input_rotation_cells import ( + QuirkInputRotationOperation as QuirkInputRotationOperation, +) import cirq.interop.quirk.cells.swap_cell import cirq.interop.quirk.cells.control_cells diff --git a/cirq-core/cirq/ion/__init__.py b/cirq-core/cirq/ion/__init__.py index ea83ee88c90..8ad7ed7b060 100644 --- a/cirq-core/cirq/ion/__init__.py +++ b/cirq-core/cirq/ion/__init__.py @@ -14,6 +14,8 @@ """Trapped ion devices, gates, and compiling utilties.""" -from cirq.ops import ms +from cirq.ops import ms as ms -from cirq.transformers import two_qubit_matrix_to_ion_operations +from cirq.transformers import ( + two_qubit_matrix_to_ion_operations as two_qubit_matrix_to_ion_operations, +) diff --git a/cirq-core/cirq/linalg/__init__.py b/cirq-core/cirq/linalg/__init__.py index e0181859837..b800cfeb154 100644 --- a/cirq-core/cirq/linalg/__init__.py +++ b/cirq-core/cirq/linalg/__init__.py @@ -17,70 +17,80 @@ Avoids duplicating functionality present in numpy. """ -from cirq.linalg.combinators import block_diag, CONTROL_TAG, dot, kron, kron_with_controls +from cirq.linalg.combinators import ( + block_diag as block_diag, + CONTROL_TAG as CONTROL_TAG, + dot as dot, + kron as kron, + kron_with_controls as kron_with_controls, +) from cirq.linalg.decompositions import ( - axis_angle, - AxisAngleDecomposition, - deconstruct_single_qubit_matrix_into_angles, - extract_right_diag, - kak_canonicalize_vector, - kak_decomposition, - kak_vector, - KakDecomposition, - kron_factor_4x4_to_2x2s, - map_eigenvalues, - num_cnots_required, - unitary_eig, - scatter_plot_normalized_kak_interaction_coefficients, - so4_to_magic_su2s, + # pylint: disable=line-too-long + axis_angle as axis_angle, + AxisAngleDecomposition as AxisAngleDecomposition, + deconstruct_single_qubit_matrix_into_angles as deconstruct_single_qubit_matrix_into_angles, + extract_right_diag as extract_right_diag, + kak_canonicalize_vector as kak_canonicalize_vector, + kak_decomposition as kak_decomposition, + kak_vector as kak_vector, + KakDecomposition as KakDecomposition, + kron_factor_4x4_to_2x2s as kron_factor_4x4_to_2x2s, + map_eigenvalues as map_eigenvalues, + num_cnots_required as num_cnots_required, + unitary_eig as unitary_eig, + scatter_plot_normalized_kak_interaction_coefficients as scatter_plot_normalized_kak_interaction_coefficients, + so4_to_magic_su2s as so4_to_magic_su2s, ) - from cirq.linalg.diagonalize import ( - bidiagonalize_real_matrix_pair_with_symmetric_products, - bidiagonalize_unitary_with_special_orthogonals, - diagonalize_real_symmetric_and_sorted_diagonal_matrices, - diagonalize_real_symmetric_matrix, + # pylint: disable=line-too-long + bidiagonalize_real_matrix_pair_with_symmetric_products as bidiagonalize_real_matrix_pair_with_symmetric_products, + bidiagonalize_unitary_with_special_orthogonals as bidiagonalize_unitary_with_special_orthogonals, + diagonalize_real_symmetric_and_sorted_diagonal_matrices as diagonalize_real_symmetric_and_sorted_diagonal_matrices, + diagonalize_real_symmetric_matrix as diagonalize_real_symmetric_matrix, ) from cirq.linalg.operator_spaces import ( - expand_matrix_in_orthogonal_basis, - hilbert_schmidt_inner_product, - kron_bases, - matrix_from_basis_coefficients, - PAULI_BASIS, - pow_pauli_combination, + expand_matrix_in_orthogonal_basis as expand_matrix_in_orthogonal_basis, + hilbert_schmidt_inner_product as hilbert_schmidt_inner_product, + kron_bases as kron_bases, + matrix_from_basis_coefficients as matrix_from_basis_coefficients, + PAULI_BASIS as PAULI_BASIS, + pow_pauli_combination as pow_pauli_combination, ) from cirq.linalg.predicates import ( - allclose_up_to_global_phase, - is_cptp, - is_diagonal, - is_hermitian, - is_normal, - is_orthogonal, - is_special_orthogonal, - is_special_unitary, - is_unitary, - matrix_commutes, - slice_for_qubits_equal_to, + allclose_up_to_global_phase as allclose_up_to_global_phase, + is_cptp as is_cptp, + is_diagonal as is_diagonal, + is_hermitian as is_hermitian, + is_normal as is_normal, + is_orthogonal as is_orthogonal, + is_special_orthogonal as is_special_orthogonal, + is_special_unitary as is_special_unitary, + is_unitary as is_unitary, + matrix_commutes as matrix_commutes, + slice_for_qubits_equal_to as slice_for_qubits_equal_to, ) -from cirq.linalg.tolerance import all_near_zero, all_near_zero_mod +from cirq.linalg.tolerance import ( + all_near_zero as all_near_zero, + all_near_zero_mod as all_near_zero_mod, +) from cirq.linalg.transformations import ( - apply_matrix_to_slices, - density_matrix_kronecker_product, - match_global_phase, - partial_trace, - partial_trace_of_state_vector_as_mixture, - reflection_matrix_pow, - state_vector_kronecker_product, - sub_state_vector, - targeted_conjugate_about, - targeted_left_multiply, - to_special, - transpose_flattened_array, - can_numpy_support_shape, + apply_matrix_to_slices as apply_matrix_to_slices, + density_matrix_kronecker_product as density_matrix_kronecker_product, + match_global_phase as match_global_phase, + partial_trace as partial_trace, + partial_trace_of_state_vector_as_mixture as partial_trace_of_state_vector_as_mixture, + reflection_matrix_pow as reflection_matrix_pow, + state_vector_kronecker_product as state_vector_kronecker_product, + sub_state_vector as sub_state_vector, + targeted_conjugate_about as targeted_conjugate_about, + targeted_left_multiply as targeted_left_multiply, + to_special as to_special, + transpose_flattened_array as transpose_flattened_array, + can_numpy_support_shape as can_numpy_support_shape, ) diff --git a/cirq-core/cirq/neutral_atoms/__init__.py b/cirq-core/cirq/neutral_atoms/__init__.py index 447b8411a27..e3041cc7aaa 100644 --- a/cirq-core/cirq/neutral_atoms/__init__.py +++ b/cirq-core/cirq/neutral_atoms/__init__.py @@ -15,6 +15,6 @@ """Neutral atom devices and gates.""" from cirq.neutral_atoms.convert_to_neutral_atom_gates import ( - is_native_neutral_atom_gate, - is_native_neutral_atom_op, + is_native_neutral_atom_gate as is_native_neutral_atom_gate, + is_native_neutral_atom_op as is_native_neutral_atom_op, ) diff --git a/cirq-core/cirq/ops/__init__.py b/cirq-core/cirq/ops/__init__.py index 25db2fc710a..fe1c3098d75 100644 --- a/cirq-core/cirq/ops/__init__.py +++ b/cirq-core/cirq/ops/__init__.py @@ -14,208 +14,249 @@ """Gates (unitary and non-unitary), operations, base types, and gate sets. """ -from cirq.ops.arithmetic_operation import ArithmeticGate +from cirq.ops.arithmetic_operation import ArithmeticGate as ArithmeticGate -from cirq.ops.clifford_gate import CliffordGate, SingleQubitCliffordGate +from cirq.ops.clifford_gate import ( + CliffordGate as CliffordGate, + SingleQubitCliffordGate as SingleQubitCliffordGate, +) from cirq.ops.dense_pauli_string import ( - BaseDensePauliString, - DensePauliString, - MutableDensePauliString, + BaseDensePauliString as BaseDensePauliString, + DensePauliString as DensePauliString, + MutableDensePauliString as MutableDensePauliString, ) -from cirq.ops.boolean_hamiltonian import BooleanHamiltonianGate +from cirq.ops.boolean_hamiltonian import BooleanHamiltonianGate as BooleanHamiltonianGate from cirq.ops.common_channels import ( - amplitude_damp, - AmplitudeDampingChannel, - asymmetric_depolarize, - AsymmetricDepolarizingChannel, - bit_flip, - BitFlipChannel, - depolarize, - DepolarizingChannel, - generalized_amplitude_damp, - GeneralizedAmplitudeDampingChannel, - phase_damp, - phase_flip, - PhaseDampingChannel, - PhaseFlipChannel, - R, - reset, - reset_each, - ResetChannel, + amplitude_damp as amplitude_damp, + AmplitudeDampingChannel as AmplitudeDampingChannel, + asymmetric_depolarize as asymmetric_depolarize, + AsymmetricDepolarizingChannel as AsymmetricDepolarizingChannel, + bit_flip as bit_flip, + BitFlipChannel as BitFlipChannel, + depolarize as depolarize, + DepolarizingChannel as DepolarizingChannel, + generalized_amplitude_damp as generalized_amplitude_damp, + GeneralizedAmplitudeDampingChannel as GeneralizedAmplitudeDampingChannel, + phase_damp as phase_damp, + phase_flip as phase_flip, + PhaseDampingChannel as PhaseDampingChannel, + PhaseFlipChannel as PhaseFlipChannel, + R as R, + reset as reset, + reset_each as reset_each, + ResetChannel as ResetChannel, ) from cirq.ops.common_gates import ( - CNOT, - CNotPowGate, - cphase, - CX, - CXPowGate, - CZ, - CZPowGate, - H, - HPowGate, - Rx, - Ry, - Rz, - rx, - ry, - rz, - S, - T, - XPowGate, - YPowGate, - ZPowGate, + CNOT as CNOT, + CNotPowGate as CNotPowGate, + cphase as cphase, + CX as CX, + CXPowGate as CXPowGate, + CZ as CZ, + CZPowGate as CZPowGate, + H as H, + HPowGate as HPowGate, + Rx as Rx, + Ry as Ry, + Rz as Rz, + rx as rx, + ry as ry, + rz as rz, + S as S, + T as T, + XPowGate as XPowGate, + YPowGate as YPowGate, + ZPowGate as ZPowGate, ) from cirq.ops.common_gate_families import ( - AnyUnitaryGateFamily, - AnyIntegerPowerGateFamily, - ParallelGateFamily, + AnyUnitaryGateFamily as AnyUnitaryGateFamily, + AnyIntegerPowerGateFamily as AnyIntegerPowerGateFamily, + ParallelGateFamily as ParallelGateFamily, ) -from cirq.ops.classically_controlled_operation import ClassicallyControlledOperation +from cirq.ops.classically_controlled_operation import ( + ClassicallyControlledOperation as ClassicallyControlledOperation, +) -from cirq.ops.controlled_gate import ControlledGate +from cirq.ops.controlled_gate import ControlledGate as ControlledGate -from cirq.ops.diagonal_gate import DiagonalGate +from cirq.ops.diagonal_gate import DiagonalGate as DiagonalGate -from cirq.ops.eigen_gate import EigenGate +from cirq.ops.eigen_gate import EigenGate as EigenGate -from cirq.ops.fourier_transform import PhaseGradientGate, qft, QuantumFourierTransformGate +from cirq.ops.fourier_transform import ( + PhaseGradientGate as PhaseGradientGate, + qft as qft, + QuantumFourierTransformGate as QuantumFourierTransformGate, +) -from cirq.ops.fsim_gate import FSimGate, PhasedFSimGate +from cirq.ops.fsim_gate import FSimGate as FSimGate, PhasedFSimGate as PhasedFSimGate -from cirq.ops.gate_features import InterchangeableQubitsGate +from cirq.ops.gate_features import InterchangeableQubitsGate as InterchangeableQubitsGate -from cirq.ops.gate_operation import GateOperation +from cirq.ops.gate_operation import GateOperation as GateOperation -from cirq.ops.gateset import GateFamily, Gateset +from cirq.ops.gateset import GateFamily as GateFamily, Gateset as Gateset -from cirq.ops.identity import I, identity_each, IdentityGate +from cirq.ops.identity import I as I, identity_each as identity_each, IdentityGate as IdentityGate -from cirq.ops.global_phase_op import GlobalPhaseGate, global_phase_operation +from cirq.ops.global_phase_op import ( + GlobalPhaseGate as GlobalPhaseGate, + global_phase_operation as global_phase_operation, +) -from cirq.ops.kraus_channel import KrausChannel +from cirq.ops.kraus_channel import KrausChannel as KrausChannel from cirq.ops.linear_combinations import ( - LinearCombinationOfGates, - LinearCombinationOfOperations, - PauliSum, - PauliSumLike, - ProjectorSum, + LinearCombinationOfGates as LinearCombinationOfGates, + LinearCombinationOfOperations as LinearCombinationOfOperations, + PauliSum as PauliSum, + PauliSumLike as PauliSumLike, + ProjectorSum as ProjectorSum, ) -from cirq.ops.mixed_unitary_channel import MixedUnitaryChannel +from cirq.ops.mixed_unitary_channel import MixedUnitaryChannel as MixedUnitaryChannel -from cirq.ops.pauli_sum_exponential import PauliSumExponential +from cirq.ops.pauli_sum_exponential import PauliSumExponential as PauliSumExponential -from cirq.ops.pauli_measurement_gate import PauliMeasurementGate +from cirq.ops.pauli_measurement_gate import PauliMeasurementGate as PauliMeasurementGate -from cirq.ops.parallel_gate import ParallelGate, parallel_gate_op +from cirq.ops.parallel_gate import ( + ParallelGate as ParallelGate, + parallel_gate_op as parallel_gate_op, +) -from cirq.ops.projector import ProjectorString +from cirq.ops.projector import ProjectorString as ProjectorString -from cirq.ops.controlled_operation import ControlledOperation +from cirq.ops.controlled_operation import ControlledOperation as ControlledOperation -from cirq.ops.qubit_manager import BorrowableQubit, CleanQubit, QubitManager, SimpleQubitManager +from cirq.ops.qubit_manager import ( + BorrowableQubit as BorrowableQubit, + CleanQubit as CleanQubit, + QubitManager as QubitManager, + SimpleQubitManager as SimpleQubitManager, +) -from cirq.ops.greedy_qubit_manager import GreedyQubitManager +from cirq.ops.greedy_qubit_manager import GreedyQubitManager as GreedyQubitManager -from cirq.ops.qubit_order import QubitOrder +from cirq.ops.qubit_order import QubitOrder as QubitOrder -from cirq.ops.qubit_order_or_list import QubitOrderOrList +from cirq.ops.qubit_order_or_list import QubitOrderOrList as QubitOrderOrList -from cirq.ops.matrix_gates import MatrixGate +from cirq.ops.matrix_gates import MatrixGate as MatrixGate from cirq.ops.measure_util import ( - M, - measure, - measure_each, - measure_paulistring_terms, - measure_single_paulistring, + M as M, + measure as measure, + measure_each as measure_each, + measure_paulistring_terms as measure_paulistring_terms, + measure_single_paulistring as measure_single_paulistring, ) -from cirq.ops.measurement_gate import MeasurementGate +from cirq.ops.measurement_gate import MeasurementGate as MeasurementGate -from cirq.ops.named_qubit import NamedQubit, NamedQid +from cirq.ops.named_qubit import NamedQubit as NamedQubit, NamedQid as NamedQid from cirq.ops.op_tree import ( - flatten_op_tree, - freeze_op_tree, - flatten_to_ops, - flatten_to_ops_or_moments, - OP_TREE, - transform_op_tree, + flatten_op_tree as flatten_op_tree, + freeze_op_tree as freeze_op_tree, + flatten_to_ops as flatten_to_ops, + flatten_to_ops_or_moments as flatten_to_ops_or_moments, + OP_TREE as OP_TREE, + transform_op_tree as transform_op_tree, ) -from cirq.ops.parity_gates import XX, XXPowGate, YY, YYPowGate, ZZ, ZZPowGate, MSGate, ms +from cirq.ops.parity_gates import ( + XX as XX, + XXPowGate as XXPowGate, + YY as YY, + YYPowGate as YYPowGate, + ZZ as ZZ, + ZZPowGate as ZZPowGate, + MSGate as MSGate, + ms as ms, +) -from cirq.ops.pauli_gates import Pauli, X, Y, Z +from cirq.ops.pauli_gates import Pauli as Pauli, X as X, Y as Y, Z as Z -from cirq.ops.pauli_interaction_gate import PauliInteractionGate +from cirq.ops.pauli_interaction_gate import PauliInteractionGate as PauliInteractionGate from cirq.ops.pauli_string import ( - MutablePauliString, - PAULI_GATE_LIKE, - PAULI_STRING_LIKE, - PauliString, - SingleQubitPauliStringGateOperation, + MutablePauliString as MutablePauliString, + PAULI_GATE_LIKE as PAULI_GATE_LIKE, + PAULI_STRING_LIKE as PAULI_STRING_LIKE, + PauliString as PauliString, + SingleQubitPauliStringGateOperation as SingleQubitPauliStringGateOperation, ) -from cirq.ops.pauli_string_phasor import PauliStringPhasor, PauliStringPhasorGate +from cirq.ops.pauli_string_phasor import ( + PauliStringPhasor as PauliStringPhasor, + PauliStringPhasorGate as PauliStringPhasorGate, +) -from cirq.ops.pauli_string_raw_types import PauliStringGateOperation +from cirq.ops.pauli_string_raw_types import PauliStringGateOperation as PauliStringGateOperation -from cirq.ops.permutation_gate import QubitPermutationGate +from cirq.ops.permutation_gate import QubitPermutationGate as QubitPermutationGate -from cirq.ops.phased_iswap_gate import givens, PhasedISwapPowGate +from cirq.ops.phased_iswap_gate import givens as givens, PhasedISwapPowGate as PhasedISwapPowGate -from cirq.ops.phased_x_gate import PhasedXPowGate +from cirq.ops.phased_x_gate import PhasedXPowGate as PhasedXPowGate -from cirq.ops.phased_x_z_gate import PhasedXZGate +from cirq.ops.phased_x_z_gate import PhasedXZGate as PhasedXZGate -from cirq.ops.qid_util import q +from cirq.ops.qid_util import q as q -from cirq.ops.random_gate_channel import RandomGateChannel +from cirq.ops.random_gate_channel import RandomGateChannel as RandomGateChannel -from cirq.ops.raw_types import Gate, Operation, Qid, TaggedOperation +from cirq.ops.raw_types import ( + Gate as Gate, + Operation as Operation, + Qid as Qid, + TaggedOperation as TaggedOperation, +) from cirq.ops.swap_gates import ( - ISWAP, - ISwapPowGate, - ISWAP_INV, - riswap, - SQRT_ISWAP, - SQRT_ISWAP_INV, - SWAP, - SwapPowGate, + ISWAP as ISWAP, + ISwapPowGate as ISwapPowGate, + ISWAP_INV as ISWAP_INV, + riswap as riswap, + SQRT_ISWAP as SQRT_ISWAP, + SQRT_ISWAP_INV as SQRT_ISWAP_INV, + SWAP as SWAP, + SwapPowGate as SwapPowGate, ) -from cirq.ops.tags import RoutingSwapTag, VirtualTag +from cirq.ops.tags import RoutingSwapTag as RoutingSwapTag, VirtualTag as VirtualTag from cirq.ops.three_qubit_gates import ( - CCNOT, - CCNotPowGate, - CCX, - CCXPowGate, - CCZ, - CCZPowGate, - CSWAP, - CSwapGate, - FREDKIN, - ThreeQubitDiagonalGate, - TOFFOLI, + CCNOT as CCNOT, + CCNotPowGate as CCNotPowGate, + CCX as CCX, + CCXPowGate as CCXPowGate, + CCZ as CCZ, + CCZPowGate as CCZPowGate, + CSWAP as CSWAP, + CSwapGate as CSwapGate, + FREDKIN as FREDKIN, + ThreeQubitDiagonalGate as ThreeQubitDiagonalGate, + TOFFOLI as TOFFOLI, ) -from cirq.ops.two_qubit_diagonal_gate import TwoQubitDiagonalGate +from cirq.ops.two_qubit_diagonal_gate import TwoQubitDiagonalGate as TwoQubitDiagonalGate -from cirq.ops.wait_gate import wait, WaitGate +from cirq.ops.wait_gate import wait as wait, WaitGate as WaitGate -from cirq.ops.state_preparation_channel import StatePreparationChannel +from cirq.ops.state_preparation_channel import StatePreparationChannel as StatePreparationChannel -from cirq.ops.control_values import AbstractControlValues, ProductOfSums, SumOfProducts +from cirq.ops.control_values import ( + AbstractControlValues as AbstractControlValues, + ProductOfSums as ProductOfSums, + SumOfProducts as SumOfProducts, +) -from cirq.ops.uniform_superposition_gate import UniformSuperpositionGate +from cirq.ops.uniform_superposition_gate import UniformSuperpositionGate as UniformSuperpositionGate diff --git a/cirq-core/cirq/ops/boolean_hamiltonian.py b/cirq-core/cirq/ops/boolean_hamiltonian.py index 5da78c3e4b2..99ef9856fb5 100644 --- a/cirq-core/cirq/ops/boolean_hamiltonian.py +++ b/cirq-core/cirq/ops/boolean_hamiltonian.py @@ -31,7 +31,8 @@ import cirq from cirq import value from cirq.ops import raw_types -from cirq.ops.linear_combinations import PauliSum, PauliString +from cirq.ops.linear_combinations import PauliSum +from cirq.ops.pauli_string import PauliString @value.value_equality diff --git a/cirq-core/cirq/protocols/__init__.py b/cirq-core/cirq/protocols/__init__.py index 1ea0b16a126..499c91e34a2 100644 --- a/cirq-core/cirq/protocols/__init__.py +++ b/cirq-core/cirq/protocols/__init__.py @@ -14,114 +14,166 @@ """Protocols (structural subtyping) supported in Cirq.""" -from cirq.protocols.act_on_protocol import act_on, SupportsActOn, SupportsActOnQubits +from cirq.protocols.act_on_protocol import ( + act_on as act_on, + SupportsActOn as SupportsActOn, + SupportsActOnQubits as SupportsActOnQubits, +) + from cirq.protocols.apply_unitary_protocol import ( - apply_unitaries, - apply_unitary, - ApplyUnitaryArgs, - SupportsConsistentApplyUnitary, + apply_unitaries as apply_unitaries, + apply_unitary as apply_unitary, + ApplyUnitaryArgs as ApplyUnitaryArgs, + SupportsConsistentApplyUnitary as SupportsConsistentApplyUnitary, ) + from cirq.protocols.apply_channel_protocol import ( - apply_channel, - ApplyChannelArgs, - SupportsApplyChannel, + apply_channel as apply_channel, + ApplyChannelArgs as ApplyChannelArgs, + SupportsApplyChannel as SupportsApplyChannel, ) + from cirq.protocols.apply_mixture_protocol import ( - apply_mixture, - ApplyMixtureArgs, - SupportsApplyMixture, + apply_mixture as apply_mixture, + ApplyMixtureArgs as ApplyMixtureArgs, + SupportsApplyMixture as SupportsApplyMixture, ) -from cirq.protocols.approximate_equality_protocol import approx_eq, SupportsApproximateEquality -from cirq.protocols.kraus_protocol import kraus, has_kraus, SupportsKraus -from cirq.protocols.commutes_protocol import commutes, definitely_commutes, SupportsCommutes + +from cirq.protocols.approximate_equality_protocol import ( + approx_eq as approx_eq, + SupportsApproximateEquality as SupportsApproximateEquality, +) + +from cirq.protocols.kraus_protocol import ( + kraus as kraus, + has_kraus as has_kraus, + SupportsKraus as SupportsKraus, +) + +from cirq.protocols.commutes_protocol import ( + commutes as commutes, + definitely_commutes as definitely_commutes, + SupportsCommutes as SupportsCommutes, +) + from cirq.protocols.control_key_protocol import ( - control_keys, - measurement_keys_touched, - SupportsControlKey, + control_keys as control_keys, + measurement_keys_touched as measurement_keys_touched, + SupportsControlKey as SupportsControlKey, ) + from cirq.protocols.circuit_diagram_info_protocol import ( - circuit_diagram_info, - CircuitDiagramInfo, - CircuitDiagramInfoArgs, - LabelEntity, - SupportsCircuitDiagramInfo, + circuit_diagram_info as circuit_diagram_info, + CircuitDiagramInfo as CircuitDiagramInfo, + CircuitDiagramInfoArgs as CircuitDiagramInfoArgs, + LabelEntity as LabelEntity, + SupportsCircuitDiagramInfo as SupportsCircuitDiagramInfo, ) + from cirq.protocols.decompose_protocol import ( - decompose, - decompose_once, - decompose_once_with_qubits, - DecompositionContext, - SupportsDecompose, - SupportsDecomposeWithQubits, + decompose as decompose, + decompose_once as decompose_once, + decompose_once_with_qubits as decompose_once_with_qubits, + DecompositionContext as DecompositionContext, + SupportsDecompose as SupportsDecompose, + SupportsDecomposeWithQubits as SupportsDecomposeWithQubits, ) + from cirq.protocols.equal_up_to_global_phase_protocol import ( - equal_up_to_global_phase, - SupportsEqualUpToGlobalPhase, + equal_up_to_global_phase as equal_up_to_global_phase, + SupportsEqualUpToGlobalPhase as SupportsEqualUpToGlobalPhase, +) + +from cirq.protocols.has_stabilizer_effect_protocol import ( + has_stabilizer_effect as has_stabilizer_effect, +) + +from cirq.protocols.has_unitary_protocol import ( + has_unitary as has_unitary, + SupportsExplicitHasUnitary as SupportsExplicitHasUnitary, ) -from cirq.protocols.has_stabilizer_effect_protocol import has_stabilizer_effect -from cirq.protocols.has_unitary_protocol import has_unitary, SupportsExplicitHasUnitary -from cirq.protocols.inverse_protocol import inverse + +from cirq.protocols.inverse_protocol import inverse as inverse + from cirq.protocols.json_serialization import ( - cirq_type_from_json, - DEFAULT_RESOLVERS, - HasJSONNamespace, - JsonResolver, - json_cirq_type, - json_namespace, - to_json_gzip, - read_json_gzip, - to_json, - read_json, - obj_to_dict_helper, - dataclass_json_dict, - SerializableByKey, - SupportsJSON, + cirq_type_from_json as cirq_type_from_json, + DEFAULT_RESOLVERS as DEFAULT_RESOLVERS, + HasJSONNamespace as HasJSONNamespace, + JsonResolver as JsonResolver, + json_cirq_type as json_cirq_type, + json_namespace as json_namespace, + to_json_gzip as to_json_gzip, + read_json_gzip as read_json_gzip, + to_json as to_json, + read_json as read_json, + obj_to_dict_helper as obj_to_dict_helper, + dataclass_json_dict as dataclass_json_dict, + SerializableByKey as SerializableByKey, + SupportsJSON as SupportsJSON, ) + from cirq.protocols.measurement_key_protocol import ( - is_measurement, - measurement_key_name, - measurement_key_obj, - measurement_key_names, - measurement_key_objs, - with_key_path, - with_key_path_prefix, - with_measurement_key_mapping, - with_rescoped_keys, - SupportsMeasurementKey, -) -from cirq.protocols.mixture_protocol import has_mixture, mixture, SupportsMixture, validate_mixture -from cirq.protocols.mul_protocol import mul -from cirq.protocols.pauli_expansion_protocol import pauli_expansion, SupportsPauliExpansion + is_measurement as is_measurement, + measurement_key_name as measurement_key_name, + measurement_key_obj as measurement_key_obj, + measurement_key_names as measurement_key_names, + measurement_key_objs as measurement_key_objs, + with_key_path as with_key_path, + with_key_path_prefix as with_key_path_prefix, + with_measurement_key_mapping as with_measurement_key_mapping, + with_rescoped_keys as with_rescoped_keys, + SupportsMeasurementKey as SupportsMeasurementKey, +) + +from cirq.protocols.mixture_protocol import ( + has_mixture as has_mixture, + mixture as mixture, + SupportsMixture as SupportsMixture, + validate_mixture as validate_mixture, +) + +from cirq.protocols.mul_protocol import mul as mul + +from cirq.protocols.pauli_expansion_protocol import ( + pauli_expansion as pauli_expansion, + SupportsPauliExpansion as SupportsPauliExpansion, +) # pylint: disable=redefined-builtin -from cirq.protocols.pow_protocol import pow +from cirq.protocols.pow_protocol import pow as pow # pylint: enable=redefined-builtin + from cirq.protocols.qasm import ( - qasm, - QasmArgs, - SupportsQasm, - SupportsQasmWithArgs, - SupportsQasmWithArgsAndQubits, + qasm as qasm, + QasmArgs as QasmArgs, + SupportsQasm as SupportsQasm, + SupportsQasmWithArgs as SupportsQasmWithArgs, + SupportsQasmWithArgsAndQubits as SupportsQasmWithArgsAndQubits, ) + from cirq.protocols.trace_distance_bound import ( - SupportsTraceDistanceBound, - trace_distance_bound, - trace_distance_from_angle_list, + SupportsTraceDistanceBound as SupportsTraceDistanceBound, + trace_distance_bound as trace_distance_bound, + trace_distance_from_angle_list as trace_distance_from_angle_list, ) + from cirq.protocols.resolve_parameters import ( - is_parameterized, - parameter_names, - parameter_symbols, - resolve_parameters, - resolve_parameters_once, - SupportsParameterization, -) -from cirq.protocols.phase_protocol import phase_by, SupportsPhase + is_parameterized as is_parameterized, + parameter_names as parameter_names, + parameter_symbols as parameter_symbols, + resolve_parameters as resolve_parameters, + resolve_parameters_once as resolve_parameters_once, + SupportsParameterization as SupportsParameterization, +) + +from cirq.protocols.phase_protocol import phase_by as phase_by, SupportsPhase as SupportsPhase + from cirq.protocols.qid_shape_protocol import ( - num_qubits, - qid_shape, - SupportsExplicitQidShape, - SupportsExplicitNumQubits, + num_qubits as num_qubits, + qid_shape as qid_shape, + SupportsExplicitQidShape as SupportsExplicitQidShape, + SupportsExplicitNumQubits as SupportsExplicitNumQubits, ) -from cirq.protocols.unitary_protocol import SupportsUnitary, unitary + +from cirq.protocols.unitary_protocol import SupportsUnitary as SupportsUnitary, unitary as unitary diff --git a/cirq-core/cirq/protocols/json_test_data/__init__.py b/cirq-core/cirq/protocols/json_test_data/__init__.py index a7b1f63a839..e1681c8a531 100644 --- a/cirq-core/cirq/protocols/json_test_data/__init__.py +++ b/cirq-core/cirq/protocols/json_test_data/__init__.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cirq.protocols.json_test_data.spec import TestSpec +from cirq.protocols.json_test_data.spec import TestSpec as TestSpec diff --git a/cirq-core/cirq/qis/__init__.py b/cirq-core/cirq/qis/__init__.py index 4edceb0dc0c..e618fc3729e 100644 --- a/cirq-core/cirq/qis/__init__.py +++ b/cirq-core/cirq/qis/__init__.py @@ -15,49 +15,61 @@ """Tools and methods for primitives used in quantum information science.""" from cirq.qis.channels import ( - choi_to_kraus, - choi_to_superoperator, - kraus_to_choi, - kraus_to_superoperator, - operation_to_choi, - operation_to_superoperator, - superoperator_to_choi, - superoperator_to_kraus, + choi_to_kraus as choi_to_kraus, + choi_to_superoperator as choi_to_superoperator, + kraus_to_choi as kraus_to_choi, + kraus_to_superoperator as kraus_to_superoperator, + operation_to_choi as operation_to_choi, + operation_to_superoperator as operation_to_superoperator, + superoperator_to_choi as superoperator_to_choi, + superoperator_to_kraus as superoperator_to_kraus, ) -from cirq.qis.clifford_tableau import CliffordTableau, StabilizerState +from cirq.qis.clifford_tableau import ( + CliffordTableau as CliffordTableau, + StabilizerState as StabilizerState, +) -from cirq.qis.measures import entanglement_fidelity, fidelity, von_neumann_entropy +from cirq.qis.measures import ( + entanglement_fidelity as entanglement_fidelity, + fidelity as fidelity, + von_neumann_entropy as von_neumann_entropy, +) -from cirq.qis.quantum_state_representation import QuantumStateRepresentation +from cirq.qis.quantum_state_representation import ( + QuantumStateRepresentation as QuantumStateRepresentation, +) from cirq.qis.states import ( - bloch_vector_from_state_vector, - density_matrix, - density_matrix_from_state_vector, - dirac_notation, - eye_tensor, - infer_qid_shape, - one_hot, - QUANTUM_STATE_LIKE, - QuantumState, - quantum_state, - STATE_VECTOR_LIKE, - to_valid_density_matrix, - to_valid_state_vector, - validate_density_matrix, - validate_indices, - validate_qid_shape, - validate_normalized_state_vector, + bloch_vector_from_state_vector as bloch_vector_from_state_vector, + density_matrix as density_matrix, + density_matrix_from_state_vector as density_matrix_from_state_vector, + dirac_notation as dirac_notation, + eye_tensor as eye_tensor, + infer_qid_shape as infer_qid_shape, + one_hot as one_hot, + QUANTUM_STATE_LIKE as QUANTUM_STATE_LIKE, + QuantumState as QuantumState, + quantum_state as quantum_state, + STATE_VECTOR_LIKE as STATE_VECTOR_LIKE, + to_valid_density_matrix as to_valid_density_matrix, + to_valid_state_vector as to_valid_state_vector, + validate_density_matrix as validate_density_matrix, + validate_indices as validate_indices, + validate_qid_shape as validate_qid_shape, + validate_normalized_state_vector as validate_normalized_state_vector, ) from cirq.qis.noise_utils import ( - decay_constant_to_xeb_fidelity, - decay_constant_to_pauli_error, - pauli_error_to_decay_constant, - xeb_fidelity_to_decay_constant, - pauli_error_from_t1, - average_error, - decoherence_pauli_error, + decay_constant_to_xeb_fidelity as decay_constant_to_xeb_fidelity, + decay_constant_to_pauli_error as decay_constant_to_pauli_error, + pauli_error_to_decay_constant as pauli_error_to_decay_constant, + xeb_fidelity_to_decay_constant as xeb_fidelity_to_decay_constant, + pauli_error_from_t1 as pauli_error_from_t1, + average_error as average_error, + decoherence_pauli_error as decoherence_pauli_error, +) + +from cirq.qis.entropy import ( + process_renyi_entropy_from_bitstrings as process_renyi_entropy_from_bitstrings, ) -from cirq.qis.entropy import process_renyi_entropy_from_bitstrings diff --git a/cirq-core/cirq/sim/__init__.py b/cirq-core/cirq/sim/__init__.py index 980b649db7a..1d92d0942ce 100644 --- a/cirq-core/cirq/sim/__init__.py +++ b/cirq-core/cirq/sim/__init__.py @@ -15,63 +15,81 @@ """Classes for circuit simulators and base implementations of these classes.""" from cirq.sim.clifford import ( - CliffordSimulator, - CliffordSimulatorStepResult, - CliffordState, - CliffordTrialResult, - CliffordTableauSimulationState, - StabilizerChFormSimulationState, - StabilizerSampler, - StabilizerSimulationState, - StabilizerStateChForm, + CliffordSimulator as CliffordSimulator, + CliffordSimulatorStepResult as CliffordSimulatorStepResult, + CliffordState as CliffordState, + CliffordTrialResult as CliffordTrialResult, + CliffordTableauSimulationState as CliffordTableauSimulationState, + StabilizerChFormSimulationState as StabilizerChFormSimulationState, + StabilizerSampler as StabilizerSampler, + StabilizerSimulationState as StabilizerSimulationState, + StabilizerStateChForm as StabilizerStateChForm, ) -from cirq.sim.density_matrix_simulation_state import DensityMatrixSimulationState +from cirq.sim.density_matrix_simulation_state import ( + DensityMatrixSimulationState as DensityMatrixSimulationState, +) from cirq.sim.density_matrix_simulator import ( - DensityMatrixSimulator, - DensityMatrixStepResult, - DensityMatrixTrialResult, + DensityMatrixSimulator as DensityMatrixSimulator, + DensityMatrixStepResult as DensityMatrixStepResult, + DensityMatrixTrialResult as DensityMatrixTrialResult, ) -from cirq.sim.density_matrix_utils import measure_density_matrix, sample_density_matrix +from cirq.sim.density_matrix_utils import ( + measure_density_matrix as measure_density_matrix, + sample_density_matrix as sample_density_matrix, +) from cirq.sim.mux import ( - CIRCUIT_LIKE, - final_density_matrix, - final_state_vector, - sample, - sample_sweep, + CIRCUIT_LIKE as CIRCUIT_LIKE, + final_density_matrix as final_density_matrix, + final_state_vector as final_state_vector, + sample as sample, + sample_sweep as sample_sweep, ) -from cirq.sim.simulation_product_state import SimulationProductState +from cirq.sim.simulation_product_state import SimulationProductState as SimulationProductState -from cirq.sim.simulation_state import SimulationState +from cirq.sim.simulation_state import SimulationState as SimulationState -from cirq.sim.simulation_state_base import SimulationStateBase +from cirq.sim.simulation_state_base import SimulationStateBase as SimulationStateBase from cirq.sim.simulator import ( - SimulatesAmplitudes, - SimulatesExpectationValues, - SimulatesFinalState, - SimulatesIntermediateState, - SimulatesSamples, - SimulationTrialResult, - StepResult, + SimulatesAmplitudes as SimulatesAmplitudes, + SimulatesExpectationValues as SimulatesExpectationValues, + SimulatesFinalState as SimulatesFinalState, + SimulatesIntermediateState as SimulatesIntermediateState, + SimulatesSamples as SimulatesSamples, + SimulationTrialResult as SimulationTrialResult, + StepResult as StepResult, ) -from cirq.sim.simulator_base import SimulationTrialResultBase, SimulatorBase, StepResultBase +from cirq.sim.simulator_base import ( + SimulationTrialResultBase as SimulationTrialResultBase, + SimulatorBase as SimulatorBase, + StepResultBase as StepResultBase, +) -from cirq.sim.sparse_simulator import Simulator, SparseSimulatorStep +from cirq.sim.sparse_simulator import ( + Simulator as Simulator, + SparseSimulatorStep as SparseSimulatorStep, +) -from cirq.sim.state_vector import measure_state_vector, sample_state_vector, StateVectorMixin +from cirq.sim.state_vector import ( + measure_state_vector as measure_state_vector, + sample_state_vector as sample_state_vector, + StateVectorMixin as StateVectorMixin, +) -from cirq.sim.state_vector_simulation_state import StateVectorSimulationState +from cirq.sim.state_vector_simulation_state import ( + StateVectorSimulationState as StateVectorSimulationState, +) -from cirq.sim.classical_simulator import ClassicalStateSimulator +from cirq.sim.classical_simulator import ClassicalStateSimulator as ClassicalStateSimulator from cirq.sim.state_vector_simulator import ( - SimulatesIntermediateStateVector, - StateVectorStepResult, - StateVectorTrialResult, + SimulatesIntermediateStateVector as SimulatesIntermediateStateVector, + StateVectorStepResult as StateVectorStepResult, + StateVectorTrialResult as StateVectorTrialResult, ) diff --git a/cirq-core/cirq/sim/clifford/__init__.py b/cirq-core/cirq/sim/clifford/__init__.py index 2f7a0a5a46e..fc1cbc598d5 100644 --- a/cirq-core/cirq/sim/clifford/__init__.py +++ b/cirq-core/cirq/sim/clifford/__init__.py @@ -1,18 +1,26 @@ # pylint: disable=wrong-or-nonexistent-copyright-notice from cirq.sim.clifford.clifford_simulator import ( - CliffordSimulator, - CliffordSimulatorStepResult, - CliffordState, - CliffordTrialResult, + CliffordSimulator as CliffordSimulator, + CliffordSimulatorStepResult as CliffordSimulatorStepResult, + CliffordState as CliffordState, + CliffordTrialResult as CliffordTrialResult, ) -from cirq.sim.clifford.clifford_tableau_simulation_state import CliffordTableauSimulationState +from cirq.sim.clifford.clifford_tableau_simulation_state import ( + CliffordTableauSimulationState as CliffordTableauSimulationState, +) -from cirq.sim.clifford.stabilizer_ch_form_simulation_state import StabilizerChFormSimulationState +from cirq.sim.clifford.stabilizer_ch_form_simulation_state import ( + StabilizerChFormSimulationState as StabilizerChFormSimulationState, +) -from cirq.sim.clifford.stabilizer_sampler import StabilizerSampler +from cirq.sim.clifford.stabilizer_sampler import StabilizerSampler as StabilizerSampler -from cirq.sim.clifford.stabilizer_simulation_state import StabilizerSimulationState +from cirq.sim.clifford.stabilizer_simulation_state import ( + StabilizerSimulationState as StabilizerSimulationState, +) -from cirq.sim.clifford.stabilizer_state_ch_form import StabilizerStateChForm +from cirq.sim.clifford.stabilizer_state_ch_form import ( + StabilizerStateChForm as StabilizerStateChForm, +) diff --git a/cirq-core/cirq/study/__init__.py b/cirq-core/cirq/study/__init__.py index 13511f8fbd9..da93db539a0 100644 --- a/cirq-core/cirq/study/__init__.py +++ b/cirq-core/cirq/study/__init__.py @@ -15,33 +15,38 @@ """Parameterized circuits and results.""" from cirq.study.flatten_expressions import ( - ExpressionMap, - flatten, - flatten_with_params, - flatten_with_sweep, + ExpressionMap as ExpressionMap, + flatten as flatten, + flatten_with_params as flatten_with_params, + flatten_with_sweep as flatten_with_sweep, ) from cirq.study.resolver import ( - ParamDictType, - ParamMappingType, - ParamResolver, - ParamResolverOrSimilarType, + ParamDictType as ParamDictType, + ParamMappingType as ParamMappingType, + ParamResolver as ParamResolver, + ParamResolverOrSimilarType as ParamResolverOrSimilarType, ) -from cirq.study.sweepable import Sweepable, to_resolvers, to_sweep, to_sweeps +from cirq.study.sweepable import ( + Sweepable as Sweepable, + to_resolvers as to_resolvers, + to_sweep as to_sweep, + to_sweeps as to_sweeps, +) from cirq.study.sweeps import ( - Linspace, - ListSweep, - Points, - Product, - Sweep, - UNIT_SWEEP, - UnitSweep, - Zip, - ZipLongest, - dict_to_product_sweep, - dict_to_zip_sweep, + Linspace as Linspace, + ListSweep as ListSweep, + Points as Points, + Product as Product, + Sweep as Sweep, + UNIT_SWEEP as UNIT_SWEEP, + UnitSweep as UnitSweep, + Zip as Zip, + ZipLongest as ZipLongest, + dict_to_product_sweep as dict_to_product_sweep, + dict_to_zip_sweep as dict_to_zip_sweep, ) -from cirq.study.result import ResultDict, Result +from cirq.study.result import ResultDict as ResultDict, Result as Result diff --git a/cirq-core/cirq/testing/__init__.py b/cirq-core/cirq/testing/__init__.py index 06c9adbfce5..03f891d8fe0 100644 --- a/cirq-core/cirq/testing/__init__.py +++ b/cirq-core/cirq/testing/__init__.py @@ -15,109 +15,135 @@ """Utilities for testing code.""" from cirq.testing.circuit_compare import ( - assert_circuits_with_terminal_measurements_are_equivalent, - assert_circuits_have_same_unitary_given_final_permutation, - assert_has_consistent_apply_channel, - assert_has_consistent_apply_unitary, - assert_has_consistent_apply_unitary_for_various_exponents, - assert_has_diagram, - assert_same_circuits, - highlight_text_differences, - assert_has_consistent_qid_shape, + # pylint: disable=line-too-long + assert_circuits_with_terminal_measurements_are_equivalent as assert_circuits_with_terminal_measurements_are_equivalent, + assert_circuits_have_same_unitary_given_final_permutation as assert_circuits_have_same_unitary_given_final_permutation, + assert_has_consistent_apply_channel as assert_has_consistent_apply_channel, + assert_has_consistent_apply_unitary as assert_has_consistent_apply_unitary, + assert_has_consistent_apply_unitary_for_various_exponents as assert_has_consistent_apply_unitary_for_various_exponents, + assert_has_diagram as assert_has_diagram, + assert_same_circuits as assert_same_circuits, + highlight_text_differences as highlight_text_differences, + assert_has_consistent_qid_shape as assert_has_consistent_qid_shape, ) -from cirq.testing.consistent_act_on import assert_all_implemented_act_on_effects_match_unitary +from cirq.testing.consistent_act_on import ( + # pylint: disable=line-too-long + assert_all_implemented_act_on_effects_match_unitary as assert_all_implemented_act_on_effects_match_unitary, +) -from cirq.testing.consistent_channels import assert_consistent_channel, assert_consistent_mixture +from cirq.testing.consistent_channels import ( + assert_consistent_channel as assert_consistent_channel, + assert_consistent_mixture as assert_consistent_mixture, +) from cirq.testing.consistent_controlled_gate_op import ( - assert_controlled_and_controlled_by_identical, - assert_controlled_unitary_consistent, + assert_controlled_and_controlled_by_identical as assert_controlled_and_controlled_by_identical, + assert_controlled_unitary_consistent as assert_controlled_unitary_consistent, ) from cirq.testing.consistent_decomposition import ( - assert_decompose_ends_at_default_gateset, - assert_decompose_is_consistent_with_unitary, + assert_decompose_ends_at_default_gateset as assert_decompose_ends_at_default_gateset, + assert_decompose_is_consistent_with_unitary as assert_decompose_is_consistent_with_unitary, ) from cirq.testing.consistent_pauli_expansion import ( - assert_pauli_expansion_is_consistent_with_unitary, + # pylint: disable=line-too-long + assert_pauli_expansion_is_consistent_with_unitary as assert_pauli_expansion_is_consistent_with_unitary, ) -from cirq.testing.consistent_phase_by import assert_phase_by_is_consistent_with_unitary +from cirq.testing.consistent_phase_by import ( + assert_phase_by_is_consistent_with_unitary as assert_phase_by_is_consistent_with_unitary, +) from cirq.testing.consistent_protocols import ( - assert_eigengate_implements_consistent_protocols, - assert_has_consistent_trace_distance_bound, - assert_implements_consistent_protocols, - assert_commutes_magic_method_consistent_with_unitaries, + # pylint: disable=line-too-long + assert_eigengate_implements_consistent_protocols as assert_eigengate_implements_consistent_protocols, + assert_has_consistent_trace_distance_bound as assert_has_consistent_trace_distance_bound, + assert_implements_consistent_protocols as assert_implements_consistent_protocols, + assert_commutes_magic_method_consistent_with_unitaries as assert_commutes_magic_method_consistent_with_unitaries, ) -from cirq.testing.consistent_qasm import assert_qasm_is_consistent_with_unitary +from cirq.testing.consistent_qasm import ( + assert_qasm_is_consistent_with_unitary as assert_qasm_is_consistent_with_unitary, +) -from cirq.testing.consistent_resolve_parameters import assert_consistent_resolve_parameters +from cirq.testing.consistent_resolve_parameters import ( + assert_consistent_resolve_parameters as assert_consistent_resolve_parameters, +) -from cirq.testing.consistent_specified_has_unitary import assert_specifies_has_unitary_if_unitary +from cirq.testing.consistent_specified_has_unitary import ( + assert_specifies_has_unitary_if_unitary as assert_specifies_has_unitary_if_unitary, +) -from cirq.testing.deprecation import assert_deprecated +from cirq.testing.deprecation import assert_deprecated as assert_deprecated -from cirq.testing.devices import ValidatingTestDevice +from cirq.testing.devices import ValidatingTestDevice as ValidatingTestDevice -from cirq.testing.equals_tester import EqualsTester +from cirq.testing.equals_tester import EqualsTester as EqualsTester -from cirq.testing.equivalent_basis_map import assert_equivalent_computational_basis_map +from cirq.testing.equivalent_basis_map import ( + assert_equivalent_computational_basis_map as assert_equivalent_computational_basis_map, +) -from cirq.testing.equivalent_repr_eval import assert_equivalent_repr +from cirq.testing.equivalent_repr_eval import assert_equivalent_repr as assert_equivalent_repr from cirq.testing.gate_features import ( - SingleQubitGate, - TwoQubitGate, - ThreeQubitGate, - DoesNotSupportSerializationGate, + SingleQubitGate as SingleQubitGate, + TwoQubitGate as TwoQubitGate, + ThreeQubitGate as ThreeQubitGate, + DoesNotSupportSerializationGate as DoesNotSupportSerializationGate, ) -from cirq.testing.json import assert_json_roundtrip_works +from cirq.testing.json import assert_json_roundtrip_works as assert_json_roundtrip_works from cirq.testing.lin_alg_utils import ( - assert_allclose_up_to_global_phase, - random_density_matrix, - random_orthogonal, - random_special_orthogonal, - random_special_unitary, - random_superposition, - random_unitary, + assert_allclose_up_to_global_phase as assert_allclose_up_to_global_phase, + random_density_matrix as random_density_matrix, + random_orthogonal as random_orthogonal, + random_special_orthogonal as random_special_orthogonal, + random_special_unitary as random_special_unitary, + random_superposition as random_superposition, + random_unitary as random_unitary, ) -from cirq.testing.logs import assert_logs +from cirq.testing.logs import assert_logs as assert_logs -from cirq.testing.no_identifier_qubit import NoIdentifierQubit +from cirq.testing.no_identifier_qubit import NoIdentifierQubit as NoIdentifierQubit -from cirq.testing.op_tree import assert_equivalent_op_tree +from cirq.testing.op_tree import assert_equivalent_op_tree as assert_equivalent_op_tree -from cirq.testing.order_tester import OrderTester +from cirq.testing.order_tester import OrderTester as OrderTester -from cirq.testing.pytest_randomly_utils import retry_once_with_later_random_values +from cirq.testing.pytest_randomly_utils import ( + retry_once_with_later_random_values as retry_once_with_later_random_values, +) from cirq.testing.random_circuit import ( - DEFAULT_GATE_DOMAIN, - random_circuit, - random_two_qubit_circuit_with_czs, + DEFAULT_GATE_DOMAIN as DEFAULT_GATE_DOMAIN, + random_circuit as random_circuit, + random_two_qubit_circuit_with_czs as random_two_qubit_circuit_with_czs, ) from cirq.testing.repr_pretty_tester import ( - assert_repr_pretty, - assert_repr_pretty_contains, - FakePrinter, + assert_repr_pretty as assert_repr_pretty, + assert_repr_pretty_contains as assert_repr_pretty_contains, + FakePrinter as FakePrinter, ) from cirq.testing.routing_devices import ( - construct_grid_device, - construct_ring_device, - RoutingTestingDevice, + construct_grid_device as construct_grid_device, + construct_ring_device as construct_ring_device, + RoutingTestingDevice as RoutingTestingDevice, ) -from cirq.testing.sample_circuits import nonoptimal_toffoli_circuit +from cirq.testing.sample_circuits import nonoptimal_toffoli_circuit as nonoptimal_toffoli_circuit -from cirq.testing.sample_gates import PhaseUsingCleanAncilla, PhaseUsingDirtyAncilla +from cirq.testing.sample_gates import ( + PhaseUsingCleanAncilla as PhaseUsingCleanAncilla, + PhaseUsingDirtyAncilla as PhaseUsingDirtyAncilla, +) -from cirq.testing.consistent_unitary import assert_unitary_is_consistent +from cirq.testing.consistent_unitary import ( + assert_unitary_is_consistent as assert_unitary_is_consistent, +) diff --git a/cirq-core/cirq/testing/_compat_test_data/module_a/__init__.py b/cirq-core/cirq/testing/_compat_test_data/module_a/__init__.py index 22e43c164fb..8f7e9740f31 100644 --- a/cirq-core/cirq/testing/_compat_test_data/module_a/__init__.py +++ b/cirq-core/cirq/testing/_compat_test_data/module_a/__init__.py @@ -5,9 +5,9 @@ from cirq.testing._compat_test_data.module_a import module_b -from cirq.testing._compat_test_data.module_a.dupe import DUPE_CONSTANT +from cirq.testing._compat_test_data.module_a.dupe import DUPE_CONSTANT as DUPE_CONSTANT -from cirq.testing._compat_test_data.module_a.types import SampleType +from cirq.testing._compat_test_data.module_a.types import SampleType as SampleType MODULE_A_ATTRIBUTE = "module_a" diff --git a/cirq-core/cirq/testing/_compat_test_data/module_a/sub/subsub/__init__.py b/cirq-core/cirq/testing/_compat_test_data/module_a/sub/subsub/__init__.py index 6a8f2b33266..bbd83516383 100644 --- a/cirq-core/cirq/testing/_compat_test_data/module_a/sub/subsub/__init__.py +++ b/cirq-core/cirq/testing/_compat_test_data/module_a/sub/subsub/__init__.py @@ -1,2 +1,2 @@ # pylint: disable=wrong-or-nonexistent-copyright-notice -from cirq.testing._compat_test_data.module_a.sub.subsub.dupe import DUPE_CONSTANT +from cirq.testing._compat_test_data.module_a.sub.subsub.dupe import DUPE_CONSTANT as DUPE_CONSTANT diff --git a/cirq-core/cirq/testing/json.py b/cirq-core/cirq/testing/json.py index 2b50518cd31..717f6d2a14d 100644 --- a/cirq-core/cirq/testing/json.py +++ b/cirq-core/cirq/testing/json.py @@ -11,18 +11,19 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + import dataclasses import inspect import io import pathlib from dataclasses import dataclass +from types import ModuleType from typing import List, Type, Dict, Iterator, Tuple, Set import numpy as np import pandas as pd import cirq -from cirq._import import ModuleType # This is the testing framework for json serialization # The actual tests live in cirq.protocols.json_serialization_test.py. diff --git a/cirq-core/cirq/transformers/__init__.py b/cirq-core/cirq/transformers/__init__.py index 5f3f8f2f17a..dcfbc6307d7 100644 --- a/cirq-core/cirq/transformers/__init__.py +++ b/cirq-core/cirq/transformers/__init__.py @@ -15,124 +15,136 @@ """Classes and methods for transforming circuits.""" from cirq.transformers.analytical_decompositions import ( - compute_cphase_exponents_for_fsim_decomposition, - decompose_cphase_into_two_fsim, - decompose_clifford_tableau_to_operations, - decompose_multi_controlled_x, - decompose_multi_controlled_rotation, - decompose_two_qubit_interaction_into_four_fsim_gates, - is_negligible_turn, - parameterized_2q_op_to_sqrt_iswap_operations, - prepare_two_qubit_state_using_cz, - prepare_two_qubit_state_using_iswap, - prepare_two_qubit_state_using_sqrt_iswap, - quantum_shannon_decomposition, - single_qubit_matrix_to_gates, - single_qubit_matrix_to_pauli_rotations, - single_qubit_matrix_to_phased_x_z, - single_qubit_matrix_to_phxz, - single_qubit_op_to_framed_phase_form, - three_qubit_matrix_to_operations, - two_qubit_matrix_to_cz_isometry, - two_qubit_matrix_to_cz_operations, - two_qubit_matrix_to_diagonal_and_cz_operations, - two_qubit_matrix_to_ion_operations, - two_qubit_matrix_to_sqrt_iswap_operations, - unitary_to_pauli_string, + # pylint: disable=line-too-long + compute_cphase_exponents_for_fsim_decomposition as compute_cphase_exponents_for_fsim_decomposition, + decompose_cphase_into_two_fsim as decompose_cphase_into_two_fsim, + decompose_clifford_tableau_to_operations as decompose_clifford_tableau_to_operations, + decompose_multi_controlled_x as decompose_multi_controlled_x, + decompose_multi_controlled_rotation as decompose_multi_controlled_rotation, + decompose_two_qubit_interaction_into_four_fsim_gates as decompose_two_qubit_interaction_into_four_fsim_gates, + is_negligible_turn as is_negligible_turn, + parameterized_2q_op_to_sqrt_iswap_operations as parameterized_2q_op_to_sqrt_iswap_operations, + prepare_two_qubit_state_using_cz as prepare_two_qubit_state_using_cz, + prepare_two_qubit_state_using_iswap as prepare_two_qubit_state_using_iswap, + prepare_two_qubit_state_using_sqrt_iswap as prepare_two_qubit_state_using_sqrt_iswap, + quantum_shannon_decomposition as quantum_shannon_decomposition, + single_qubit_matrix_to_gates as single_qubit_matrix_to_gates, + single_qubit_matrix_to_pauli_rotations as single_qubit_matrix_to_pauli_rotations, + single_qubit_matrix_to_phased_x_z as single_qubit_matrix_to_phased_x_z, + single_qubit_matrix_to_phxz as single_qubit_matrix_to_phxz, + single_qubit_op_to_framed_phase_form as single_qubit_op_to_framed_phase_form, + three_qubit_matrix_to_operations as three_qubit_matrix_to_operations, + two_qubit_matrix_to_cz_isometry as two_qubit_matrix_to_cz_isometry, + two_qubit_matrix_to_cz_operations as two_qubit_matrix_to_cz_operations, + two_qubit_matrix_to_diagonal_and_cz_operations as two_qubit_matrix_to_diagonal_and_cz_operations, + two_qubit_matrix_to_ion_operations as two_qubit_matrix_to_ion_operations, + two_qubit_matrix_to_sqrt_iswap_operations as two_qubit_matrix_to_sqrt_iswap_operations, + unitary_to_pauli_string as unitary_to_pauli_string, ) from cirq.transformers.heuristic_decompositions import ( - TwoQubitGateTabulation, - TwoQubitGateTabulationResult, - two_qubit_gate_product_tabulation, + TwoQubitGateTabulation as TwoQubitGateTabulation, + TwoQubitGateTabulationResult as TwoQubitGateTabulationResult, + two_qubit_gate_product_tabulation as two_qubit_gate_product_tabulation, ) from cirq.transformers.routing import ( - AbstractInitialMapper, - HardCodedInitialMapper, - LineInitialMapper, - MappingManager, - RouteCQC, - routed_circuit_with_mapping, + AbstractInitialMapper as AbstractInitialMapper, + HardCodedInitialMapper as HardCodedInitialMapper, + LineInitialMapper as LineInitialMapper, + MappingManager as MappingManager, + RouteCQC as RouteCQC, + routed_circuit_with_mapping as routed_circuit_with_mapping, ) from cirq.transformers.target_gatesets import ( - create_transformer_with_kwargs, - CompilationTargetGateset, - CZTargetGateset, - SqrtIswapTargetGateset, - TwoQubitCompilationTargetGateset, + create_transformer_with_kwargs as create_transformer_with_kwargs, + CompilationTargetGateset as CompilationTargetGateset, + CZTargetGateset as CZTargetGateset, + SqrtIswapTargetGateset as SqrtIswapTargetGateset, + TwoQubitCompilationTargetGateset as TwoQubitCompilationTargetGateset, ) -from cirq.transformers.align import align_left, align_right +from cirq.transformers.align import align_left as align_left, align_right as align_right -from cirq.transformers.stratify import stratified_circuit +from cirq.transformers.stratify import stratified_circuit as stratified_circuit -from cirq.transformers.expand_composite import expand_composite +from cirq.transformers.expand_composite import expand_composite as expand_composite -from cirq.transformers.eject_phased_paulis import eject_phased_paulis +from cirq.transformers.eject_phased_paulis import eject_phased_paulis as eject_phased_paulis -from cirq.transformers.optimize_for_target_gateset import optimize_for_target_gateset +from cirq.transformers.optimize_for_target_gateset import ( + optimize_for_target_gateset as optimize_for_target_gateset, +) -from cirq.transformers.drop_empty_moments import drop_empty_moments +from cirq.transformers.drop_empty_moments import drop_empty_moments as drop_empty_moments -from cirq.transformers.drop_negligible_operations import drop_negligible_operations +from cirq.transformers.drop_negligible_operations import ( + drop_negligible_operations as drop_negligible_operations, +) -from cirq.transformers.dynamical_decoupling import add_dynamical_decoupling +from cirq.transformers.dynamical_decoupling import ( + add_dynamical_decoupling as add_dynamical_decoupling, +) -from cirq.transformers.eject_z import eject_z +from cirq.transformers.eject_z import eject_z as eject_z from cirq.transformers.measurement_transformers import ( - defer_measurements, - dephase_measurements, - drop_terminal_measurements, + defer_measurements as defer_measurements, + dephase_measurements as dephase_measurements, + drop_terminal_measurements as drop_terminal_measurements, ) -from cirq.transformers.merge_k_qubit_gates import merge_k_qubit_unitaries +from cirq.transformers.merge_k_qubit_gates import merge_k_qubit_unitaries as merge_k_qubit_unitaries from cirq.transformers.merge_single_qubit_gates import ( - merge_single_qubit_gates_to_phased_x_and_z, - merge_single_qubit_gates_to_phxz, - merge_single_qubit_moments_to_phxz, + merge_single_qubit_gates_to_phased_x_and_z as merge_single_qubit_gates_to_phased_x_and_z, + merge_single_qubit_gates_to_phxz as merge_single_qubit_gates_to_phxz, + merge_single_qubit_moments_to_phxz as merge_single_qubit_moments_to_phxz, ) -from cirq.transformers.qubit_management_transformers import map_clean_and_borrowable_qubits +from cirq.transformers.qubit_management_transformers import ( + map_clean_and_borrowable_qubits as map_clean_and_borrowable_qubits, +) -from cirq.transformers.synchronize_terminal_measurements import synchronize_terminal_measurements +from cirq.transformers.synchronize_terminal_measurements import ( + synchronize_terminal_measurements as synchronize_terminal_measurements, +) from cirq.transformers.transformer_api import ( - LogLevel, - TRANSFORMER, - TransformerContext, - TransformerLogger, - transformer, + LogLevel as LogLevel, + TRANSFORMER as TRANSFORMER, + TransformerContext as TransformerContext, + TransformerLogger as TransformerLogger, + transformer as transformer, ) from cirq.transformers.transformer_primitives import ( - map_moments, - map_operations, - map_operations_and_unroll, - merge_k_qubit_unitaries_to_circuit_op, - merge_moments, - merge_operations, - merge_operations_to_circuit_op, - toggle_tags, - unroll_circuit_op, - unroll_circuit_op_greedy_earliest, - unroll_circuit_op_greedy_frontier, + map_moments as map_moments, + map_operations as map_operations, + map_operations_and_unroll as map_operations_and_unroll, + merge_k_qubit_unitaries_to_circuit_op as merge_k_qubit_unitaries_to_circuit_op, + merge_moments as merge_moments, + merge_operations as merge_operations, + merge_operations_to_circuit_op as merge_operations_to_circuit_op, + toggle_tags as toggle_tags, + unroll_circuit_op as unroll_circuit_op, + unroll_circuit_op_greedy_earliest as unroll_circuit_op_greedy_earliest, + unroll_circuit_op_greedy_frontier as unroll_circuit_op_greedy_frontier, ) - from cirq.transformers.gauge_compiling import ( - CZGaugeTransformer, - ConstantGauge, - Gauge, - GaugeSelector, - GaugeTransformer, - ISWAPGaugeTransformer, - SpinInversionGaugeTransformer, - SqrtCZGaugeTransformer, - SqrtISWAPGaugeTransformer, + CZGaugeTransformer as CZGaugeTransformer, + ConstantGauge as ConstantGauge, + Gauge as Gauge, + GaugeSelector as GaugeSelector, + GaugeTransformer as GaugeTransformer, + ISWAPGaugeTransformer as ISWAPGaugeTransformer, + SpinInversionGaugeTransformer as SpinInversionGaugeTransformer, + SqrtCZGaugeTransformer as SqrtCZGaugeTransformer, + SqrtISWAPGaugeTransformer as SqrtISWAPGaugeTransformer, ) -from cirq.transformers.randomized_measurements import RandomizedMeasurements +from cirq.transformers.randomized_measurements import ( + RandomizedMeasurements as RandomizedMeasurements, +) diff --git a/cirq-core/cirq/transformers/analytical_decompositions/__init__.py b/cirq-core/cirq/transformers/analytical_decompositions/__init__.py index decd3fffc85..df2c87d29d5 100644 --- a/cirq-core/cirq/transformers/analytical_decompositions/__init__.py +++ b/cirq-core/cirq/transformers/analytical_decompositions/__init__.py @@ -15,64 +15,67 @@ """Utilities for analytical decomposition of cirq gates.""" from cirq.transformers.analytical_decompositions.clifford_decomposition import ( - decompose_clifford_tableau_to_operations, + decompose_clifford_tableau_to_operations as decompose_clifford_tableau_to_operations, ) from cirq.transformers.analytical_decompositions.controlled_gate_decomposition import ( - decompose_multi_controlled_x, - decompose_multi_controlled_rotation, + decompose_multi_controlled_x as decompose_multi_controlled_x, + decompose_multi_controlled_rotation as decompose_multi_controlled_rotation, ) from cirq.transformers.analytical_decompositions.cphase_to_fsim import ( - compute_cphase_exponents_for_fsim_decomposition, - decompose_cphase_into_two_fsim, + # pylint: disable=line-too-long + compute_cphase_exponents_for_fsim_decomposition as compute_cphase_exponents_for_fsim_decomposition, + decompose_cphase_into_two_fsim as decompose_cphase_into_two_fsim, ) from cirq.transformers.analytical_decompositions.quantum_shannon_decomposition import ( - quantum_shannon_decomposition, + quantum_shannon_decomposition as quantum_shannon_decomposition, ) from cirq.transformers.analytical_decompositions.single_qubit_decompositions import ( - is_negligible_turn, - single_qubit_matrix_to_gates, - single_qubit_matrix_to_pauli_rotations, - single_qubit_matrix_to_phased_x_z, - single_qubit_matrix_to_phxz, - single_qubit_op_to_framed_phase_form, + is_negligible_turn as is_negligible_turn, + single_qubit_matrix_to_gates as single_qubit_matrix_to_gates, + single_qubit_matrix_to_pauli_rotations as single_qubit_matrix_to_pauli_rotations, + single_qubit_matrix_to_phased_x_z as single_qubit_matrix_to_phased_x_z, + single_qubit_matrix_to_phxz as single_qubit_matrix_to_phxz, + single_qubit_op_to_framed_phase_form as single_qubit_op_to_framed_phase_form, ) from cirq.transformers.analytical_decompositions.three_qubit_decomposition import ( - three_qubit_matrix_to_operations, + three_qubit_matrix_to_operations as three_qubit_matrix_to_operations, ) from cirq.transformers.analytical_decompositions.two_qubit_to_cz import ( - two_qubit_matrix_to_cz_operations, - two_qubit_matrix_to_diagonal_and_cz_operations, + # pylint: disable=line-too-long + two_qubit_matrix_to_cz_operations as two_qubit_matrix_to_cz_operations, + two_qubit_matrix_to_diagonal_and_cz_operations as two_qubit_matrix_to_diagonal_and_cz_operations, ) from cirq.transformers.analytical_decompositions.two_qubit_to_fsim import ( - decompose_two_qubit_interaction_into_four_fsim_gates, + # pylint: disable=line-too-long + decompose_two_qubit_interaction_into_four_fsim_gates as decompose_two_qubit_interaction_into_four_fsim_gates, ) from cirq.transformers.analytical_decompositions.two_qubit_to_ms import ( - two_qubit_matrix_to_ion_operations, + two_qubit_matrix_to_ion_operations as two_qubit_matrix_to_ion_operations, ) from cirq.transformers.analytical_decompositions.two_qubit_to_sqrt_iswap import ( - parameterized_2q_op_to_sqrt_iswap_operations, - two_qubit_matrix_to_sqrt_iswap_operations, + parameterized_2q_op_to_sqrt_iswap_operations as parameterized_2q_op_to_sqrt_iswap_operations, + two_qubit_matrix_to_sqrt_iswap_operations as two_qubit_matrix_to_sqrt_iswap_operations, ) from cirq.transformers.analytical_decompositions.two_qubit_state_preparation import ( - prepare_two_qubit_state_using_cz, - prepare_two_qubit_state_using_sqrt_iswap, - prepare_two_qubit_state_using_iswap, + prepare_two_qubit_state_using_cz as prepare_two_qubit_state_using_cz, + prepare_two_qubit_state_using_sqrt_iswap as prepare_two_qubit_state_using_sqrt_iswap, + prepare_two_qubit_state_using_iswap as prepare_two_qubit_state_using_iswap, ) from cirq.transformers.analytical_decompositions.single_to_two_qubit_isometry import ( - two_qubit_matrix_to_cz_isometry, + two_qubit_matrix_to_cz_isometry as two_qubit_matrix_to_cz_isometry, ) from cirq.transformers.analytical_decompositions.pauli_string_decomposition import ( - unitary_to_pauli_string, + unitary_to_pauli_string as unitary_to_pauli_string, ) diff --git a/cirq-core/cirq/transformers/gauge_compiling/__init__.py b/cirq-core/cirq/transformers/gauge_compiling/__init__.py index eb7146f7077..3a87f3deaeb 100644 --- a/cirq-core/cirq/transformers/gauge_compiling/__init__.py +++ b/cirq-core/cirq/transformers/gauge_compiling/__init__.py @@ -14,13 +14,26 @@ from cirq.transformers.gauge_compiling.gauge_compiling import ( - ConstantGauge, - Gauge, - GaugeSelector, - GaugeTransformer, + ConstantGauge as ConstantGauge, + Gauge as Gauge, + GaugeSelector as GaugeSelector, + GaugeTransformer as GaugeTransformer, +) + +from cirq.transformers.gauge_compiling.sqrt_cz_gauge import ( + SqrtCZGaugeTransformer as SqrtCZGaugeTransformer, +) + +from cirq.transformers.gauge_compiling.spin_inversion_gauge import ( + SpinInversionGaugeTransformer as SpinInversionGaugeTransformer, +) + +from cirq.transformers.gauge_compiling.cz_gauge import CZGaugeTransformer as CZGaugeTransformer + +from cirq.transformers.gauge_compiling.iswap_gauge import ( + ISWAPGaugeTransformer as ISWAPGaugeTransformer, +) + +from cirq.transformers.gauge_compiling.sqrt_iswap_gauge import ( + SqrtISWAPGaugeTransformer as SqrtISWAPGaugeTransformer, ) -from cirq.transformers.gauge_compiling.sqrt_cz_gauge import SqrtCZGaugeTransformer -from cirq.transformers.gauge_compiling.spin_inversion_gauge import SpinInversionGaugeTransformer -from cirq.transformers.gauge_compiling.cz_gauge import CZGaugeTransformer -from cirq.transformers.gauge_compiling.iswap_gauge import ISWAPGaugeTransformer -from cirq.transformers.gauge_compiling.sqrt_iswap_gauge import SqrtISWAPGaugeTransformer diff --git a/cirq-core/cirq/transformers/heuristic_decompositions/__init__.py b/cirq-core/cirq/transformers/heuristic_decompositions/__init__.py index 69584bfa144..c505870c9ee 100644 --- a/cirq-core/cirq/transformers/heuristic_decompositions/__init__.py +++ b/cirq-core/cirq/transformers/heuristic_decompositions/__init__.py @@ -15,7 +15,7 @@ """Utilities for heuristic decomposition of cirq gates.""" from cirq.transformers.heuristic_decompositions.two_qubit_gate_tabulation import ( - TwoQubitGateTabulation, - TwoQubitGateTabulationResult, - two_qubit_gate_product_tabulation, + TwoQubitGateTabulation as TwoQubitGateTabulation, + TwoQubitGateTabulationResult as TwoQubitGateTabulationResult, + two_qubit_gate_product_tabulation as two_qubit_gate_product_tabulation, ) diff --git a/cirq-core/cirq/transformers/routing/__init__.py b/cirq-core/cirq/transformers/routing/__init__.py index c35f7eb1598..33d836d881c 100644 --- a/cirq-core/cirq/transformers/routing/__init__.py +++ b/cirq-core/cirq/transformers/routing/__init__.py @@ -14,8 +14,17 @@ """Routing utilities in Cirq.""" -from cirq.transformers.routing.initial_mapper import AbstractInitialMapper, HardCodedInitialMapper -from cirq.transformers.routing.mapping_manager import MappingManager -from cirq.transformers.routing.line_initial_mapper import LineInitialMapper -from cirq.transformers.routing.route_circuit_cqc import RouteCQC -from cirq.transformers.routing.visualize_routed_circuit import routed_circuit_with_mapping +from cirq.transformers.routing.initial_mapper import ( + AbstractInitialMapper as AbstractInitialMapper, + HardCodedInitialMapper as HardCodedInitialMapper, +) + +from cirq.transformers.routing.mapping_manager import MappingManager as MappingManager + +from cirq.transformers.routing.line_initial_mapper import LineInitialMapper as LineInitialMapper + +from cirq.transformers.routing.route_circuit_cqc import RouteCQC as RouteCQC + +from cirq.transformers.routing.visualize_routed_circuit import ( + routed_circuit_with_mapping as routed_circuit_with_mapping, +) diff --git a/cirq-core/cirq/transformers/target_gatesets/__init__.py b/cirq-core/cirq/transformers/target_gatesets/__init__.py index 9c5369d6120..fc8824b2d46 100644 --- a/cirq-core/cirq/transformers/target_gatesets/__init__.py +++ b/cirq-core/cirq/transformers/target_gatesets/__init__.py @@ -15,11 +15,13 @@ """Gatesets which can act as compilation targets in Cirq.""" from cirq.transformers.target_gatesets.compilation_target_gateset import ( - create_transformer_with_kwargs, - CompilationTargetGateset, - TwoQubitCompilationTargetGateset, + create_transformer_with_kwargs as create_transformer_with_kwargs, + CompilationTargetGateset as CompilationTargetGateset, + TwoQubitCompilationTargetGateset as TwoQubitCompilationTargetGateset, ) -from cirq.transformers.target_gatesets.cz_gateset import CZTargetGateset +from cirq.transformers.target_gatesets.cz_gateset import CZTargetGateset as CZTargetGateset -from cirq.transformers.target_gatesets.sqrt_iswap_gateset import SqrtIswapTargetGateset +from cirq.transformers.target_gatesets.sqrt_iswap_gateset import ( + SqrtIswapTargetGateset as SqrtIswapTargetGateset, +) diff --git a/cirq-core/cirq/value/__init__.py b/cirq-core/cirq/value/__init__.py index a810bf108e9..f309a64c243 100644 --- a/cirq-core/cirq/value/__init__.py +++ b/cirq-core/cirq/value/__init__.py @@ -13,55 +13,75 @@ # limitations under the License. """Value conversion utilities and classes for time and quantum states.""" -from cirq.value.abc_alt import ABCMetaImplementAnyOneOf, alternative +from cirq.value.abc_alt import ( + ABCMetaImplementAnyOneOf as ABCMetaImplementAnyOneOf, + alternative as alternative, +) from cirq.value.angle import ( - canonicalize_half_turns, - chosen_angle_to_canonical_half_turns, - chosen_angle_to_half_turns, + canonicalize_half_turns as canonicalize_half_turns, + chosen_angle_to_canonical_half_turns as chosen_angle_to_canonical_half_turns, + chosen_angle_to_half_turns as chosen_angle_to_half_turns, ) from cirq.value.classical_data import ( - ClassicalDataDictionaryStore, - ClassicalDataStore, - ClassicalDataStoreReader, - MeasurementType, + ClassicalDataDictionaryStore as ClassicalDataDictionaryStore, + ClassicalDataStore as ClassicalDataStore, + ClassicalDataStoreReader as ClassicalDataStoreReader, + MeasurementType as MeasurementType, ) -from cirq.value.condition import Condition, KeyCondition, SympyCondition +from cirq.value.condition import ( + Condition as Condition, + KeyCondition as KeyCondition, + SympyCondition as SympyCondition, +) from cirq.value.digits import ( - big_endian_bits_to_int, - big_endian_digits_to_int, - big_endian_int_to_bits, - big_endian_int_to_digits, + big_endian_bits_to_int as big_endian_bits_to_int, + big_endian_digits_to_int as big_endian_digits_to_int, + big_endian_int_to_bits as big_endian_int_to_bits, + big_endian_int_to_digits as big_endian_int_to_digits, ) -from cirq.value.duration import Duration, DURATION_LIKE +from cirq.value.duration import Duration as Duration, DURATION_LIKE as DURATION_LIKE -from cirq.value.linear_dict import LinearDict, Scalar +from cirq.value.linear_dict import LinearDict as LinearDict, Scalar as Scalar -from cirq.value.measurement_key import MEASUREMENT_KEY_SEPARATOR, MeasurementKey +from cirq.value.measurement_key import ( + MEASUREMENT_KEY_SEPARATOR as MEASUREMENT_KEY_SEPARATOR, + MeasurementKey as MeasurementKey, +) -from cirq.value.probability import state_vector_to_probabilities, validate_probability +from cirq.value.probability import ( + state_vector_to_probabilities as state_vector_to_probabilities, + validate_probability as validate_probability, +) from cirq.value.product_state import ( - ProductState, - KET_PLUS, - KET_MINUS, - KET_IMAG, - KET_MINUS_IMAG, - KET_ZERO, - KET_ONE, - PAULI_STATES, + ProductState as ProductState, + KET_PLUS as KET_PLUS, + KET_MINUS as KET_MINUS, + KET_IMAG as KET_IMAG, + KET_MINUS_IMAG as KET_MINUS_IMAG, + KET_ZERO as KET_ZERO, + KET_ONE as KET_ONE, + PAULI_STATES as PAULI_STATES, ) -from cirq.value.periodic_value import PeriodicValue +from cirq.value.periodic_value import PeriodicValue as PeriodicValue -from cirq.value.random_state import parse_random_state, RANDOM_STATE_OR_SEED_LIKE +from cirq.value.random_state import ( + parse_random_state as parse_random_state, + RANDOM_STATE_OR_SEED_LIKE as RANDOM_STATE_OR_SEED_LIKE, +) -from cirq.value.timestamp import Timestamp +from cirq.value.timestamp import Timestamp as Timestamp -from cirq.value.type_alias import TParamKey, TParamVal, TParamValComplex +from cirq.value.type_alias import ( + TParamKey as TParamKey, + TParamVal as TParamVal, + TParamValComplex as TParamValComplex, +) -from cirq.value.value_equality_attr import value_equality +from cirq.value.value_equality_attr import value_equality as value_equality diff --git a/cirq-core/cirq/vis/__init__.py b/cirq-core/cirq/vis/__init__.py index b0cc92ec754..69c47c19cc3 100644 --- a/cirq-core/cirq/vis/__init__.py +++ b/cirq-core/cirq/vis/__init__.py @@ -14,14 +14,17 @@ """Classes and methods for visualizing results, quantum states, and devices.""" -from cirq.vis.heatmap import Heatmap +from cirq.vis.heatmap import Heatmap as Heatmap -from cirq.vis.heatmap import TwoQubitInteractionHeatmap +from cirq.vis.heatmap import TwoQubitInteractionHeatmap as TwoQubitInteractionHeatmap -from cirq.vis.histogram import integrated_histogram +from cirq.vis.histogram import integrated_histogram as integrated_histogram -from cirq.vis.state_histogram import get_state_histogram, plot_state_histogram +from cirq.vis.state_histogram import ( + get_state_histogram as get_state_histogram, + plot_state_histogram as plot_state_histogram, +) -from cirq.vis.density_matrix import plot_density_matrix +from cirq.vis.density_matrix import plot_density_matrix as plot_density_matrix -from cirq.vis.vis_utils import relative_luminance +from cirq.vis.vis_utils import relative_luminance as relative_luminance diff --git a/cirq-core/cirq/work/__init__.py b/cirq-core/cirq/work/__init__.py index 16297299aef..8213d3f756e 100644 --- a/cirq-core/cirq/work/__init__.py +++ b/cirq-core/cirq/work/__init__.py @@ -14,20 +14,26 @@ """Workflow utilities for sampling and measurement collection.""" -from cirq.work.collector import CircuitSampleJob, Collector -from cirq.work.pauli_sum_collector import PauliSumCollector -from cirq.work.observable_settings import InitObsSetting, _MeasurementSpec, observables_to_settings -from cirq.work.observable_grouping import group_settings_greedy +from cirq.work.collector import CircuitSampleJob as CircuitSampleJob, Collector as Collector +from cirq.work.pauli_sum_collector import PauliSumCollector as PauliSumCollector +from cirq.work.observable_settings import ( + InitObsSetting as InitObsSetting, + _MeasurementSpec as _MeasurementSpec, + observables_to_settings as observables_to_settings, +) +from cirq.work.observable_grouping import group_settings_greedy as group_settings_greedy from cirq.work.observable_measurement_data import ( - ObservableMeasuredResult, - BitstringAccumulator, - flatten_grouped_results, + ObservableMeasuredResult as ObservableMeasuredResult, + BitstringAccumulator as BitstringAccumulator, + flatten_grouped_results as flatten_grouped_results, ) from cirq.work.observable_measurement import ( - VarianceStoppingCriteria, - RepetitionsStoppingCriteria, - measure_grouped_settings, + VarianceStoppingCriteria as VarianceStoppingCriteria, + RepetitionsStoppingCriteria as RepetitionsStoppingCriteria, + measure_grouped_settings as measure_grouped_settings, +) +from cirq.work.observable_readout_calibration import ( + calibrate_readout_error as calibrate_readout_error, ) -from cirq.work.observable_readout_calibration import calibrate_readout_error -from cirq.work.sampler import Sampler -from cirq.work.zeros_sampler import ZerosSampler +from cirq.work.sampler import Sampler as Sampler +from cirq.work.zeros_sampler import ZerosSampler as ZerosSampler diff --git a/cirq-google/cirq_google/__init__.py b/cirq-google/cirq_google/__init__.py index 0b9a3f5e128..20458786bc6 100644 --- a/cirq-google/cirq_google/__init__.py +++ b/cirq-google/cirq_google/__init__.py @@ -17,91 +17,91 @@ import sys from cirq_google import api -from cirq_google._version import __version__ +from cirq_google._version import __version__ as __version__ from cirq_google.devices import ( - GoogleNoiseProperties, - GridDevice, - NoiseModelFromGoogleNoiseProperties, - Sycamore, - Sycamore23, + GoogleNoiseProperties as GoogleNoiseProperties, + GridDevice as GridDevice, + NoiseModelFromGoogleNoiseProperties as NoiseModelFromGoogleNoiseProperties, + Sycamore as Sycamore, + Sycamore23 as Sycamore23, ) from cirq_google.engine import ( - Calibration, - CalibrationLayer, - CalibrationResult, - Engine, - EngineJob, - EngineProgram, - EngineProcessor, - EngineResult, - ProtoVersion, - ProcessorSampler, - ValidatingSampler, - get_engine, - get_engine_calibration, - get_engine_device, - get_engine_sampler, - noise_properties_from_calibration, + Calibration as Calibration, + CalibrationLayer as CalibrationLayer, + CalibrationResult as CalibrationResult, + Engine as Engine, + EngineJob as EngineJob, + EngineProgram as EngineProgram, + EngineProcessor as EngineProcessor, + EngineResult as EngineResult, + ProtoVersion as ProtoVersion, + ProcessorSampler as ProcessorSampler, + ValidatingSampler as ValidatingSampler, + get_engine as get_engine, + get_engine_calibration as get_engine_calibration, + get_engine_device as get_engine_device, + get_engine_sampler as get_engine_sampler, + noise_properties_from_calibration as noise_properties_from_calibration, ) from cirq_google.line import ( - AnnealSequenceSearchStrategy, - GreedySequenceSearchStrategy, - line_on_device, - LinePlacementStrategy, + AnnealSequenceSearchStrategy as AnnealSequenceSearchStrategy, + GreedySequenceSearchStrategy as GreedySequenceSearchStrategy, + line_on_device as line_on_device, + LinePlacementStrategy as LinePlacementStrategy, ) from cirq_google.ops import ( - CalibrationTag, - Coupler, - FSimGateFamily, - FSimViaModelTag, - InternalGate, - PhysicalZTag, - SYC, - SycamoreGate, + CalibrationTag as CalibrationTag, + Coupler as Coupler, + FSimGateFamily as FSimGateFamily, + FSimViaModelTag as FSimViaModelTag, + InternalGate as InternalGate, + PhysicalZTag as PhysicalZTag, + SYC as SYC, + SycamoreGate as SycamoreGate, ) from cirq_google.transformers import ( - known_2q_op_to_sycamore_operations, - two_qubit_matrix_to_sycamore_operations, - GoogleCZTargetGateset, - SycamoreTargetGateset, + known_2q_op_to_sycamore_operations as known_2q_op_to_sycamore_operations, + two_qubit_matrix_to_sycamore_operations as two_qubit_matrix_to_sycamore_operations, + GoogleCZTargetGateset as GoogleCZTargetGateset, + SycamoreTargetGateset as SycamoreTargetGateset, ) from cirq_google.serialization import ( - arg_from_proto, - CIRCUIT_SERIALIZER, - CircuitSerializer, - CircuitOpDeserializer, - CircuitOpSerializer, - Serializer, + arg_from_proto as arg_from_proto, + CIRCUIT_SERIALIZER as CIRCUIT_SERIALIZER, + CircuitSerializer as CircuitSerializer, + CircuitOpDeserializer as CircuitOpDeserializer, + CircuitOpSerializer as CircuitOpSerializer, + Serializer as Serializer, ) from cirq_google.workflow import ( - ExecutableSpec, - KeyValueExecutableSpec, - QuantumExecutable, - QuantumExecutableGroup, - BitstringsMeasurement, - SharedRuntimeInfo, - RuntimeInfo, - ExecutableResult, - ExecutableGroupResult, - ExecutableGroupResultFilesystemRecord, - QuantumRuntimeConfiguration, - execute, - QubitPlacer, - CouldNotPlaceError, - NaiveQubitPlacer, - RandomDevicePlacer, - HardcodedQubitPlacer, - ProcessorRecord, - EngineProcessorRecord, - SimulatedProcessorRecord, - SimulatedProcessorWithLocalDeviceRecord, + ExecutableSpec as ExecutableSpec, + KeyValueExecutableSpec as KeyValueExecutableSpec, + QuantumExecutable as QuantumExecutable, + QuantumExecutableGroup as QuantumExecutableGroup, + BitstringsMeasurement as BitstringsMeasurement, + SharedRuntimeInfo as SharedRuntimeInfo, + RuntimeInfo as RuntimeInfo, + ExecutableResult as ExecutableResult, + ExecutableGroupResult as ExecutableGroupResult, + ExecutableGroupResultFilesystemRecord as ExecutableGroupResultFilesystemRecord, + QuantumRuntimeConfiguration as QuantumRuntimeConfiguration, + execute as execute, + QubitPlacer as QubitPlacer, + CouldNotPlaceError as CouldNotPlaceError, + NaiveQubitPlacer as NaiveQubitPlacer, + RandomDevicePlacer as RandomDevicePlacer, + HardcodedQubitPlacer as HardcodedQubitPlacer, + ProcessorRecord as ProcessorRecord, + EngineProcessorRecord as EngineProcessorRecord, + SimulatedProcessorRecord as SimulatedProcessorRecord, + SimulatedProcessorWithLocalDeviceRecord as SimulatedProcessorWithLocalDeviceRecord, ) from cirq_google import study diff --git a/cirq-google/cirq_google/api/v1/__init__.py b/cirq-google/cirq_google/api/v1/__init__.py index 454cc3bcd7f..fff44299c25 100644 --- a/cirq-google/cirq_google/api/v1/__init__.py +++ b/cirq-google/cirq_google/api/v1/__init__.py @@ -15,15 +15,18 @@ from cirq_google.api.v1 import operations_pb2, params_pb2, program_pb2 -from cirq_google.api.v1.params import sweep_from_proto, sweep_to_proto +from cirq_google.api.v1.params import ( + sweep_from_proto as sweep_from_proto, + sweep_to_proto as sweep_to_proto, +) from cirq_google.api.v1.programs import ( - gate_to_proto, - is_native_xmon_gate, - is_native_xmon_op, - pack_results, - circuit_as_schedule_to_protos, - circuit_from_schedule_from_protos, - unpack_results, - xmon_op_from_proto, + gate_to_proto as gate_to_proto, + is_native_xmon_gate as is_native_xmon_gate, + is_native_xmon_op as is_native_xmon_op, + pack_results as pack_results, + circuit_as_schedule_to_protos as circuit_as_schedule_to_protos, + circuit_from_schedule_from_protos as circuit_from_schedule_from_protos, + unpack_results as unpack_results, + xmon_op_from_proto as xmon_op_from_proto, ) diff --git a/cirq-google/cirq_google/api/v2/__init__.py b/cirq-google/cirq_google/api/v2/__init__.py index cd601d52764..ca1009bb46c 100644 --- a/cirq-google/cirq_google/api/v2/__init__.py +++ b/cirq-google/cirq_google/api/v2/__init__.py @@ -16,20 +16,24 @@ from cirq_google.api.v2 import device_pb2, metrics_pb2, program_pb2, result_pb2, run_context_pb2 from cirq_google.api.v2.program import ( - grid_qubit_from_proto_id, - line_qubit_from_proto_id, - named_qubit_from_proto_id, - qubit_from_proto_id, - qubit_to_proto_id, + grid_qubit_from_proto_id as grid_qubit_from_proto_id, + line_qubit_from_proto_id as line_qubit_from_proto_id, + named_qubit_from_proto_id as named_qubit_from_proto_id, + qubit_from_proto_id as qubit_from_proto_id, + qubit_to_proto_id as qubit_to_proto_id, ) from cirq_google.api.v2.results import ( - MeasureInfo, - find_measurements, - pack_bits, - unpack_bits, - results_from_proto, - results_to_proto, + MeasureInfo as MeasureInfo, + find_measurements as find_measurements, + pack_bits as pack_bits, + unpack_bits as unpack_bits, + results_from_proto as results_from_proto, + results_to_proto as results_to_proto, ) -from cirq_google.api.v2.sweeps import run_context_to_proto, sweep_from_proto, sweep_to_proto +from cirq_google.api.v2.sweeps import ( + run_context_to_proto as run_context_to_proto, + sweep_from_proto as sweep_from_proto, + sweep_to_proto as sweep_to_proto, +) diff --git a/cirq-google/cirq_google/devices/__init__.py b/cirq-google/cirq_google/devices/__init__.py index dfc2d598444..540b8b3b7e3 100644 --- a/cirq-google/cirq_google/devices/__init__.py +++ b/cirq-google/cirq_google/devices/__init__.py @@ -15,10 +15,10 @@ """Devices and Noise models for publicly known Google devices.""" from cirq_google.devices.google_noise_properties import ( - GoogleNoiseProperties, - NoiseModelFromGoogleNoiseProperties, + GoogleNoiseProperties as GoogleNoiseProperties, + NoiseModelFromGoogleNoiseProperties as NoiseModelFromGoogleNoiseProperties, ) -from cirq_google.devices.known_devices import Sycamore, Sycamore23 +from cirq_google.devices.known_devices import Sycamore as Sycamore, Sycamore23 as Sycamore23 -from cirq_google.devices.grid_device import GridDevice +from cirq_google.devices.grid_device import GridDevice as GridDevice diff --git a/cirq-google/cirq_google/engine/__init__.py b/cirq-google/cirq_google/engine/__init__.py index c2f9361497c..1cb42453285 100644 --- a/cirq-google/cirq_google/engine/__init__.py +++ b/cirq-google/cirq_google/engine/__init__.py @@ -15,71 +15,83 @@ """Client for running on Google's Quantum Engine. """ -from cirq_google.engine.abstract_engine import AbstractEngine +from cirq_google.engine.abstract_engine import AbstractEngine as AbstractEngine -from cirq_google.engine.abstract_job import AbstractJob +from cirq_google.engine.abstract_job import AbstractJob as AbstractJob -from cirq_google.engine.abstract_processor import AbstractProcessor +from cirq_google.engine.abstract_processor import AbstractProcessor as AbstractProcessor -from cirq_google.engine.abstract_program import AbstractProgram +from cirq_google.engine.abstract_program import AbstractProgram as AbstractProgram -from cirq_google.engine.abstract_local_engine import AbstractLocalEngine +from cirq_google.engine.abstract_local_engine import AbstractLocalEngine as AbstractLocalEngine -from cirq_google.engine.abstract_local_job import AbstractLocalJob +from cirq_google.engine.abstract_local_job import AbstractLocalJob as AbstractLocalJob -from cirq_google.engine.abstract_local_processor import AbstractLocalProcessor +from cirq_google.engine.abstract_local_processor import ( + AbstractLocalProcessor as AbstractLocalProcessor, +) + +from cirq_google.engine.abstract_local_program import AbstractLocalProgram as AbstractLocalProgram -from cirq_google.engine.abstract_local_program import AbstractLocalProgram +from cirq_google.engine.simulated_local_engine import SimulatedLocalEngine as SimulatedLocalEngine -from cirq_google.engine.simulated_local_engine import SimulatedLocalEngine +from cirq_google.engine.simulated_local_job import SimulatedLocalJob as SimulatedLocalJob -from cirq_google.engine.simulated_local_job import SimulatedLocalJob +from cirq_google.engine.simulated_local_processor import ( + SimulatedLocalProcessor as SimulatedLocalProcessor, +) -from cirq_google.engine.simulated_local_processor import SimulatedLocalProcessor +from cirq_google.engine.simulated_local_program import ( + SimulatedLocalProgram as SimulatedLocalProgram, +) -from cirq_google.engine.simulated_local_program import SimulatedLocalProgram -from cirq_google.engine.calibration import Calibration +from cirq_google.engine.calibration import Calibration as Calibration -from cirq_google.engine.calibration_layer import CalibrationLayer -from cirq_google.engine.calibration_result import CalibrationResult -from cirq_google.engine.calibration_to_noise_properties import noise_properties_from_calibration +from cirq_google.engine.calibration_layer import CalibrationLayer as CalibrationLayer + +from cirq_google.engine.calibration_result import CalibrationResult as CalibrationResult + +from cirq_google.engine.calibration_to_noise_properties import ( + noise_properties_from_calibration as noise_properties_from_calibration, +) from cirq_google.engine.engine import ( - Engine, - get_engine, - get_engine_calibration, - get_engine_device, - get_engine_sampler, - ProtoVersion, + Engine as Engine, + get_engine as get_engine, + get_engine_calibration as get_engine_calibration, + get_engine_device as get_engine_device, + get_engine_sampler as get_engine_sampler, + ProtoVersion as ProtoVersion, ) -from cirq_google.engine.engine_client import EngineException +from cirq_google.engine.engine_client import EngineException as EngineException -from cirq_google.engine.engine_job import EngineJob +from cirq_google.engine.engine_job import EngineJob as EngineJob -from cirq_google.engine.engine_processor import EngineProcessor +from cirq_google.engine.engine_processor import EngineProcessor as EngineProcessor -from cirq_google.engine.engine_program import EngineProgram +from cirq_google.engine.engine_program import EngineProgram as EngineProgram from cirq_google.engine.runtime_estimator import ( - estimate_run_time, - estimate_run_batch_time, - estimate_run_sweep_time, + estimate_run_time as estimate_run_time, + estimate_run_batch_time as estimate_run_batch_time, + estimate_run_sweep_time as estimate_run_sweep_time, ) -from cirq_google.engine.validating_sampler import ValidatingSampler +from cirq_google.engine.validating_sampler import ValidatingSampler as ValidatingSampler from cirq_google.engine.virtual_engine_factory import ( - create_default_noisy_quantum_virtual_machine, - create_device_from_processor_id, - create_noiseless_virtual_engine_from_device, - create_noiseless_virtual_engine_from_proto, - create_noiseless_virtual_engine_from_templates, - create_noiseless_virtual_engine_from_latest_templates, - load_median_device_calibration, - load_sample_device_zphase, + # pylint: disable=line-too-long + create_default_noisy_quantum_virtual_machine as create_default_noisy_quantum_virtual_machine, + create_device_from_processor_id as create_device_from_processor_id, + create_noiseless_virtual_engine_from_device as create_noiseless_virtual_engine_from_device, + create_noiseless_virtual_engine_from_proto as create_noiseless_virtual_engine_from_proto, + create_noiseless_virtual_engine_from_templates as create_noiseless_virtual_engine_from_templates, + create_noiseless_virtual_engine_from_latest_templates as create_noiseless_virtual_engine_from_latest_templates, + load_median_device_calibration as load_median_device_calibration, + load_sample_device_zphase as load_sample_device_zphase, ) -from cirq_google.engine.engine_result import EngineResult +from cirq_google.engine.engine_result import EngineResult as EngineResult -from cirq_google.engine.processor_sampler import ProcessorSampler +from cirq_google.engine.processor_sampler import ProcessorSampler as ProcessorSampler diff --git a/cirq-google/cirq_google/experimental/__init__.py b/cirq-google/cirq_google/experimental/__init__.py index 9822028eaee..f39728a3c9f 100644 --- a/cirq-google/cirq_google/experimental/__init__.py +++ b/cirq-google/cirq_google/experimental/__init__.py @@ -15,8 +15,9 @@ """Experimental features. Their API can be broken without any warning and might be in a work-in progress state""" from cirq_google.experimental.noise_models import ( - PerQubitDepolarizingWithDampedReadoutNoiseModel, - simple_noise_from_calibration_metrics, + # pylint: disable=line-too-long + PerQubitDepolarizingWithDampedReadoutNoiseModel as PerQubitDepolarizingWithDampedReadoutNoiseModel, + simple_noise_from_calibration_metrics as simple_noise_from_calibration_metrics, ) -from cirq_google.experimental.ops import CouplerPulse +from cirq_google.experimental.ops import CouplerPulse as CouplerPulse diff --git a/cirq-google/cirq_google/experimental/noise_models/__init__.py b/cirq-google/cirq_google/experimental/noise_models/__init__.py index 09ac113164a..a1f9ceb661c 100644 --- a/cirq-google/cirq_google/experimental/noise_models/__init__.py +++ b/cirq-google/cirq_google/experimental/noise_models/__init__.py @@ -15,6 +15,7 @@ """Noise models for Google devices.""" from cirq_google.experimental.noise_models.noise_models import ( - PerQubitDepolarizingWithDampedReadoutNoiseModel, - simple_noise_from_calibration_metrics, + # pylint: disable=line-too-long + PerQubitDepolarizingWithDampedReadoutNoiseModel as PerQubitDepolarizingWithDampedReadoutNoiseModel, + simple_noise_from_calibration_metrics as simple_noise_from_calibration_metrics, ) diff --git a/cirq-google/cirq_google/experimental/ops/__init__.py b/cirq-google/cirq_google/experimental/ops/__init__.py index d8c33714bff..3f9e4f59558 100644 --- a/cirq-google/cirq_google/experimental/ops/__init__.py +++ b/cirq-google/cirq_google/experimental/ops/__init__.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cirq_google.experimental.ops.coupler_pulse import CouplerPulse +from cirq_google.experimental.ops.coupler_pulse import CouplerPulse as CouplerPulse diff --git a/cirq-google/cirq_google/json_test_data/__init__.py b/cirq-google/cirq_google/json_test_data/__init__.py index fb4dddbac3d..483aa3c6bef 100644 --- a/cirq-google/cirq_google/json_test_data/__init__.py +++ b/cirq-google/cirq_google/json_test_data/__init__.py @@ -17,4 +17,4 @@ # cirq/protocols/json_serialization_test.py which checks for coverage of # public classes and tests the correctness of repr and json results -from cirq_google.json_test_data.spec import TestSpec +from cirq_google.json_test_data.spec import TestSpec as TestSpec diff --git a/cirq-google/cirq_google/line/__init__.py b/cirq-google/cirq_google/line/__init__.py index 5bf23682be3..ff35bac10f0 100644 --- a/cirq-google/cirq_google/line/__init__.py +++ b/cirq-google/cirq_google/line/__init__.py @@ -15,8 +15,8 @@ """Utilities for picking out a line of GridQubits from a device.""" from cirq_google.line.placement import ( - AnnealSequenceSearchStrategy, - GreedySequenceSearchStrategy, - line_on_device, - LinePlacementStrategy, + AnnealSequenceSearchStrategy as AnnealSequenceSearchStrategy, + GreedySequenceSearchStrategy as GreedySequenceSearchStrategy, + line_on_device as line_on_device, + LinePlacementStrategy as LinePlacementStrategy, ) diff --git a/cirq-google/cirq_google/line/placement/__init__.py b/cirq-google/cirq_google/line/placement/__init__.py index a8b6ef14e70..534a9ab985b 100644 --- a/cirq-google/cirq_google/line/placement/__init__.py +++ b/cirq-google/cirq_google/line/placement/__init__.py @@ -12,14 +12,18 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cirq_google.line.placement.anneal import AnnealSequenceSearchStrategy +from cirq_google.line.placement.anneal import ( + AnnealSequenceSearchStrategy as AnnealSequenceSearchStrategy, +) -from cirq_google.line.placement.greedy import GreedySequenceSearchStrategy +from cirq_google.line.placement.greedy import ( + GreedySequenceSearchStrategy as GreedySequenceSearchStrategy, +) -from cirq_google.line.placement.place_strategy import LinePlacementStrategy +from cirq_google.line.placement.place_strategy import LinePlacementStrategy as LinePlacementStrategy -from cirq_google.line.placement.sequence import GridQubitLineTuple +from cirq_google.line.placement.sequence import GridQubitLineTuple as GridQubitLineTuple -from cirq_google.line.placement.line import line_on_device +from cirq_google.line.placement.line import line_on_device as line_on_device -from cirq_google.line.placement.optimization import anneal_minimize +from cirq_google.line.placement.optimization import anneal_minimize as anneal_minimize diff --git a/cirq-google/cirq_google/ops/__init__.py b/cirq-google/cirq_google/ops/__init__.py index 9cc623675ba..40cbd340346 100644 --- a/cirq-google/cirq_google/ops/__init__.py +++ b/cirq-google/cirq_google/ops/__init__.py @@ -14,16 +14,16 @@ """Qubit Gates, Operations, and Tags useful for Google devices. """ -from cirq_google.ops.calibration_tag import CalibrationTag +from cirq_google.ops.calibration_tag import CalibrationTag as CalibrationTag -from cirq_google.ops.coupler import Coupler +from cirq_google.ops.coupler import Coupler as Coupler -from cirq_google.ops.fsim_gate_family import FSimGateFamily +from cirq_google.ops.fsim_gate_family import FSimGateFamily as FSimGateFamily -from cirq_google.ops.fsim_via_model_tag import FSimViaModelTag +from cirq_google.ops.fsim_via_model_tag import FSimViaModelTag as FSimViaModelTag -from cirq_google.ops.physical_z_tag import PhysicalZTag +from cirq_google.ops.physical_z_tag import PhysicalZTag as PhysicalZTag -from cirq_google.ops.sycamore_gate import SycamoreGate, SYC +from cirq_google.ops.sycamore_gate import SycamoreGate as SycamoreGate, SYC as SYC -from cirq_google.ops.internal_gate import InternalGate +from cirq_google.ops.internal_gate import InternalGate as InternalGate diff --git a/cirq-google/cirq_google/serialization/__init__.py b/cirq-google/cirq_google/serialization/__init__.py index 12f5eeec0df..865dce20f1c 100644 --- a/cirq-google/cirq_google/serialization/__init__.py +++ b/cirq-google/cirq_google/serialization/__init__.py @@ -14,12 +14,15 @@ """Classes for serializing circuits into protocol buffers.""" -from cirq_google.serialization.arg_func_langs import arg_from_proto +from cirq_google.serialization.arg_func_langs import arg_from_proto as arg_from_proto -from cirq_google.serialization.circuit_serializer import CircuitSerializer, CIRCUIT_SERIALIZER +from cirq_google.serialization.circuit_serializer import ( + CircuitSerializer as CircuitSerializer, + CIRCUIT_SERIALIZER as CIRCUIT_SERIALIZER, +) -from cirq_google.serialization.op_deserializer import CircuitOpDeserializer +from cirq_google.serialization.op_deserializer import CircuitOpDeserializer as CircuitOpDeserializer -from cirq_google.serialization.op_serializer import CircuitOpSerializer +from cirq_google.serialization.op_serializer import CircuitOpSerializer as CircuitOpSerializer -from cirq_google.serialization.serializer import Serializer +from cirq_google.serialization.serializer import Serializer as Serializer diff --git a/cirq-google/cirq_google/study/__init__.py b/cirq-google/cirq_google/study/__init__.py index ffe28aa8587..7a16348af64 100644 --- a/cirq-google/cirq_google/study/__init__.py +++ b/cirq-google/cirq_google/study/__init__.py @@ -14,4 +14,4 @@ """Classes for running sweeps particular to Google hardware.""" -from cirq_google.study.device_parameter import DeviceParameter +from cirq_google.study.device_parameter import DeviceParameter as DeviceParameter diff --git a/cirq-google/cirq_google/transformers/__init__.py b/cirq-google/cirq_google/transformers/__init__.py index 89b1019eea6..4b71fcc7dfc 100644 --- a/cirq-google/cirq_google/transformers/__init__.py +++ b/cirq-google/cirq_google/transformers/__init__.py @@ -15,10 +15,13 @@ """Transformers for compiling to Google-specific gates, such as Sycamore.""" from cirq_google.transformers.analytical_decompositions import ( - known_2q_op_to_sycamore_operations, - two_qubit_matrix_to_sycamore_operations, + known_2q_op_to_sycamore_operations as known_2q_op_to_sycamore_operations, + two_qubit_matrix_to_sycamore_operations as two_qubit_matrix_to_sycamore_operations, ) -from cirq_google.transformers.target_gatesets import GoogleCZTargetGateset, SycamoreTargetGateset +from cirq_google.transformers.target_gatesets import ( + GoogleCZTargetGateset as GoogleCZTargetGateset, + SycamoreTargetGateset as SycamoreTargetGateset, +) -from cirq_google.transformers.sycamore_gauge import SYCGaugeTransformer +from cirq_google.transformers.sycamore_gauge import SYCGaugeTransformer as SYCGaugeTransformer diff --git a/cirq-google/cirq_google/transformers/analytical_decompositions/__init__.py b/cirq-google/cirq_google/transformers/analytical_decompositions/__init__.py index 2ce8047eeeb..bafb4d87ab2 100644 --- a/cirq-google/cirq_google/transformers/analytical_decompositions/__init__.py +++ b/cirq-google/cirq_google/transformers/analytical_decompositions/__init__.py @@ -13,6 +13,6 @@ # limitations under the License. from cirq_google.transformers.analytical_decompositions.two_qubit_to_sycamore import ( - known_2q_op_to_sycamore_operations, - two_qubit_matrix_to_sycamore_operations, + known_2q_op_to_sycamore_operations as known_2q_op_to_sycamore_operations, + two_qubit_matrix_to_sycamore_operations as two_qubit_matrix_to_sycamore_operations, ) diff --git a/cirq-google/cirq_google/transformers/target_gatesets/__init__.py b/cirq-google/cirq_google/transformers/target_gatesets/__init__.py index be82a9c9c7a..0a80e025a09 100644 --- a/cirq-google/cirq_google/transformers/target_gatesets/__init__.py +++ b/cirq-google/cirq_google/transformers/target_gatesets/__init__.py @@ -14,6 +14,10 @@ """`cirq.CompilationTargetGateset` implementations for cirq_google gatesets and devices.""" -from cirq_google.transformers.target_gatesets.google_cz_gateset import GoogleCZTargetGateset +from cirq_google.transformers.target_gatesets.google_cz_gateset import ( + GoogleCZTargetGateset as GoogleCZTargetGateset, +) -from cirq_google.transformers.target_gatesets.sycamore_gateset import SycamoreTargetGateset +from cirq_google.transformers.target_gatesets.sycamore_gateset import ( + SycamoreTargetGateset as SycamoreTargetGateset, +) diff --git a/cirq-google/cirq_google/workflow/__init__.py b/cirq-google/cirq_google/workflow/__init__.py index c360fd9b8f1..499817eff7c 100644 --- a/cirq-google/cirq_google/workflow/__init__.py +++ b/cirq-google/cirq_google/workflow/__init__.py @@ -15,35 +15,37 @@ """Utilities for running end-to-end experiments using Quantum Computing Service (QCS). """ from cirq_google.workflow.quantum_executable import ( - ExecutableSpec, - KeyValueExecutableSpec, - QuantumExecutable, - QuantumExecutableGroup, - BitstringsMeasurement, + ExecutableSpec as ExecutableSpec, + KeyValueExecutableSpec as KeyValueExecutableSpec, + QuantumExecutable as QuantumExecutable, + QuantumExecutableGroup as QuantumExecutableGroup, + BitstringsMeasurement as BitstringsMeasurement, ) from cirq_google.workflow.quantum_runtime import ( - SharedRuntimeInfo, - RuntimeInfo, - ExecutableResult, - ExecutableGroupResult, - QuantumRuntimeConfiguration, - execute, + SharedRuntimeInfo as SharedRuntimeInfo, + RuntimeInfo as RuntimeInfo, + ExecutableResult as ExecutableResult, + ExecutableGroupResult as ExecutableGroupResult, + QuantumRuntimeConfiguration as QuantumRuntimeConfiguration, + execute as execute, ) -from cirq_google.workflow.io import ExecutableGroupResultFilesystemRecord +from cirq_google.workflow.io import ( + ExecutableGroupResultFilesystemRecord as ExecutableGroupResultFilesystemRecord, +) from cirq_google.workflow.qubit_placement import ( - QubitPlacer, - CouldNotPlaceError, - NaiveQubitPlacer, - RandomDevicePlacer, - HardcodedQubitPlacer, + QubitPlacer as QubitPlacer, + CouldNotPlaceError as CouldNotPlaceError, + NaiveQubitPlacer as NaiveQubitPlacer, + RandomDevicePlacer as RandomDevicePlacer, + HardcodedQubitPlacer as HardcodedQubitPlacer, ) from cirq_google.workflow.processor_record import ( - ProcessorRecord, - EngineProcessorRecord, - SimulatedProcessorRecord, - SimulatedProcessorWithLocalDeviceRecord, + ProcessorRecord as ProcessorRecord, + EngineProcessorRecord as EngineProcessorRecord, + SimulatedProcessorRecord as SimulatedProcessorRecord, + SimulatedProcessorWithLocalDeviceRecord as SimulatedProcessorWithLocalDeviceRecord, ) diff --git a/cirq-ionq/cirq_ionq/__init__.py b/cirq-ionq/cirq_ionq/__init__.py index fce52d9c9a9..2a115190790 100644 --- a/cirq-ionq/cirq_ionq/__init__.py +++ b/cirq-ionq/cirq_ionq/__init__.py @@ -12,31 +12,34 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cirq_ionq._version import __version__ +from cirq_ionq._version import __version__ as __version__ -from cirq_ionq.calibration import Calibration +from cirq_ionq.calibration import Calibration as Calibration -from cirq_ionq.ionq_devices import IonQAPIDevice +from cirq_ionq.ionq_devices import IonQAPIDevice as IonQAPIDevice -from cirq_ionq.ionq_gateset import IonQTargetGateset, decompose_all_to_all_connect_ccz_gate +from cirq_ionq.ionq_gateset import ( + IonQTargetGateset as IonQTargetGateset, + decompose_all_to_all_connect_ccz_gate as decompose_all_to_all_connect_ccz_gate, +) from cirq_ionq.ionq_exceptions import ( - IonQException, - IonQNotFoundException, - IonQUnsuccessfulJobException, + IonQException as IonQException, + IonQNotFoundException as IonQNotFoundException, + IonQUnsuccessfulJobException as IonQUnsuccessfulJobException, ) -from cirq_ionq.job import Job +from cirq_ionq.job import Job as Job -from cirq_ionq.results import QPUResult, SimulatorResult +from cirq_ionq.results import QPUResult as QPUResult, SimulatorResult as SimulatorResult -from cirq_ionq.sampler import Sampler +from cirq_ionq.sampler import Sampler as Sampler -from cirq_ionq.serializer import Serializer, SerializedProgram +from cirq_ionq.serializer import Serializer as Serializer, SerializedProgram as SerializedProgram -from cirq_ionq.service import Service +from cirq_ionq.service import Service as Service -from cirq_ionq.ionq_native_gates import GPIGate, GPI2Gate, MSGate +from cirq_ionq.ionq_native_gates import GPIGate as GPIGate, GPI2Gate as GPI2Gate, MSGate as MSGate from cirq.protocols.json_serialization import _register_resolver from cirq_ionq.json_resolver_cache import _class_resolver_dictionary diff --git a/cirq-ionq/cirq_ionq/json_test_data/__init__.py b/cirq-ionq/cirq_ionq/json_test_data/__init__.py index 809fe4f1ca4..09ec57ae972 100644 --- a/cirq-ionq/cirq_ionq/json_test_data/__init__.py +++ b/cirq-ionq/cirq_ionq/json_test_data/__init__.py @@ -17,4 +17,4 @@ # cirq/protocols/json_serialization_test.py which checks for coverage of # public classes and tests the correctness of repr and json results -from cirq_ionq.json_test_data.spec import TestSpec +from cirq_ionq.json_test_data.spec import TestSpec as TestSpec diff --git a/cirq-ionq/cirq_ionq/serializer.py b/cirq-ionq/cirq_ionq/serializer.py index 2ab3a20a71f..0902b9f1cf4 100644 --- a/cirq-ionq/cirq_ionq/serializer.py +++ b/cirq-ionq/cirq_ionq/serializer.py @@ -20,7 +20,6 @@ import cirq from cirq.devices import line_qubit -from cirq.ops import common_gates, parity_gates from cirq_ionq.ionq_native_gates import GPIGate, GPI2Gate, MSGate _NATIVE_GATES = cirq.Gateset( @@ -62,16 +61,16 @@ def __init__(self, atol: float = 1e-8): """ self.atol = atol self._dispatch: Dict[Type['cirq.Gate'], Callable] = { - common_gates.XPowGate: self._serialize_x_pow_gate, - common_gates.YPowGate: self._serialize_y_pow_gate, - common_gates.ZPowGate: self._serialize_z_pow_gate, - parity_gates.XXPowGate: self._serialize_xx_pow_gate, - parity_gates.YYPowGate: self._serialize_yy_pow_gate, - parity_gates.ZZPowGate: self._serialize_zz_pow_gate, - common_gates.CNotPowGate: self._serialize_cnot_pow_gate, - common_gates.HPowGate: self._serialize_h_pow_gate, - common_gates.SwapPowGate: self._serialize_swap_gate, - common_gates.MeasurementGate: self._serialize_measurement_gate, + cirq.XPowGate: self._serialize_x_pow_gate, + cirq.YPowGate: self._serialize_y_pow_gate, + cirq.ZPowGate: self._serialize_z_pow_gate, + cirq.XXPowGate: self._serialize_xx_pow_gate, + cirq.YYPowGate: self._serialize_yy_pow_gate, + cirq.ZZPowGate: self._serialize_zz_pow_gate, + cirq.CNotPowGate: self._serialize_cnot_pow_gate, + cirq.HPowGate: self._serialize_h_pow_gate, + cirq.SwapPowGate: self._serialize_swap_gate, + cirq.MeasurementGate: self._serialize_measurement_gate, # These gates can't be used with any of the non-measurement gates above # Rather than validating this here, we rely on the IonQ API to report failure. GPIGate: self._serialize_gpi_gate, diff --git a/cirq-pasqal/cirq_pasqal/__init__.py b/cirq-pasqal/cirq_pasqal/__init__.py index 860915296df..c341c9e7050 100644 --- a/cirq-pasqal/cirq_pasqal/__init__.py +++ b/cirq-pasqal/cirq_pasqal/__init__.py @@ -14,18 +14,20 @@ """Devices, qubits, and sampler for Pasqal's neutral atom device.""" -from cirq_pasqal._version import __version__ +from cirq_pasqal._version import __version__ as __version__ -from cirq_pasqal.pasqal_qubits import ThreeDQubit, TwoDQubit +from cirq_pasqal.pasqal_qubits import ThreeDQubit as ThreeDQubit, TwoDQubit as TwoDQubit -from cirq_pasqal.pasqal_gateset import PasqalGateset +from cirq_pasqal.pasqal_gateset import PasqalGateset as PasqalGateset -from cirq_pasqal.pasqal_device import PasqalDevice, PasqalVirtualDevice +from cirq_pasqal.pasqal_device import ( + PasqalDevice as PasqalDevice, + PasqalVirtualDevice as PasqalVirtualDevice, +) -from cirq_pasqal.pasqal_noise_model import PasqalNoiseModel - -from cirq_pasqal.pasqal_sampler import PasqalSampler +from cirq_pasqal.pasqal_noise_model import PasqalNoiseModel as PasqalNoiseModel +from cirq_pasqal.pasqal_sampler import PasqalSampler as PasqalSampler # Register cirq_pasqal's public classes for JSON serialization. from cirq.protocols.json_serialization import _register_resolver diff --git a/cirq-pasqal/cirq_pasqal/json_test_data/__init__.py b/cirq-pasqal/cirq_pasqal/json_test_data/__init__.py index 1377c9b5bbf..3d616496d41 100644 --- a/cirq-pasqal/cirq_pasqal/json_test_data/__init__.py +++ b/cirq-pasqal/cirq_pasqal/json_test_data/__init__.py @@ -17,4 +17,4 @@ # cirq/protocols/json_serialization_test.py which checks for coverage of # public classes and tests the correctness of repr and json results -from cirq_pasqal.json_test_data.spec import TestSpec +from cirq_pasqal.json_test_data.spec import TestSpec as TestSpec diff --git a/cirq-rigetti/cirq_rigetti/__init__.py b/cirq-rigetti/cirq_rigetti/__init__.py index a37325381a1..e9d6efc5c84 100644 --- a/cirq-rigetti/cirq_rigetti/__init__.py +++ b/cirq-rigetti/cirq_rigetti/__init__.py @@ -12,21 +12,30 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cirq_rigetti._version import __version__ -from cirq_rigetti.sampler import RigettiQCSSampler, get_rigetti_qcs_sampler -from cirq_rigetti.service import RigettiQCSService, get_rigetti_qcs_service +from cirq_rigetti._version import __version__ as __version__ + +from cirq_rigetti.sampler import ( + RigettiQCSSampler as RigettiQCSSampler, + get_rigetti_qcs_sampler as get_rigetti_qcs_sampler, +) + +from cirq_rigetti.service import ( + RigettiQCSService as RigettiQCSService, + get_rigetti_qcs_service as get_rigetti_qcs_service, +) + from cirq_rigetti import circuit_sweep_executors, quil_output from cirq_rigetti import circuit_transformers from cirq_rigetti.aspen_device import ( - RigettiQCSAspenDevice, - AspenQubit, - OctagonalQubit, - UnsupportedQubit, - UnsupportedRigettiQCSOperation, - UnsupportedRigettiQCSQuantumProcessor, + RigettiQCSAspenDevice as RigettiQCSAspenDevice, + AspenQubit as AspenQubit, + OctagonalQubit as OctagonalQubit, + UnsupportedQubit as UnsupportedQubit, + UnsupportedRigettiQCSOperation as UnsupportedRigettiQCSOperation, + UnsupportedRigettiQCSQuantumProcessor as UnsupportedRigettiQCSQuantumProcessor, ) -from cirq_rigetti.quil_input import circuit_from_quil +from cirq_rigetti.quil_input import circuit_from_quil as circuit_from_quil # Registers the cirq_rigetti's public classes for JSON serialization. from cirq.protocols.json_serialization import _register_resolver diff --git a/cirq-rigetti/cirq_rigetti/json_test_data/__init__.py b/cirq-rigetti/cirq_rigetti/json_test_data/__init__.py index ed3194671fd..beed6e4348b 100644 --- a/cirq-rigetti/cirq_rigetti/json_test_data/__init__.py +++ b/cirq-rigetti/cirq_rigetti/json_test_data/__init__.py @@ -17,4 +17,4 @@ # cirq/protocols/json_serialization_test.py which checks for coverage of # public classes and tests the correctness of repr and json results -from cirq_rigetti.json_test_data.spec import TestSpec +from cirq_rigetti.json_test_data.spec import TestSpec as TestSpec diff --git a/cirq-web/cirq_web/__init__.py b/cirq-web/cirq_web/__init__.py index 27f44d52449..faa6416625c 100644 --- a/cirq-web/cirq_web/__init__.py +++ b/cirq-web/cirq_web/__init__.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cirq_web._version import __version__ +from cirq_web._version import __version__ as __version__ -from cirq_web.widget import Widget +from cirq_web.widget import Widget as Widget -from cirq_web.bloch_sphere import BlochSphere +from cirq_web.bloch_sphere import BlochSphere as BlochSphere -from cirq_web.circuits import Circuit3D +from cirq_web.circuits import Circuit3D as Circuit3D diff --git a/cirq-web/cirq_web/bloch_sphere/__init__.py b/cirq-web/cirq_web/bloch_sphere/__init__.py index a699d4e1b6e..2848027b08e 100644 --- a/cirq-web/cirq_web/bloch_sphere/__init__.py +++ b/cirq-web/cirq_web/bloch_sphere/__init__.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cirq_web.bloch_sphere.bloch_sphere import BlochSphere +from cirq_web.bloch_sphere.bloch_sphere import BlochSphere as BlochSphere diff --git a/cirq-web/cirq_web/circuits/__init__.py b/cirq-web/cirq_web/circuits/__init__.py index 017f3a79191..ef14b2693aa 100644 --- a/cirq-web/cirq_web/circuits/__init__.py +++ b/cirq-web/cirq_web/circuits/__init__.py @@ -12,5 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -from cirq_web.circuits.circuit import Circuit3D -from cirq_web.circuits.symbols import Operation3DSymbol +from cirq_web.circuits.circuit import Circuit3D as Circuit3D + +from cirq_web.circuits.symbols import Operation3DSymbol as Operation3DSymbol diff --git a/dev_tools/conf/mypy.ini b/dev_tools/conf/mypy.ini index b3f4b59ef6c..948348ac597 100644 --- a/dev_tools/conf/mypy.ini +++ b/dev_tools/conf/mypy.ini @@ -5,6 +5,10 @@ plugins = duet.typing warn_unused_ignores = true warn_redundant_casts = true +# Require explicit reexport from cirq modules +[mypy-cirq.*] +no_implicit_reexport = true + [mypy-__main__] follow_imports = silent ignore_missing_imports = true @@ -21,7 +25,6 @@ ignore_missing_imports = true follow_imports = silent ignore_missing_imports = true - # Treat symbols imported from Google's protobuf library as type Any. # This suppresses errors due to attributes not known to typeshed, # e.g. Descriptor._options. diff --git a/dev_tools/docs/run_doctest.py b/dev_tools/docs/run_doctest.py index a387d5791d3..f2f832c7543 100755 --- a/dev_tools/docs/run_doctest.py +++ b/dev_tools/docs/run_doctest.py @@ -26,6 +26,7 @@ """ from typing import Any, Dict, Iterable, List, Tuple +from types import ModuleType import sys import glob @@ -35,9 +36,6 @@ from dev_tools import shell_tools from dev_tools.output_capture import OutputCapture -# Bug workaround: https://github.com/python/mypy/issues/1498 -ModuleType = Any - class Doctest: def __init__(self, file_name: str, mod: ModuleType, test_globals: Dict[str, Any]): diff --git a/dev_tools/notebooks/__init__.py b/dev_tools/notebooks/__init__.py index 413ad428929..9b7fd6649d7 100644 --- a/dev_tools/notebooks/__init__.py +++ b/dev_tools/notebooks/__init__.py @@ -12,4 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from dev_tools.notebooks.utils import filter_notebooks, list_all_notebooks, rewrite_notebook +from dev_tools.notebooks.utils import ( + filter_notebooks as filter_notebooks, + list_all_notebooks as list_all_notebooks, + rewrite_notebook as rewrite_notebook, +) diff --git a/dev_tools/requirements/__init__.py b/dev_tools/requirements/__init__.py index b539b428dfd..acc360ac6a0 100644 --- a/dev_tools/requirements/__init__.py +++ b/dev_tools/requirements/__init__.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -from dev_tools.requirements.reqs import explode +from dev_tools.requirements.reqs import explode as explode