cirq-core 1.6.0.dev20250509215532__py3-none-any.whl → 1.6.0.dev20250512192405__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cirq-core might be problematic. Click here for more details.
- cirq/_version.py +1 -1
- cirq/_version_test.py +2 -2
- cirq/circuits/_block_diagram_drawer_test.py +6 -6
- cirq/circuits/_box_drawing_character_data_test.py +1 -1
- cirq/circuits/insert_strategy_test.py +2 -2
- cirq/circuits/optimization_pass_test.py +5 -5
- cirq/contrib/acquaintance/inspection_utils_test.py +2 -2
- cirq/contrib/acquaintance/mutation_utils_test.py +2 -2
- cirq/contrib/acquaintance/optimizers_test.py +1 -1
- cirq/contrib/acquaintance/shift_test.py +6 -6
- cirq/contrib/acquaintance/strategies/cubic_test.py +2 -2
- cirq/contrib/acquaintance/topological_sort_test.py +1 -1
- cirq/contrib/hacks/disable_validation_test.py +1 -1
- cirq/contrib/json_test.py +3 -3
- cirq/contrib/noise_models/noise_models_test.py +8 -8
- cirq/contrib/paulistring/clifford_optimize_test.py +5 -5
- cirq/contrib/paulistring/clifford_target_gateset_test.py +11 -11
- cirq/contrib/paulistring/optimize_test.py +3 -3
- cirq/contrib/paulistring/pauli_string_dag_test.py +1 -1
- cirq/contrib/paulistring/pauli_string_optimize_test.py +3 -3
- cirq/contrib/paulistring/recombine_test.py +1 -1
- cirq/contrib/paulistring/separate_test.py +1 -1
- cirq/contrib/qasm_import/_parser_test.py +67 -67
- cirq/contrib/qcircuit/qcircuit_pdf_test.py +1 -1
- cirq/contrib/qcircuit/qcircuit_test.py +6 -6
- cirq/contrib/routing/greedy_test.py +2 -2
- cirq/contrib/routing/initialization_test.py +3 -3
- cirq/contrib/svg/svg_test.py +5 -5
- cirq/devices/device_test.py +4 -4
- cirq/devices/insertion_noise_model_test.py +5 -5
- cirq/devices/named_topologies_test.py +10 -10
- cirq/devices/noise_properties_test.py +1 -1
- cirq/experiments/n_qubit_tomography_test.py +5 -5
- cirq/experiments/t1_decay_experiment_test.py +11 -11
- cirq/interop/quirk/cells/arithmetic_cells_test.py +14 -14
- cirq/interop/quirk/cells/control_cells_test.py +5 -5
- cirq/interop/quirk/cells/frequency_space_cells_test.py +1 -1
- cirq/interop/quirk/cells/ignored_cells_test.py +1 -1
- cirq/interop/quirk/cells/input_cells_test.py +5 -5
- cirq/interop/quirk/cells/input_rotation_cells_test.py +7 -7
- cirq/interop/quirk/cells/measurement_cells_test.py +1 -1
- cirq/interop/quirk/cells/qubit_permutation_cells_test.py +7 -7
- cirq/interop/quirk/cells/scalar_cells_test.py +1 -1
- cirq/interop/quirk/cells/single_qubit_rotation_cells_test.py +3 -3
- cirq/interop/quirk/cells/swap_cell_test.py +4 -4
- cirq/interop/quirk/cells/testing_test.py +6 -6
- cirq/interop/quirk/cells/unsupported_cells_test.py +2 -2
- cirq/linalg/combinators_test.py +7 -7
- cirq/linalg/diagonalize_test.py +10 -10
- cirq/linalg/operator_spaces_test.py +11 -11
- cirq/linalg/tolerance_test.py +4 -4
- cirq/neutral_atoms/convert_to_neutral_atom_gates_test.py +1 -1
- cirq/ops/arithmetic_operation_test.py +2 -2
- cirq/ops/common_channels_test.py +80 -80
- cirq/ops/fsim_gate_test.py +26 -26
- cirq/ops/gate_features_test.py +3 -3
- cirq/ops/greedy_qubit_manager_test.py +3 -3
- cirq/ops/mixed_unitary_channel_test.py +11 -11
- cirq/ops/parallel_gate_test.py +16 -16
- cirq/ops/parity_gates_test.py +34 -32
- cirq/ops/pauli_gates_test.py +20 -20
- cirq/ops/pauli_interaction_gate_test.py +8 -8
- cirq/ops/pauli_sum_exponential_test.py +10 -10
- cirq/ops/permutation_gate_test.py +8 -8
- cirq/ops/phased_iswap_gate_test.py +15 -15
- cirq/ops/qubit_manager_test.py +4 -4
- cirq/ops/random_gate_channel_test.py +11 -11
- cirq/ops/state_preparation_channel_test.py +8 -8
- cirq/ops/swap_gates_test.py +17 -17
- cirq/ops/tags_test.py +2 -2
- cirq/ops/three_qubit_gates_test.py +17 -17
- cirq/ops/two_qubit_diagonal_gate_test.py +8 -8
- cirq/ops/uniform_superposition_gate_test.py +3 -3
- cirq/protocols/act_on_protocol_test.py +6 -6
- cirq/protocols/circuit_diagram_info_protocol_test.py +13 -13
- cirq/protocols/control_key_protocol_test.py +1 -1
- cirq/protocols/decompose_protocol_test.py +12 -12
- cirq/protocols/equal_up_to_global_phase_protocol_test.py +6 -6
- cirq/protocols/has_stabilizer_effect_protocol_test.py +5 -5
- cirq/protocols/has_unitary_protocol_test.py +8 -8
- cirq/protocols/hash_from_pickle_test.py +1 -1
- cirq/protocols/inverse_protocol_test.py +2 -2
- cirq/protocols/kraus_protocol_test.py +9 -9
- cirq/protocols/measurement_key_protocol_test.py +10 -10
- cirq/protocols/pauli_expansion_protocol_test.py +2 -2
- cirq/protocols/phase_protocol_test.py +1 -1
- cirq/protocols/qasm_test.py +3 -3
- cirq/protocols/qid_shape_protocol_test.py +1 -1
- cirq/protocols/resolve_parameters_test.py +5 -5
- cirq/protocols/trace_distance_bound_test.py +1 -1
- cirq/qis/channels_test.py +16 -16
- cirq/qis/measures_test.py +16 -14
- cirq/qis/noise_utils_test.py +7 -7
- cirq/sim/clifford/clifford_tableau_simulation_state_test.py +3 -3
- cirq/sim/clifford/stabilizer_ch_form_simulation_state_test.py +6 -6
- cirq/sim/clifford/stabilizer_sampler_test.py +2 -2
- cirq/sim/clifford/stabilizer_simulation_state_test.py +4 -4
- cirq/sim/clifford/stabilizer_state_ch_form_test.py +2 -2
- cirq/sim/density_matrix_simulation_state_test.py +8 -8
- cirq/sim/density_matrix_utils_test.py +36 -36
- cirq/sim/simulation_product_state_test.py +22 -22
- cirq/sim/simulation_state_test.py +12 -12
- cirq/sim/simulation_utils_test.py +1 -1
- cirq/sim/state_vector_simulation_state_test.py +12 -12
- cirq/study/flatten_expressions_test.py +11 -11
- cirq/study/resolver_test.py +20 -20
- cirq/testing/consistent_act_on_test.py +1 -1
- cirq/testing/consistent_channels_test.py +8 -8
- cirq/testing/consistent_controlled_gate_op_test.py +2 -2
- cirq/testing/consistent_decomposition_test.py +2 -2
- cirq/testing/consistent_pauli_expansion_test.py +1 -1
- cirq/testing/consistent_phase_by_test.py +1 -1
- cirq/testing/consistent_qasm_test.py +1 -1
- cirq/testing/consistent_specified_has_unitary_test.py +4 -4
- cirq/testing/consistent_unitary_test.py +2 -2
- cirq/testing/deprecation_test.py +2 -2
- cirq/testing/devices_test.py +4 -4
- cirq/testing/equivalent_basis_map_test.py +2 -2
- cirq/testing/equivalent_repr_eval_test.py +3 -3
- cirq/testing/gate_features_test.py +5 -5
- cirq/testing/json_test.py +3 -3
- cirq/testing/lin_alg_utils_test.py +12 -12
- cirq/testing/logs_test.py +7 -7
- cirq/testing/no_identifier_qubit_test.py +3 -3
- cirq/testing/op_tree_test.py +1 -1
- cirq/testing/order_tester_test.py +6 -6
- cirq/testing/pytest_utils_test.py +2 -2
- cirq/testing/random_circuit_test.py +5 -5
- cirq/testing/repr_pretty_tester_test.py +3 -3
- cirq/testing/routing_devices_test.py +6 -6
- cirq/testing/sample_circuits_test.py +1 -1
- cirq/testing/sample_gates_test.py +2 -2
- cirq/transformers/analytical_decompositions/pauli_string_decomposition_test.py +3 -3
- cirq/transformers/analytical_decompositions/three_qubit_decomposition_test.py +7 -7
- cirq/transformers/analytical_decompositions/two_qubit_to_cz_test.py +6 -6
- cirq/transformers/analytical_decompositions/two_qubit_to_fsim_test.py +5 -5
- cirq/transformers/analytical_decompositions/two_qubit_to_ms_test.py +1 -1
- cirq/transformers/drop_empty_moments_test.py +2 -2
- cirq/transformers/eject_phased_paulis_test.py +9 -9
- cirq/transformers/heuristic_decompositions/two_qubit_gate_tabulation_test.py +7 -7
- cirq/transformers/insertion_sort_test.py +1 -1
- cirq/transformers/merge_k_qubit_gates_test.py +9 -9
- cirq/transformers/qubit_management_transformers_test.py +3 -3
- cirq/transformers/randomized_measurements_test.py +8 -4
- cirq/transformers/routing/line_initial_mapper_test.py +5 -5
- cirq/transformers/routing/route_circuit_cqc_test.py +13 -13
- cirq/transformers/routing/visualize_routed_circuit_test.py +2 -2
- cirq/transformers/synchronize_terminal_measurements_test.py +10 -10
- cirq/transformers/target_gatesets/compilation_target_gateset_test.py +8 -8
- cirq/transformers/target_gatesets/cz_gateset_test.py +17 -17
- cirq/transformers/target_gatesets/sqrt_iswap_gateset_test.py +23 -23
- cirq/value/angle_test.py +3 -3
- cirq/value/classical_data_test.py +8 -8
- cirq/value/periodic_value_test.py +9 -7
- cirq/value/probability_test.py +2 -2
- cirq/value/value_equality_attr_test.py +11 -11
- cirq/vis/histogram_test.py +2 -2
- cirq/vis/state_histogram_test.py +5 -5
- cirq/vis/vis_utils_test.py +1 -1
- cirq/work/observable_grouping_test.py +8 -8
- cirq/work/observable_readout_calibration_test.py +1 -1
- cirq/work/zeros_sampler_test.py +4 -4
- {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/METADATA +1 -1
- {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/RECORD +167 -167
- {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/WHEEL +0 -0
- {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.6.0.dev20250509215532.dist-info → cirq_core-1.6.0.dev20250512192405.dist-info}/top_level.txt +0 -0
|
@@ -17,7 +17,7 @@ from cirq.interop.quirk.cells.qubit_permutation_cells import QuirkQubitPermutati
|
|
|
17
17
|
from cirq.interop.quirk.cells.testing import assert_url_to_circuit_returns
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
def test_equality():
|
|
20
|
+
def test_equality() -> None:
|
|
21
21
|
eq = cirq.testing.EqualsTester()
|
|
22
22
|
eq.make_equality_group(lambda: QuirkQubitPermutationGate('a', 'b', [0, 1]))
|
|
23
23
|
eq.add_equality_group(QuirkQubitPermutationGate('x', 'b', [0, 1]))
|
|
@@ -25,11 +25,11 @@ def test_equality():
|
|
|
25
25
|
eq.add_equality_group(QuirkQubitPermutationGate('a', 'b', [1, 0]))
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
def test_repr():
|
|
28
|
+
def test_repr() -> None:
|
|
29
29
|
cirq.testing.assert_equivalent_repr(QuirkQubitPermutationGate('a', 'b', [0, 1]))
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
def test_right_rotate():
|
|
32
|
+
def test_right_rotate() -> None:
|
|
33
33
|
assert_url_to_circuit_returns(
|
|
34
34
|
'{"cols":[["X",">>4",1,1,1,"X"]]}',
|
|
35
35
|
diagram="""
|
|
@@ -57,7 +57,7 @@ def test_right_rotate():
|
|
|
57
57
|
)
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
def test_left_rotate():
|
|
60
|
+
def test_left_rotate() -> None:
|
|
61
61
|
assert_url_to_circuit_returns(
|
|
62
62
|
'{"cols":[["<<4"]]}',
|
|
63
63
|
maps={
|
|
@@ -72,7 +72,7 @@ def test_left_rotate():
|
|
|
72
72
|
)
|
|
73
73
|
|
|
74
74
|
|
|
75
|
-
def test_reverse():
|
|
75
|
+
def test_reverse() -> None:
|
|
76
76
|
assert_url_to_circuit_returns(
|
|
77
77
|
'{"cols":[["rev4"]]}',
|
|
78
78
|
maps={
|
|
@@ -98,7 +98,7 @@ def test_reverse():
|
|
|
98
98
|
)
|
|
99
99
|
|
|
100
100
|
|
|
101
|
-
def test_interleave():
|
|
101
|
+
def test_interleave() -> None:
|
|
102
102
|
assert_url_to_circuit_returns(
|
|
103
103
|
'{"cols":[["weave5"]]}',
|
|
104
104
|
maps={
|
|
@@ -128,7 +128,7 @@ def test_interleave():
|
|
|
128
128
|
)
|
|
129
129
|
|
|
130
130
|
|
|
131
|
-
def test_deinterleave():
|
|
131
|
+
def test_deinterleave() -> None:
|
|
132
132
|
assert_url_to_circuit_returns(
|
|
133
133
|
'{"cols":[["split5"]]}',
|
|
134
134
|
maps={
|
|
@@ -16,7 +16,7 @@ import cirq
|
|
|
16
16
|
from cirq.interop.quirk.cells.testing import assert_url_to_circuit_returns
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
def test_scalar_operations():
|
|
19
|
+
def test_scalar_operations() -> None:
|
|
20
20
|
assert_url_to_circuit_returns('{"cols":[["…"]]}', cirq.Circuit())
|
|
21
21
|
|
|
22
22
|
assert_url_to_circuit_returns(
|
|
@@ -18,7 +18,7 @@ import cirq
|
|
|
18
18
|
from cirq.interop.quirk.cells.testing import assert_url_to_circuit_returns
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def test_fixed_single_qubit_rotations():
|
|
21
|
+
def test_fixed_single_qubit_rotations() -> None:
|
|
22
22
|
a, b, c, d = cirq.LineQubit.range(4)
|
|
23
23
|
|
|
24
24
|
assert_url_to_circuit_returns(
|
|
@@ -89,7 +89,7 @@ def test_fixed_single_qubit_rotations():
|
|
|
89
89
|
)
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
def test_dynamic_single_qubit_rotations():
|
|
92
|
+
def test_dynamic_single_qubit_rotations() -> None:
|
|
93
93
|
a, b, c = cirq.LineQubit.range(3)
|
|
94
94
|
t = sympy.Symbol('t')
|
|
95
95
|
|
|
@@ -118,7 +118,7 @@ def test_dynamic_single_qubit_rotations():
|
|
|
118
118
|
)
|
|
119
119
|
|
|
120
120
|
|
|
121
|
-
def test_formulaic_gates():
|
|
121
|
+
def test_formulaic_gates() -> None:
|
|
122
122
|
a, b = cirq.LineQubit.range(2)
|
|
123
123
|
t = sympy.Symbol('t')
|
|
124
124
|
|
|
@@ -19,7 +19,7 @@ from cirq import quirk_url_to_circuit
|
|
|
19
19
|
from cirq.interop.quirk.cells.testing import assert_url_to_circuit_returns
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
def test_swap():
|
|
22
|
+
def test_swap() -> None:
|
|
23
23
|
a, b, c = cirq.LineQubit.range(3)
|
|
24
24
|
assert_url_to_circuit_returns('{"cols":[["Swap","Swap"]]}', cirq.Circuit(cirq.SWAP(a, b)))
|
|
25
25
|
assert_url_to_circuit_returns(
|
|
@@ -34,7 +34,7 @@ def test_swap():
|
|
|
34
34
|
)
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
def test_controlled_swap():
|
|
37
|
+
def test_controlled_swap() -> None:
|
|
38
38
|
a, b, c, d = cirq.LineQubit.range(4)
|
|
39
39
|
assert_url_to_circuit_returns(
|
|
40
40
|
'{"cols":[["Swap","•","Swap"]]}', cirq.Circuit(cirq.SWAP(a, c).controlled_by(b))
|
|
@@ -44,7 +44,7 @@ def test_controlled_swap():
|
|
|
44
44
|
)
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
def test_with_line_qubits_mapped_to():
|
|
47
|
+
def test_with_line_qubits_mapped_to() -> None:
|
|
48
48
|
a, b, c, d = cirq.LineQubit.range(4)
|
|
49
49
|
a2, b2, c2, d2 = cirq.NamedQubit.range(4, prefix='q')
|
|
50
50
|
cell = cirq.interop.quirk.cells.swap_cell.SwapCell(qubits=[a, b], controls=[c, d])
|
|
@@ -53,7 +53,7 @@ def test_with_line_qubits_mapped_to():
|
|
|
53
53
|
assert cell.with_line_qubits_mapped_to([a2, b2, c2, d2]) == mapped_cell
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
def test_repr():
|
|
56
|
+
def test_repr() -> None:
|
|
57
57
|
a, b, c, d = cirq.LineQubit.range(4)
|
|
58
58
|
cirq.testing.assert_equivalent_repr(
|
|
59
59
|
cirq.interop.quirk.cells.swap_cell.SwapCell(qubits=[a, b], controls=[c, d])
|
|
@@ -19,7 +19,7 @@ import cirq
|
|
|
19
19
|
from cirq.interop.quirk.cells.testing import assert_url_to_circuit_returns
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
def test_assert_url_to_circuit_returns_circuit():
|
|
22
|
+
def test_assert_url_to_circuit_returns_circuit() -> None:
|
|
23
23
|
assert_url_to_circuit_returns(
|
|
24
24
|
'{"cols":[["X"]]}', circuit=cirq.Circuit(cirq.X(cirq.LineQubit(0)))
|
|
25
25
|
)
|
|
@@ -30,21 +30,21 @@ def test_assert_url_to_circuit_returns_circuit():
|
|
|
30
30
|
)
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
def test_assert_url_to_circuit_returns_unitary():
|
|
33
|
+
def test_assert_url_to_circuit_returns_unitary() -> None:
|
|
34
34
|
assert_url_to_circuit_returns('{"cols":[["X"]]}', unitary=cirq.unitary(cirq.X))
|
|
35
35
|
|
|
36
36
|
with pytest.raises(AssertionError, match='Not equal to tolerance'):
|
|
37
37
|
assert_url_to_circuit_returns('{"cols":[["X"]]}', unitary=np.eye(2))
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
def test_assert_url_to_circuit_returns_diagram():
|
|
40
|
+
def test_assert_url_to_circuit_returns_diagram() -> None:
|
|
41
41
|
assert_url_to_circuit_returns('{"cols":[["X"]]}', diagram='0: ───X───')
|
|
42
42
|
|
|
43
43
|
with pytest.raises(AssertionError, match='text diagram differs'):
|
|
44
44
|
assert_url_to_circuit_returns('{"cols":[["X"]]}', diagram='not even close')
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
def test_assert_url_to_circuit_returns_maps():
|
|
47
|
+
def test_assert_url_to_circuit_returns_maps() -> None:
|
|
48
48
|
assert_url_to_circuit_returns('{"cols":[["X"]]}', maps={0: 1})
|
|
49
49
|
assert_url_to_circuit_returns('{"cols":[["X"]]}', maps={0: 1, 1: 0})
|
|
50
50
|
|
|
@@ -55,7 +55,7 @@ def test_assert_url_to_circuit_returns_maps():
|
|
|
55
55
|
assert_url_to_circuit_returns('{"cols":[["H"]]}', maps={0: 0})
|
|
56
56
|
|
|
57
57
|
|
|
58
|
-
def test_assert_url_to_circuit_returns_output_amplitudes_from_quirk():
|
|
58
|
+
def test_assert_url_to_circuit_returns_output_amplitudes_from_quirk() -> None:
|
|
59
59
|
assert_url_to_circuit_returns(
|
|
60
60
|
'{"cols":[["X","Z"]]}',
|
|
61
61
|
output_amplitudes_from_quirk=[
|
|
@@ -78,7 +78,7 @@ def test_assert_url_to_circuit_returns_output_amplitudes_from_quirk():
|
|
|
78
78
|
)
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
def test_assert_url_to_circuit_misc():
|
|
81
|
+
def test_assert_url_to_circuit_misc() -> None:
|
|
82
82
|
a, b = cirq.LineQubit.range(2)
|
|
83
83
|
|
|
84
84
|
assert_url_to_circuit_returns(
|
|
@@ -17,7 +17,7 @@ import pytest
|
|
|
17
17
|
from cirq import quirk_url_to_circuit
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
def test_non_physical_operations():
|
|
20
|
+
def test_non_physical_operations() -> None:
|
|
21
21
|
with pytest.raises(NotImplementedError, match="unphysical operation"):
|
|
22
22
|
_ = quirk_url_to_circuit('https://algassert.com/quirk#circuit={"cols":[["__error__"]]}')
|
|
23
23
|
with pytest.raises(NotImplementedError, match="unphysical operation"):
|
|
@@ -26,7 +26,7 @@ def test_non_physical_operations():
|
|
|
26
26
|
)
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
def test_not_implemented_gates():
|
|
29
|
+
def test_not_implemented_gates() -> None:
|
|
30
30
|
# This test mostly exists to ensure the gates are tested if added.
|
|
31
31
|
|
|
32
32
|
for k in ["X^⌈t⌉", "X^⌈t-¼⌉", "Counting4", "Uncounting4", ">>t3", "<<t3"]:
|
cirq/linalg/combinators_test.py
CHANGED
|
@@ -17,7 +17,7 @@ import pytest
|
|
|
17
17
|
import cirq
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
def test_dot():
|
|
20
|
+
def test_dot() -> None:
|
|
21
21
|
assert cirq.dot(2) == 2
|
|
22
22
|
assert cirq.dot(2.5, 2.5) == 6.25
|
|
23
23
|
|
|
@@ -33,7 +33,7 @@ def test_dot():
|
|
|
33
33
|
cirq.dot()
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
def test_kron_multiplies_sizes():
|
|
36
|
+
def test_kron_multiplies_sizes() -> None:
|
|
37
37
|
assert cirq.kron(np.array([1, 2])).shape == (1, 2)
|
|
38
38
|
assert cirq.kron(np.array([1, 2]), shape_len=1).shape == (2,)
|
|
39
39
|
assert cirq.kron(np.array([1, 2]), np.array([3, 4, 5]), shape_len=1).shape == (6,)
|
|
@@ -51,7 +51,7 @@ def test_kron_multiplies_sizes():
|
|
|
51
51
|
assert np.allclose(cirq.kron(np.eye(2), np.eye(3), np.eye(4)), np.eye(24))
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
def test_kron_spreads_values():
|
|
54
|
+
def test_kron_spreads_values() -> None:
|
|
55
55
|
u = np.array([[2, 3], [5, 7]])
|
|
56
56
|
|
|
57
57
|
assert np.allclose(
|
|
@@ -68,7 +68,7 @@ def test_kron_spreads_values():
|
|
|
68
68
|
)
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
def test_acts_like_kron_multiplies_sizes():
|
|
71
|
+
def test_acts_like_kron_multiplies_sizes() -> None:
|
|
72
72
|
assert np.allclose(cirq.kron_with_controls(), np.eye(1))
|
|
73
73
|
assert np.allclose(cirq.kron_with_controls(np.eye(2), np.eye(3), np.eye(4)), np.eye(24))
|
|
74
74
|
|
|
@@ -79,7 +79,7 @@ def test_acts_like_kron_multiplies_sizes():
|
|
|
79
79
|
)
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
def test_supports_controls():
|
|
82
|
+
def test_supports_controls() -> None:
|
|
83
83
|
u = np.array([[2, 3], [5, 7]])
|
|
84
84
|
assert np.allclose(cirq.kron_with_controls(cirq.CONTROL_TAG), np.array([[1, 0], [0, 1]]))
|
|
85
85
|
assert np.allclose(
|
|
@@ -92,7 +92,7 @@ def test_supports_controls():
|
|
|
92
92
|
)
|
|
93
93
|
|
|
94
94
|
|
|
95
|
-
def test_block_diag():
|
|
95
|
+
def test_block_diag() -> None:
|
|
96
96
|
assert np.allclose(cirq.block_diag(), np.zeros((0, 0)))
|
|
97
97
|
|
|
98
98
|
assert np.allclose(cirq.block_diag(np.array([[1, 2], [3, 4]])), np.array([[1, 2], [3, 4]]))
|
|
@@ -108,7 +108,7 @@ def test_block_diag():
|
|
|
108
108
|
_ = cirq.block_diag(np.array([[1, 2, 3], [3, 4, 5]]))
|
|
109
109
|
|
|
110
110
|
|
|
111
|
-
def test_block_diag_dtype():
|
|
111
|
+
def test_block_diag_dtype() -> None:
|
|
112
112
|
assert cirq.block_diag().dtype == np.complex128
|
|
113
113
|
|
|
114
114
|
assert cirq.block_diag(np.array([[1]], dtype=np.int8)).dtype == np.int8
|
cirq/linalg/diagonalize_test.py
CHANGED
|
@@ -107,7 +107,7 @@ def assert_bidiagonalized_by(m, p, q, rtol: float = 1e-5, atol: float = 1e-8):
|
|
|
107
107
|
+ [random_symmetric_matrix(4) for _ in range(10)]
|
|
108
108
|
+ [random_symmetric_matrix(k) for k in range(1, 10)],
|
|
109
109
|
)
|
|
110
|
-
def test_diagonalize_real_symmetric_matrix(matrix):
|
|
110
|
+
def test_diagonalize_real_symmetric_matrix(matrix) -> None:
|
|
111
111
|
p = cirq.diagonalize_real_symmetric_matrix(matrix)
|
|
112
112
|
assert_diagonalized_by(matrix, p)
|
|
113
113
|
|
|
@@ -122,12 +122,12 @@ def test_diagonalize_real_symmetric_matrix(matrix):
|
|
|
122
122
|
np.array([[3, 1], [7, 3]]),
|
|
123
123
|
],
|
|
124
124
|
)
|
|
125
|
-
def test_diagonalize_real_symmetric_matrix_fails(matrix):
|
|
125
|
+
def test_diagonalize_real_symmetric_matrix_fails(matrix) -> None:
|
|
126
126
|
with pytest.raises(ValueError):
|
|
127
127
|
_ = cirq.diagonalize_real_symmetric_matrix(matrix)
|
|
128
128
|
|
|
129
129
|
|
|
130
|
-
def test_diagonalize_real_symmetric_matrix_assertion_error():
|
|
130
|
+
def test_diagonalize_real_symmetric_matrix_assertion_error() -> None:
|
|
131
131
|
with pytest.raises(AssertionError):
|
|
132
132
|
matrix = np.array([[0.5, 0], [0, 1]])
|
|
133
133
|
m = np.array([[0, 1], [0, 0]])
|
|
@@ -151,7 +151,7 @@ def test_diagonalize_real_symmetric_matrix_assertion_error():
|
|
|
151
151
|
]
|
|
152
152
|
+ [([6, 6, 5, 5, 5], random_block_diagonal_symmetric_matrix(2, 3)) for _ in range(10)],
|
|
153
153
|
)
|
|
154
|
-
def test_simultaneous_diagonalize_real_symmetric_matrix_vs_singulars(s, m):
|
|
154
|
+
def test_simultaneous_diagonalize_real_symmetric_matrix_vs_singulars(s, m) -> None:
|
|
155
155
|
m = np.array(m)
|
|
156
156
|
s = np.diag(s)
|
|
157
157
|
p = cirq.diagonalize_real_symmetric_and_sorted_diagonal_matrices(m, s)
|
|
@@ -171,7 +171,7 @@ def test_simultaneous_diagonalize_real_symmetric_matrix_vs_singulars(s, m):
|
|
|
171
171
|
([3, 2, 1], QFT, 'must be real symmetric'),
|
|
172
172
|
],
|
|
173
173
|
)
|
|
174
|
-
def test_simultaneous_diagonalize_real_symmetric_matrix_vs_singulars_fail(s, m, match: str):
|
|
174
|
+
def test_simultaneous_diagonalize_real_symmetric_matrix_vs_singulars_fail(s, m, match: str) -> None:
|
|
175
175
|
m = np.array(m)
|
|
176
176
|
s = np.diag(s)
|
|
177
177
|
with pytest.raises(ValueError, match=match):
|
|
@@ -199,7 +199,7 @@ def test_simultaneous_diagonalize_real_symmetric_matrix_vs_singulars_fail(s, m,
|
|
|
199
199
|
]
|
|
200
200
|
+ [random_bi_diagonalizable_pair(k) for k in range(1, 10)],
|
|
201
201
|
)
|
|
202
|
-
def test_bidiagonalize_real_matrix_pair_with_symmetric_products(a, b):
|
|
202
|
+
def test_bidiagonalize_real_matrix_pair_with_symmetric_products(a, b) -> None:
|
|
203
203
|
a = np.array(a)
|
|
204
204
|
b = np.array(b)
|
|
205
205
|
p, q = cirq.bidiagonalize_real_matrix_pair_with_symmetric_products(a, b)
|
|
@@ -220,14 +220,14 @@ def test_bidiagonalize_real_matrix_pair_with_symmetric_products(a, b):
|
|
|
220
220
|
[np.array([[1, 1], [1, 0]]), np.array([[1, 0], [1, 1]]), 'mat1 @ mat2.T must be symmetric'],
|
|
221
221
|
],
|
|
222
222
|
)
|
|
223
|
-
def test_bidiagonalize_real_fails(a, b, match: str):
|
|
223
|
+
def test_bidiagonalize_real_fails(a, b, match: str) -> None:
|
|
224
224
|
a = np.array(a)
|
|
225
225
|
b = np.array(b)
|
|
226
226
|
with pytest.raises(ValueError, match=match):
|
|
227
227
|
cirq.bidiagonalize_real_matrix_pair_with_symmetric_products(a, b)
|
|
228
228
|
|
|
229
229
|
|
|
230
|
-
def test_bidiagonalize__assertion_error():
|
|
230
|
+
def test_bidiagonalize__assertion_error() -> None:
|
|
231
231
|
with pytest.raises(AssertionError):
|
|
232
232
|
a = np.diag([0, 1])
|
|
233
233
|
assert_bidiagonalized_by(a, a, a)
|
|
@@ -261,7 +261,7 @@ def test_bidiagonalize__assertion_error():
|
|
|
261
261
|
+ [cirq.testing.random_unitary(4) for _ in range(10)]
|
|
262
262
|
+ [cirq.testing.random_unitary(k) for k in range(1, 10)],
|
|
263
263
|
)
|
|
264
|
-
def test_bidiagonalize_unitary_with_special_orthogonals(mat):
|
|
264
|
+
def test_bidiagonalize_unitary_with_special_orthogonals(mat) -> None:
|
|
265
265
|
p, d, q = cirq.bidiagonalize_unitary_with_special_orthogonals(mat)
|
|
266
266
|
assert cirq.is_special_orthogonal(p)
|
|
267
267
|
assert cirq.is_special_orthogonal(q)
|
|
@@ -273,6 +273,6 @@ def test_bidiagonalize_unitary_with_special_orthogonals(mat):
|
|
|
273
273
|
'mat',
|
|
274
274
|
[np.diag([0]), np.diag([0.5]), np.diag([1, 0]), np.diag([0.5, 2]), np.array([[0, 1], [0, 0]])],
|
|
275
275
|
)
|
|
276
|
-
def test_bidiagonalize_unitary_fails(mat):
|
|
276
|
+
def test_bidiagonalize_unitary_fails(mat) -> None:
|
|
277
277
|
with pytest.raises(ValueError):
|
|
278
278
|
cirq.bidiagonalize_unitary_with_special_orthogonals(mat)
|
|
@@ -84,7 +84,7 @@ def _one_hot_matrix(size: int, i: int, j: int) -> np.ndarray:
|
|
|
84
84
|
),
|
|
85
85
|
),
|
|
86
86
|
)
|
|
87
|
-
def test_kron_bases(basis1, basis2, expected_kron_basis):
|
|
87
|
+
def test_kron_bases(basis1, basis2, expected_kron_basis) -> None:
|
|
88
88
|
kron_basis = cirq.kron_bases(basis1, basis2)
|
|
89
89
|
assert len(kron_basis) == 16
|
|
90
90
|
assert set(kron_basis.keys()) == set(expected_kron_basis.keys())
|
|
@@ -115,14 +115,14 @@ def test_kron_bases(basis1, basis2, expected_kron_basis):
|
|
|
115
115
|
),
|
|
116
116
|
),
|
|
117
117
|
)
|
|
118
|
-
def test_kron_bases_consistency(basis1, basis2):
|
|
118
|
+
def test_kron_bases_consistency(basis1, basis2) -> None:
|
|
119
119
|
assert set(basis1.keys()) == set(basis2.keys())
|
|
120
120
|
for name in basis1.keys():
|
|
121
121
|
assert np.all(basis1[name] == basis2[name])
|
|
122
122
|
|
|
123
123
|
|
|
124
124
|
@pytest.mark.parametrize('basis,repeat', itertools.product((PAULI_BASIS, STANDARD_BASIS), range(5)))
|
|
125
|
-
def test_kron_bases_repeat_sanity_checks(basis, repeat):
|
|
125
|
+
def test_kron_bases_repeat_sanity_checks(basis, repeat) -> None:
|
|
126
126
|
product_basis = cirq.kron_bases(basis, repeat=repeat)
|
|
127
127
|
assert len(product_basis) == 4**repeat
|
|
128
128
|
for name1, matrix1 in product_basis.items():
|
|
@@ -138,7 +138,7 @@ def test_kron_bases_repeat_sanity_checks(basis, repeat):
|
|
|
138
138
|
'm1,m2,expect_real',
|
|
139
139
|
((X, X, True), (X, Y, True), (X, H, True), (X, SQRT_X, False), (I, SQRT_Z, False)),
|
|
140
140
|
)
|
|
141
|
-
def test_hilbert_schmidt_inner_product_is_conjugate_symmetric(m1, m2, expect_real):
|
|
141
|
+
def test_hilbert_schmidt_inner_product_is_conjugate_symmetric(m1, m2, expect_real) -> None:
|
|
142
142
|
v1 = cirq.hilbert_schmidt_inner_product(m1, m2)
|
|
143
143
|
v2 = cirq.hilbert_schmidt_inner_product(m2, m1)
|
|
144
144
|
assert v1 == v2.conjugate()
|
|
@@ -149,7 +149,7 @@ def test_hilbert_schmidt_inner_product_is_conjugate_symmetric(m1, m2, expect_rea
|
|
|
149
149
|
|
|
150
150
|
|
|
151
151
|
@pytest.mark.parametrize('a,m1,b,m2', ((1, X, 1, Z), (2, X, 3, Y), (2j, X, 3, I), (2, X, 3, X)))
|
|
152
|
-
def test_hilbert_schmidt_inner_product_is_linear(a, m1, b, m2):
|
|
152
|
+
def test_hilbert_schmidt_inner_product_is_linear(a, m1, b, m2) -> None:
|
|
153
153
|
v1 = cirq.hilbert_schmidt_inner_product(H, (a * m1 + b * m2))
|
|
154
154
|
v2 = a * cirq.hilbert_schmidt_inner_product(H, m1) + b * cirq.hilbert_schmidt_inner_product(
|
|
155
155
|
H, m2
|
|
@@ -158,7 +158,7 @@ def test_hilbert_schmidt_inner_product_is_linear(a, m1, b, m2):
|
|
|
158
158
|
|
|
159
159
|
|
|
160
160
|
@pytest.mark.parametrize('m', (I, X, Y, Z, H, SQRT_X, SQRT_Y, SQRT_Z))
|
|
161
|
-
def test_hilbert_schmidt_inner_product_is_positive_definite(m):
|
|
161
|
+
def test_hilbert_schmidt_inner_product_is_positive_definite(m) -> None:
|
|
162
162
|
v = cirq.hilbert_schmidt_inner_product(m, m)
|
|
163
163
|
# Cannot check using np.is_real due to bug in aarch64.
|
|
164
164
|
# See https://github.com/quantumlib/Cirq/issues/4379
|
|
@@ -186,7 +186,7 @@ def test_hilbert_schmidt_inner_product_is_positive_definite(m):
|
|
|
186
186
|
(SQRT_X, E11, np.sqrt(-0.5j)),
|
|
187
187
|
),
|
|
188
188
|
)
|
|
189
|
-
def test_hilbert_schmidt_inner_product_values(m1, m2, expected_value):
|
|
189
|
+
def test_hilbert_schmidt_inner_product_values(m1, m2, expected_value) -> None:
|
|
190
190
|
v = cirq.hilbert_schmidt_inner_product(m1, m2)
|
|
191
191
|
assert np.isclose(v, expected_value)
|
|
192
192
|
|
|
@@ -195,7 +195,7 @@ def test_hilbert_schmidt_inner_product_values(m1, m2, expected_value):
|
|
|
195
195
|
'm,basis',
|
|
196
196
|
itertools.product((I, X, Y, Z, H, SQRT_X, SQRT_Y, SQRT_Z), (PAULI_BASIS, STANDARD_BASIS)),
|
|
197
197
|
)
|
|
198
|
-
def test_expand_matrix_in_orthogonal_basis(m, basis):
|
|
198
|
+
def test_expand_matrix_in_orthogonal_basis(m, basis) -> None:
|
|
199
199
|
expansion = cirq.expand_matrix_in_orthogonal_basis(m, basis)
|
|
200
200
|
|
|
201
201
|
reconstructed = np.zeros(m.shape, dtype=complex)
|
|
@@ -216,7 +216,7 @@ def test_expand_matrix_in_orthogonal_basis(m, basis):
|
|
|
216
216
|
{'I': 1, 'X': 2, 'Y': 3, 'Z': 4},
|
|
217
217
|
),
|
|
218
218
|
)
|
|
219
|
-
def test_matrix_from_basis_coefficients(expansion):
|
|
219
|
+
def test_matrix_from_basis_coefficients(expansion) -> None:
|
|
220
220
|
m = cirq.matrix_from_basis_coefficients(expansion, PAULI_BASIS)
|
|
221
221
|
|
|
222
222
|
for name, coefficient in expansion.items():
|
|
@@ -236,7 +236,7 @@ def test_matrix_from_basis_coefficients(expansion):
|
|
|
236
236
|
)
|
|
237
237
|
),
|
|
238
238
|
)
|
|
239
|
-
def test_expand_is_inverse_of_reconstruct(m1, basis):
|
|
239
|
+
def test_expand_is_inverse_of_reconstruct(m1, basis) -> None:
|
|
240
240
|
c1 = cirq.expand_matrix_in_orthogonal_basis(m1, basis)
|
|
241
241
|
m2 = cirq.matrix_from_basis_coefficients(c1, basis)
|
|
242
242
|
c2 = cirq.expand_matrix_in_orthogonal_basis(m2, basis)
|
|
@@ -299,7 +299,7 @@ def test_expand_is_inverse_of_reconstruct(m1, basis):
|
|
|
299
299
|
(0, 1, 2, 3, 4, 5, 100, 101),
|
|
300
300
|
),
|
|
301
301
|
)
|
|
302
|
-
def test_pow_pauli_combination(coefficients, exponent):
|
|
302
|
+
def test_pow_pauli_combination(coefficients, exponent) -> None:
|
|
303
303
|
is_symbolic = any(isinstance(a, sympy.Basic) for a in coefficients)
|
|
304
304
|
if is_symbolic and exponent > 2:
|
|
305
305
|
return # too slow
|
cirq/linalg/tolerance_test.py
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
from cirq.linalg.tolerance import all_near_zero, all_near_zero_mod, near_zero, near_zero_mod
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
def test_all_zero():
|
|
18
|
+
def test_all_zero() -> None:
|
|
19
19
|
atol = 5
|
|
20
20
|
assert all_near_zero(0, atol=atol)
|
|
21
21
|
assert all_near_zero(4.5, atol=atol)
|
|
@@ -25,7 +25,7 @@ def test_all_zero():
|
|
|
25
25
|
assert not all_near_zero([-4.5, 0, 1, 4.5, 30], atol=atol)
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
def test_all_zero_mod():
|
|
28
|
+
def test_all_zero_mod() -> None:
|
|
29
29
|
atol = 5
|
|
30
30
|
assert all_near_zero_mod(0, 100, atol=atol)
|
|
31
31
|
assert all_near_zero_mod(4.5, 100, atol=atol)
|
|
@@ -45,14 +45,14 @@ def test_all_zero_mod():
|
|
|
45
45
|
assert not all_near_zero_mod([-4.5, 0, 1, 4.5, 30], 100, atol=atol)
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
def test_near_zero():
|
|
48
|
+
def test_near_zero() -> None:
|
|
49
49
|
atol = 5
|
|
50
50
|
assert near_zero(0, atol=atol)
|
|
51
51
|
assert near_zero(4.5, atol=atol)
|
|
52
52
|
assert not near_zero(5.5, atol=atol)
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
def test_near_zero_mod():
|
|
55
|
+
def test_near_zero_mod() -> None:
|
|
56
56
|
atol = 5
|
|
57
57
|
assert near_zero_mod(0, 100, atol=atol)
|
|
58
58
|
assert near_zero_mod(4.5, 100, atol=atol)
|
|
@@ -43,7 +43,7 @@ Q, Q2, Q3 = cirq.LineQubit.range(3)
|
|
|
43
43
|
(cirq.ZPowGate(exponent=0.5)(Q).controlled_by(Q2, Q3), False),
|
|
44
44
|
],
|
|
45
45
|
)
|
|
46
|
-
def test_gateset(op: cirq.Operation, expected: bool):
|
|
46
|
+
def test_gateset(op: cirq.Operation, expected: bool) -> None:
|
|
47
47
|
assert cirq.is_native_neutral_atom_op(op) == expected
|
|
48
48
|
if op.gate is not None:
|
|
49
49
|
assert cirq.is_native_neutral_atom_gate(op.gate) == expected
|
|
@@ -36,7 +36,7 @@ def adder_matrix(target_width: int, source_width: int) -> np.ndarray:
|
|
|
36
36
|
return result
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
def test_the_tests():
|
|
39
|
+
def test_the_tests() -> None:
|
|
40
40
|
# fmt: off
|
|
41
41
|
np.testing.assert_allclose(
|
|
42
42
|
shift_matrix(4, 1),
|
|
@@ -85,7 +85,7 @@ def test_the_tests():
|
|
|
85
85
|
)
|
|
86
86
|
|
|
87
87
|
|
|
88
|
-
def test_arithmetic_gate_apply_unitary():
|
|
88
|
+
def test_arithmetic_gate_apply_unitary() -> None:
|
|
89
89
|
class Add(cirq.ArithmeticGate):
|
|
90
90
|
def __init__(
|
|
91
91
|
self,
|