cirq-core 1.7.0.dev20250819195403__py3-none-any.whl → 1.7.0.dev20250821232720__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 +1 -1
- cirq/circuits/circuit.py +1 -1
- cirq/circuits/moment.py +1 -1
- cirq/devices/grid_qubit.py +1 -2
- cirq/devices/line_qubit.py +1 -3
- cirq/experiments/z_phase_calibration_test.py +8 -7
- cirq/interop/quirk/cells/arithmetic_cells.py +1 -1
- cirq/interop/quirk/cells/cell_test.py +5 -5
- cirq/interop/quirk/cells/composite_cell_test.py +5 -3
- cirq/interop/quirk/cells/control_cells.py +2 -2
- cirq/interop/quirk/cells/input_cells.py +3 -3
- cirq/interop/quirk/cells/input_rotation_cells.py +2 -2
- cirq/interop/quirk/cells/swap_cell.py +2 -2
- cirq/interop/quirk/cells/testing.py +1 -1
- cirq/interop/quirk/url_to_circuit.py +2 -2
- cirq/interop/quirk/url_to_circuit_test.py +11 -11
- cirq/linalg/decompositions.py +1 -1
- cirq/linalg/decompositions_test.py +52 -50
- cirq/linalg/diagonalize_test.py +2 -2
- cirq/linalg/predicates.py +1 -1
- cirq/linalg/predicates_test.py +24 -24
- cirq/linalg/transformations.py +6 -4
- cirq/neutral_atoms/neutral_atom_devices.py +1 -1
- cirq/ops/arithmetic_operation.py +1 -2
- cirq/ops/classically_controlled_operation.py +2 -2
- cirq/ops/clifford_gate.py +1 -1
- cirq/ops/common_channels_test.py +1 -1
- cirq/ops/common_gates.py +2 -2
- cirq/ops/controlled_operation.py +2 -2
- cirq/ops/controlled_operation_test.py +17 -16
- cirq/ops/dense_pauli_string.py +1 -1
- cirq/ops/dense_pauli_string_test.py +41 -37
- cirq/ops/eigen_gate_test.py +0 -7
- cirq/ops/gate_operation.py +11 -3
- cirq/ops/gateset.py +3 -3
- cirq/ops/gateset_test.py +23 -23
- cirq/ops/linear_combinations.py +1 -1
- cirq/ops/linear_combinations_test.py +103 -89
- cirq/ops/matrix_gates_test.py +31 -31
- cirq/ops/measure_util_test.py +11 -10
- cirq/ops/measurement_gate_test.py +23 -22
- cirq/ops/parity_gates.py +1 -2
- cirq/ops/pauli_gates.py +1 -1
- cirq/ops/pauli_measurement_gate_test.py +12 -12
- cirq/ops/pauli_string_phasor_test.py +45 -40
- cirq/ops/pauli_string_raw_types.py +1 -3
- cirq/ops/pauli_string_raw_types_test.py +5 -4
- cirq/ops/pauli_string_test.py +190 -118
- cirq/ops/permutation_gate.py +1 -1
- cirq/ops/raw_types.py +3 -4
- cirq/ops/raw_types_test.py +1 -1
- cirq/ops/three_qubit_gates.py +3 -3
- cirq/protocols/act_on_protocol.py +2 -4
- cirq/protocols/act_on_protocol_test.py +5 -6
- cirq/protocols/apply_channel_protocol.py +1 -2
- cirq/protocols/apply_channel_protocol_test.py +19 -18
- cirq/protocols/apply_mixture_protocol.py +1 -2
- cirq/protocols/apply_mixture_protocol_test.py +20 -19
- cirq/protocols/apply_unitary_protocol.py +1 -2
- cirq/protocols/apply_unitary_protocol_test.py +31 -23
- cirq/protocols/approximate_equality_protocol.py +1 -2
- cirq/protocols/approximate_equality_protocol_test.py +22 -16
- cirq/protocols/circuit_diagram_info_protocol.py +4 -5
- cirq/protocols/commutes_protocol.py +1 -2
- cirq/protocols/commutes_protocol_test.py +4 -4
- cirq/protocols/control_key_protocol.py +1 -3
- cirq/protocols/decompose_protocol.py +1 -2
- cirq/protocols/equal_up_to_global_phase_protocol.py +1 -2
- cirq/protocols/has_unitary_protocol.py +1 -2
- cirq/protocols/json_serialization.py +1 -2
- cirq/protocols/kraus_protocol.py +1 -2
- cirq/protocols/measurement_key_protocol.py +1 -3
- cirq/protocols/mixture_protocol.py +1 -2
- cirq/protocols/pauli_expansion_protocol.py +1 -3
- cirq/protocols/phase_protocol.py +1 -3
- cirq/protocols/qasm.py +1 -3
- cirq/protocols/qid_shape_protocol.py +1 -3
- cirq/protocols/resolve_parameters.py +1 -2
- cirq/protocols/trace_distance_bound.py +1 -2
- cirq/protocols/unitary_protocol.py +1 -2
- cirq/qis/quantum_state_representation.py +1 -2
- cirq/sim/simulation_state.py +1 -2
- cirq/sim/simulation_state_base.py +1 -3
- cirq/study/sweepable.py +1 -3
- cirq/transformers/transformer_api.py +1 -3
- cirq/value/classical_data.py +1 -3
- cirq/value/linear_dict.py +1 -1
- cirq/value/value_equality_attr.py +1 -3
- cirq/work/collector.py +1 -2
- {cirq_core-1.7.0.dev20250819195403.dist-info → cirq_core-1.7.0.dev20250821232720.dist-info}/METADATA +1 -2
- {cirq_core-1.7.0.dev20250819195403.dist-info → cirq_core-1.7.0.dev20250821232720.dist-info}/RECORD +95 -95
- {cirq_core-1.7.0.dev20250819195403.dist-info → cirq_core-1.7.0.dev20250821232720.dist-info}/WHEEL +0 -0
- {cirq_core-1.7.0.dev20250819195403.dist-info → cirq_core-1.7.0.dev20250821232720.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.7.0.dev20250819195403.dist-info → cirq_core-1.7.0.dev20250821232720.dist-info}/top_level.txt +0 -0
cirq/ops/gateset_test.py
CHANGED
|
@@ -56,7 +56,7 @@ q = cirq.NamedQubit("q")
|
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
@pytest.mark.parametrize('gate', [CustomX, CustomXPowGate])
|
|
59
|
-
def test_gate_family_init(gate):
|
|
59
|
+
def test_gate_family_init(gate) -> None:
|
|
60
60
|
name = 'test_name'
|
|
61
61
|
description = 'test_description'
|
|
62
62
|
g = cirq.GateFamily(gate=gate, name=name, description=description)
|
|
@@ -75,7 +75,7 @@ def test_gate_family_init(gate):
|
|
|
75
75
|
(CustomXPowGate, [], []),
|
|
76
76
|
],
|
|
77
77
|
)
|
|
78
|
-
def test_gate_family_default_name_and_description(gate, tags_to_accept, tags_to_ignore):
|
|
78
|
+
def test_gate_family_default_name_and_description(gate, tags_to_accept, tags_to_ignore) -> None:
|
|
79
79
|
g = cirq.GateFamily(gate, tags_to_accept=tags_to_accept, tags_to_ignore=tags_to_ignore)
|
|
80
80
|
assert re.match('.*GateFamily.*CustomX.*', g.name)
|
|
81
81
|
assert re.match('Accepts.*instances.*CustomX.*', g.description)
|
|
@@ -97,7 +97,7 @@ def test_gate_family_default_name_and_description(gate, tags_to_accept, tags_to_
|
|
|
97
97
|
)
|
|
98
98
|
def test_gate_family_equality_with_tags(
|
|
99
99
|
tags_to_accept_fam1, tags_to_ignore_fam1, tags_to_accept_fam2, tags_to_ignore_fam2
|
|
100
|
-
):
|
|
100
|
+
) -> None:
|
|
101
101
|
gate_fam1 = cirq.GateFamily(
|
|
102
102
|
cirq.X, tags_to_accept=tags_to_accept_fam1, tags_to_ignore=tags_to_ignore_fam1
|
|
103
103
|
)
|
|
@@ -108,9 +108,9 @@ def test_gate_family_equality_with_tags(
|
|
|
108
108
|
assert gate_fam1 == gate_fam2
|
|
109
109
|
|
|
110
110
|
|
|
111
|
-
def test_invalid_gate_family():
|
|
111
|
+
def test_invalid_gate_family() -> None:
|
|
112
112
|
with pytest.raises(ValueError, match='instance or subclass of `cirq.Gate`'):
|
|
113
|
-
_ = cirq.GateFamily(gate=cirq.Operation)
|
|
113
|
+
_ = cirq.GateFamily(gate=cirq.Operation) # type: ignore[arg-type]
|
|
114
114
|
|
|
115
115
|
with pytest.raises(ValueError, match='non-parameterized instance of `cirq.Gate`'):
|
|
116
116
|
_ = cirq.GateFamily(gate=CustomX ** sympy.Symbol('theta'))
|
|
@@ -119,31 +119,31 @@ def test_invalid_gate_family():
|
|
|
119
119
|
_ = cirq.GateFamily(gate=cirq.H, tags_to_accept={'a', 'b'}, tags_to_ignore={'b', 'c'})
|
|
120
120
|
|
|
121
121
|
|
|
122
|
-
def test_gate_family_immutable():
|
|
122
|
+
def test_gate_family_immutable() -> None:
|
|
123
123
|
g = cirq.GateFamily(CustomX)
|
|
124
124
|
# Match one of two strings. The second one is message returned since python 3.11.
|
|
125
125
|
with pytest.raises(
|
|
126
126
|
AttributeError,
|
|
127
127
|
match="(can't set attribute)|(property 'gate' of 'GateFamily' object has no setter)",
|
|
128
128
|
):
|
|
129
|
-
g.gate = CustomXPowGate
|
|
129
|
+
g.gate = CustomXPowGate # type: ignore[misc]
|
|
130
130
|
with pytest.raises(
|
|
131
131
|
AttributeError,
|
|
132
132
|
match="(can't set attribute)|(property 'name' of 'GateFamily' object has no setter)",
|
|
133
133
|
):
|
|
134
|
-
g.name = 'new name'
|
|
134
|
+
g.name = 'new name' # type: ignore[misc]
|
|
135
135
|
with pytest.raises(
|
|
136
136
|
AttributeError,
|
|
137
137
|
match="(can't set attribute)|(property 'description' of 'GateFamily' object has no setter)",
|
|
138
138
|
):
|
|
139
|
-
g.description = 'new description'
|
|
139
|
+
g.description = 'new description' # type: ignore[misc]
|
|
140
140
|
|
|
141
141
|
|
|
142
142
|
@pytest.mark.parametrize(
|
|
143
143
|
'gate', [CustomX, CustomXPowGate(exponent=0.5, global_shift=0.1), CustomXPowGate]
|
|
144
144
|
)
|
|
145
145
|
@pytest.mark.parametrize('name, description', [(None, None), ('custom_name', 'custom_description')])
|
|
146
|
-
def test_gate_family_repr_and_str(gate, name, description):
|
|
146
|
+
def test_gate_family_repr_and_str(gate, name, description) -> None:
|
|
147
147
|
g = cirq.GateFamily(gate, name=name, description=description)
|
|
148
148
|
cirq.testing.assert_equivalent_repr(g)
|
|
149
149
|
assert g.name in str(g)
|
|
@@ -152,13 +152,13 @@ def test_gate_family_repr_and_str(gate, name, description):
|
|
|
152
152
|
|
|
153
153
|
@pytest.mark.parametrize('gate', [cirq.X, cirq.XPowGate(), cirq.XPowGate])
|
|
154
154
|
@pytest.mark.parametrize('name, description', [(None, None), ('custom_name', 'custom_description')])
|
|
155
|
-
def test_gate_family_json(gate, name, description):
|
|
155
|
+
def test_gate_family_json(gate, name, description) -> None:
|
|
156
156
|
g = cirq.GateFamily(gate, name=name, description=description)
|
|
157
157
|
g_json = cirq.to_json(g)
|
|
158
158
|
assert cirq.read_json(json_text=g_json) == g
|
|
159
159
|
|
|
160
160
|
|
|
161
|
-
def test_gate_family_eq():
|
|
161
|
+
def test_gate_family_eq() -> None:
|
|
162
162
|
eq = cirq.testing.EqualsTester()
|
|
163
163
|
eq.add_equality_group(cirq.GateFamily(CustomX))
|
|
164
164
|
eq.add_equality_group(cirq.GateFamily(CustomX**3))
|
|
@@ -206,7 +206,7 @@ def test_gate_family_eq():
|
|
|
206
206
|
),
|
|
207
207
|
],
|
|
208
208
|
)
|
|
209
|
-
def test_gate_family_predicate_and_containment(gate_family, gates_to_check):
|
|
209
|
+
def test_gate_family_predicate_and_containment(gate_family, gates_to_check) -> None:
|
|
210
210
|
for gate, result in gates_to_check:
|
|
211
211
|
assert gate_family._predicate(gate) == result
|
|
212
212
|
assert (gate in gate_family) == result
|
|
@@ -265,7 +265,7 @@ def test_gate_family_predicate_and_containment(gate_family, gates_to_check):
|
|
|
265
265
|
),
|
|
266
266
|
],
|
|
267
267
|
)
|
|
268
|
-
def test_gate_family_tagged_operations(gate_family, gates_to_check):
|
|
268
|
+
def test_gate_family_tagged_operations(gate_family, gates_to_check) -> None:
|
|
269
269
|
for gate, result in gates_to_check:
|
|
270
270
|
assert (gate in gate_family) == result
|
|
271
271
|
|
|
@@ -296,7 +296,7 @@ gateset = cirq.Gateset(
|
|
|
296
296
|
)
|
|
297
297
|
|
|
298
298
|
|
|
299
|
-
def test_gateset_init():
|
|
299
|
+
def test_gateset_init() -> None:
|
|
300
300
|
assert gateset.name == 'custom gateset'
|
|
301
301
|
assert gateset.gates == frozenset(
|
|
302
302
|
[
|
|
@@ -308,7 +308,7 @@ def test_gateset_init():
|
|
|
308
308
|
|
|
309
309
|
|
|
310
310
|
@pytest.mark.parametrize('g', [gateset, cirq.Gateset(name='empty gateset')])
|
|
311
|
-
def test_gateset_repr_and_str(g):
|
|
311
|
+
def test_gateset_repr_and_str(g) -> None:
|
|
312
312
|
cirq.testing.assert_equivalent_repr(g)
|
|
313
313
|
assert g.name in str(g)
|
|
314
314
|
for gate_family in g.gates:
|
|
@@ -328,7 +328,7 @@ def test_gateset_repr_and_str(g):
|
|
|
328
328
|
(cirq.testing.TwoQubitGate(), True),
|
|
329
329
|
],
|
|
330
330
|
)
|
|
331
|
-
def test_gateset_contains(gate, result):
|
|
331
|
+
def test_gateset_contains(gate, result) -> None:
|
|
332
332
|
assert (gate in gateset) is result
|
|
333
333
|
op = gate(*cirq.LineQubit.range(gate.num_qubits()))
|
|
334
334
|
assert (op in gateset) is result
|
|
@@ -339,7 +339,7 @@ def test_gateset_contains(gate, result):
|
|
|
339
339
|
|
|
340
340
|
|
|
341
341
|
@pytest.mark.parametrize('use_circuit_op', [True, False])
|
|
342
|
-
def test_gateset_validate(use_circuit_op):
|
|
342
|
+
def test_gateset_validate(use_circuit_op) -> None:
|
|
343
343
|
def optree_and_circuit(optree):
|
|
344
344
|
yield optree
|
|
345
345
|
yield cirq.Circuit(optree)
|
|
@@ -374,14 +374,14 @@ def test_gateset_validate(use_circuit_op):
|
|
|
374
374
|
)
|
|
375
375
|
|
|
376
376
|
|
|
377
|
-
def test_gateset_validate_circuit_op_negative_reps():
|
|
377
|
+
def test_gateset_validate_circuit_op_negative_reps() -> None:
|
|
378
378
|
gate = CustomXPowGate(exponent=0.5)
|
|
379
379
|
op = cirq.CircuitOperation(cirq.FrozenCircuit(gate.on(cirq.LineQubit(0))), repetitions=-1)
|
|
380
380
|
assert op not in cirq.Gateset(gate)
|
|
381
381
|
assert op**-1 in cirq.Gateset(gate)
|
|
382
382
|
|
|
383
383
|
|
|
384
|
-
def test_with_params():
|
|
384
|
+
def test_with_params() -> None:
|
|
385
385
|
assert gateset.with_params() is gateset
|
|
386
386
|
assert (
|
|
387
387
|
gateset.with_params(name=gateset.name, unroll_circuit_op=gateset._unroll_circuit_op)
|
|
@@ -392,7 +392,7 @@ def test_with_params():
|
|
|
392
392
|
assert gateset_with_params._unroll_circuit_op is False
|
|
393
393
|
|
|
394
394
|
|
|
395
|
-
def test_gateset_eq():
|
|
395
|
+
def test_gateset_eq() -> None:
|
|
396
396
|
eq = cirq.testing.EqualsTester()
|
|
397
397
|
eq.add_equality_group(cirq.Gateset(CustomX))
|
|
398
398
|
eq.add_equality_group(cirq.Gateset(CustomX**3))
|
|
@@ -427,7 +427,7 @@ def test_gateset_eq():
|
|
|
427
427
|
)
|
|
428
428
|
|
|
429
429
|
|
|
430
|
-
def test_gateset_contains_with_tags():
|
|
430
|
+
def test_gateset_contains_with_tags() -> None:
|
|
431
431
|
tag = "PhysicalZTag"
|
|
432
432
|
gf_accept = cirq.GateFamily(cirq.ZPowGate, tags_to_accept=[tag])
|
|
433
433
|
gf_ignore = cirq.GateFamily(cirq.ZPowGate, tags_to_ignore=[tag])
|
|
@@ -447,7 +447,7 @@ def test_gateset_contains_with_tags():
|
|
|
447
447
|
assert op_with_tag in cirq.Gateset(gf_accept, gf_ignore)
|
|
448
448
|
|
|
449
449
|
|
|
450
|
-
def test_gateset_contains_op_with_no_gate():
|
|
450
|
+
def test_gateset_contains_op_with_no_gate() -> None:
|
|
451
451
|
gf = cirq.GateFamily(cirq.ZPowGate)
|
|
452
452
|
op = cirq.X(cirq.q(1)).with_classical_controls('a')
|
|
453
453
|
assert op.gate is None
|
cirq/ops/linear_combinations.py
CHANGED
|
@@ -473,7 +473,7 @@ class PauliSum:
|
|
|
473
473
|
|
|
474
474
|
@classmethod
|
|
475
475
|
def from_boolean_expression(
|
|
476
|
-
cls, boolean_expr: sympy.Expr, qubit_map:
|
|
476
|
+
cls, boolean_expr: sympy.Expr, qubit_map: Mapping[str, cirq.Qid]
|
|
477
477
|
) -> PauliSum:
|
|
478
478
|
"""Builds the Hamiltonian representation of a Boolean expression.
|
|
479
479
|
|