cirq-core 1.6.0.dev20250520234959__py3-none-any.whl → 1.6.0.dev20250521215048__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_operation_test.py +1 -2
- cirq/contrib/acquaintance/devices.py +2 -2
- cirq/contrib/acquaintance/inspection_utils.py +2 -2
- cirq/contrib/qasm_import/_lexer.py +1 -2
- cirq/contrib/routing/router.py +3 -3
- cirq/devices/device.py +4 -4
- cirq/experiments/fidelity_estimation.py +4 -4
- cirq/experiments/t1_decay_experiment.py +2 -2
- cirq/experiments/xeb_fitting.py +1 -1
- cirq/interop/quirk/cells/measurement_cells.py +2 -2
- cirq/linalg/combinators.py +3 -3
- cirq/linalg/predicates.py +2 -2
- cirq/linalg/tolerance.py +2 -2
- cirq/ops/arithmetic_operation_test.py +2 -4
- cirq/ops/common_gate_families.py +7 -7
- cirq/ops/controlled_gate.py +11 -0
- cirq/ops/controlled_gate_test.py +36 -2
- cirq/ops/controlled_operation_test.py +2 -2
- cirq/ops/linear_combinations_test.py +8 -9
- cirq/ops/qid_util.py +2 -2
- cirq/ops/qubit_order_or_list.py +2 -2
- cirq/protocols/act_on_protocol.py +4 -4
- cirq/protocols/commutes_protocol.py +5 -7
- cirq/protocols/control_key_protocol.py +4 -4
- cirq/protocols/decompose_protocol_test.py +1 -2
- cirq/protocols/has_stabilizer_effect_protocol.py +5 -5
- cirq/protocols/has_unitary_protocol.py +5 -5
- cirq/protocols/pauli_expansion_protocol.py +3 -3
- cirq/protocols/pow_protocol.py +5 -5
- cirq/protocols/trace_distance_bound.py +4 -4
- cirq/protocols/unitary_protocol.py +7 -7
- cirq/protocols/unitary_protocol_test.py +1 -3
- cirq/qis/entropy.py +2 -2
- cirq/sim/clifford/clifford_tableau_simulation_state.py +4 -4
- cirq/sim/clifford/stabilizer_ch_form_simulation_state.py +5 -5
- cirq/sim/clifford/stabilizer_simulation_state.py +5 -5
- cirq/sim/density_matrix_simulator_test.py +45 -46
- cirq/sim/sparse_simulator_test.py +38 -39
- cirq/sim/state_vector_simulation_state_test.py +2 -2
- cirq/sim/state_vector_test.py +3 -3
- cirq/study/sweepable.py +5 -5
- cirq/testing/consistent_act_on.py +5 -7
- cirq/testing/consistent_controlled_gate_op.py +3 -5
- cirq/testing/deprecation.py +2 -2
- cirq/testing/lin_alg_utils.py +2 -2
- cirq/transformers/align.py +3 -3
- cirq/transformers/drop_empty_moments.py +2 -2
- cirq/transformers/drop_negligible_operations.py +2 -2
- cirq/transformers/expand_composite.py +2 -2
- cirq/transformers/heuristic_decompositions/gate_tabulation_math_utils.py +3 -3
- cirq/transformers/merge_k_qubit_gates.py +5 -5
- cirq/transformers/merge_single_qubit_gates.py +5 -5
- cirq/transformers/optimize_for_target_gateset.py +6 -6
- cirq/transformers/optimize_for_target_gateset_test.py +3 -3
- cirq/transformers/tag_transformers.py +5 -5
- cirq/transformers/target_gatesets/cz_gateset_test.py +2 -2
- cirq/transformers/target_gatesets/sqrt_iswap_gateset_test.py +1 -3
- cirq/transformers/transformer_api_test.py +7 -8
- cirq/value/abc_alt.py +2 -2
- cirq/value/abc_alt_test.py +3 -3
- cirq/value/angle.py +7 -7
- cirq/value/type_alias.py +3 -5
- cirq/vis/density_matrix.py +2 -4
- cirq/vis/histogram.py +6 -6
- cirq/vis/state_histogram.py +7 -7
- cirq/work/observable_readout_calibration.py +2 -2
- {cirq_core-1.6.0.dev20250520234959.dist-info → cirq_core-1.6.0.dev20250521215048.dist-info}/METADATA +1 -1
- {cirq_core-1.6.0.dev20250520234959.dist-info → cirq_core-1.6.0.dev20250521215048.dist-info}/RECORD +73 -73
- {cirq_core-1.6.0.dev20250520234959.dist-info → cirq_core-1.6.0.dev20250521215048.dist-info}/WHEEL +0 -0
- {cirq_core-1.6.0.dev20250520234959.dist-info → cirq_core-1.6.0.dev20250521215048.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.6.0.dev20250520234959.dist-info → cirq_core-1.6.0.dev20250521215048.dist-info}/top_level.txt +0 -0
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
|
-
from typing import
|
|
19
|
+
from typing import TYPE_CHECKING
|
|
20
20
|
|
|
21
21
|
from cirq import circuits, ops, protocols
|
|
22
22
|
from cirq.transformers import merge_k_qubit_gates, transformer_api, transformer_primitives
|
|
@@ -30,7 +30,7 @@ if TYPE_CHECKING:
|
|
|
30
30
|
def merge_single_qubit_gates_to_phased_x_and_z(
|
|
31
31
|
circuit: cirq.AbstractCircuit,
|
|
32
32
|
*,
|
|
33
|
-
context:
|
|
33
|
+
context: cirq.TransformerContext | None = None,
|
|
34
34
|
atol: float = 1e-8,
|
|
35
35
|
) -> cirq.Circuit:
|
|
36
36
|
"""Replaces runs of single qubit rotations with `cirq.PhasedXPowGate` and `cirq.ZPowGate`.
|
|
@@ -66,7 +66,7 @@ def merge_single_qubit_gates_to_phased_x_and_z(
|
|
|
66
66
|
def merge_single_qubit_gates_to_phxz(
|
|
67
67
|
circuit: cirq.AbstractCircuit,
|
|
68
68
|
*,
|
|
69
|
-
context:
|
|
69
|
+
context: cirq.TransformerContext | None = None,
|
|
70
70
|
atol: float = 1e-8,
|
|
71
71
|
) -> cirq.Circuit:
|
|
72
72
|
"""Replaces runs of single qubit rotations with a single optional `cirq.PhasedXZGate`.
|
|
@@ -100,7 +100,7 @@ def merge_single_qubit_gates_to_phxz(
|
|
|
100
100
|
def merge_single_qubit_moments_to_phxz(
|
|
101
101
|
circuit: cirq.AbstractCircuit,
|
|
102
102
|
*,
|
|
103
|
-
context:
|
|
103
|
+
context: cirq.TransformerContext | None = None,
|
|
104
104
|
atol: float = 1e-8,
|
|
105
105
|
) -> cirq.Circuit:
|
|
106
106
|
"""Merges adjacent moments with only 1-qubit rotations to a single moment with PhasedXZ gates.
|
|
@@ -124,7 +124,7 @@ def merge_single_qubit_moments_to_phxz(
|
|
|
124
124
|
for op in m
|
|
125
125
|
)
|
|
126
126
|
|
|
127
|
-
def merge_func(m1: cirq.Moment, m2: cirq.Moment) ->
|
|
127
|
+
def merge_func(m1: cirq.Moment, m2: cirq.Moment) -> cirq.Moment | None:
|
|
128
128
|
if not (can_merge_moment(m1) and can_merge_moment(m2)):
|
|
129
129
|
return None
|
|
130
130
|
ret_ops = []
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
|
-
from typing import Callable, Hashable,
|
|
19
|
+
from typing import Callable, Hashable, Sequence, TYPE_CHECKING
|
|
20
20
|
|
|
21
21
|
from cirq import circuits
|
|
22
22
|
from cirq.protocols import decompose_protocol as dp
|
|
@@ -37,8 +37,8 @@ def _create_on_stuck_raise_error(gateset: cirq.Gateset):
|
|
|
37
37
|
def _decompose_operations_to_target_gateset(
|
|
38
38
|
circuit: cirq.AbstractCircuit,
|
|
39
39
|
*,
|
|
40
|
-
context:
|
|
41
|
-
gateset:
|
|
40
|
+
context: cirq.TransformerContext | None = None,
|
|
41
|
+
gateset: cirq.Gateset | None = None,
|
|
42
42
|
decomposer: Callable[[cirq.Operation, int], dp.DecomposeResult] = lambda *_: NotImplemented,
|
|
43
43
|
ignore_failures: bool = True,
|
|
44
44
|
tags_to_decompose: Sequence[Hashable] = (),
|
|
@@ -101,10 +101,10 @@ def _decompose_operations_to_target_gateset(
|
|
|
101
101
|
def optimize_for_target_gateset(
|
|
102
102
|
circuit: cirq.AbstractCircuit,
|
|
103
103
|
*,
|
|
104
|
-
context:
|
|
105
|
-
gateset:
|
|
104
|
+
context: cirq.TransformerContext | None = None,
|
|
105
|
+
gateset: cirq.CompilationTargetGateset | None = None,
|
|
106
106
|
ignore_failures: bool = True,
|
|
107
|
-
max_num_passes:
|
|
107
|
+
max_num_passes: int | None = 1,
|
|
108
108
|
) -> cirq.Circuit:
|
|
109
109
|
"""Transforms the given circuit into an equivalent circuit using gates accepted by `gateset`.
|
|
110
110
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from typing import TYPE_CHECKING
|
|
17
|
+
from typing import TYPE_CHECKING
|
|
18
18
|
|
|
19
19
|
import pytest
|
|
20
20
|
|
|
@@ -253,7 +253,7 @@ def test_optimize_for_target_gateset_deep():
|
|
|
253
253
|
|
|
254
254
|
|
|
255
255
|
@pytest.mark.parametrize('max_num_passes', [2, None])
|
|
256
|
-
def test_optimize_for_target_gateset_multiple_passes(max_num_passes:
|
|
256
|
+
def test_optimize_for_target_gateset_multiple_passes(max_num_passes: int | None):
|
|
257
257
|
gateset = cirq.CZTargetGateset()
|
|
258
258
|
|
|
259
259
|
input_circuit = cirq.Circuit(
|
|
@@ -332,7 +332,7 @@ def test_optimize_for_target_gateset_multiple_passes(max_num_passes: Union[int,
|
|
|
332
332
|
|
|
333
333
|
@pytest.mark.parametrize('max_num_passes', [2, None])
|
|
334
334
|
def test_optimize_for_target_gateset_multiple_passes_dont_preserve_moment_structure(
|
|
335
|
-
max_num_passes:
|
|
335
|
+
max_num_passes: int | None,
|
|
336
336
|
):
|
|
337
337
|
gateset = cirq.CZTargetGateset(preserve_moment_structure=False)
|
|
338
338
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
import itertools
|
|
18
|
-
from typing import Callable, Hashable,
|
|
18
|
+
from typing import Callable, Hashable, TYPE_CHECKING
|
|
19
19
|
|
|
20
20
|
from cirq.transformers import transformer_api, transformer_primitives
|
|
21
21
|
|
|
@@ -27,8 +27,8 @@ if TYPE_CHECKING:
|
|
|
27
27
|
def index_tags(
|
|
28
28
|
circuit: cirq.AbstractCircuit,
|
|
29
29
|
*,
|
|
30
|
-
context:
|
|
31
|
-
target_tags:
|
|
30
|
+
context: cirq.TransformerContext | None = None,
|
|
31
|
+
target_tags: set[Hashable] | None = None,
|
|
32
32
|
) -> cirq.Circuit:
|
|
33
33
|
"""Indexes tags in target_tags as tag_0, tag_1, ... per tag.
|
|
34
34
|
|
|
@@ -64,8 +64,8 @@ def index_tags(
|
|
|
64
64
|
def remove_tags(
|
|
65
65
|
circuit: cirq.AbstractCircuit,
|
|
66
66
|
*,
|
|
67
|
-
context:
|
|
68
|
-
target_tags:
|
|
67
|
+
context: cirq.TransformerContext | None = None,
|
|
68
|
+
target_tags: set[Hashable] | None = None,
|
|
69
69
|
remove_if: Callable[[Hashable], bool] = lambda _: False,
|
|
70
70
|
) -> cirq.Circuit:
|
|
71
71
|
"""Removes tags from the operations based on the input args.
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from typing import
|
|
17
|
+
from typing import Sequence
|
|
18
18
|
|
|
19
19
|
import numpy as np
|
|
20
20
|
import pytest
|
|
@@ -33,7 +33,7 @@ def all_gates_of_type(m: cirq.Moment, g: cirq.Gateset):
|
|
|
33
33
|
def assert_optimizes(
|
|
34
34
|
before: cirq.Circuit,
|
|
35
35
|
expected: cirq.Circuit,
|
|
36
|
-
additional_gates:
|
|
36
|
+
additional_gates: Sequence[type[cirq.Gate]] | None = None,
|
|
37
37
|
):
|
|
38
38
|
if additional_gates is None:
|
|
39
39
|
gateset = cirq.CZTargetGateset()
|
|
@@ -14,8 +14,6 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from typing import Optional
|
|
18
|
-
|
|
19
17
|
import numpy as np
|
|
20
18
|
import pytest
|
|
21
19
|
import sympy
|
|
@@ -40,7 +38,7 @@ def assert_optimizes(before: cirq.Circuit, expected: cirq.Circuit, **kwargs):
|
|
|
40
38
|
|
|
41
39
|
|
|
42
40
|
def assert_optimization_not_broken(
|
|
43
|
-
circuit: cirq.Circuit, required_sqrt_iswap_count:
|
|
41
|
+
circuit: cirq.Circuit, required_sqrt_iswap_count: int | None = None
|
|
44
42
|
):
|
|
45
43
|
c_new = cirq.optimize_for_target_gateset(
|
|
46
44
|
circuit,
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from typing import Optional
|
|
18
17
|
from unittest import mock
|
|
19
18
|
|
|
20
19
|
import pytest
|
|
@@ -29,7 +28,7 @@ class MockTransformerClass:
|
|
|
29
28
|
self.mock = mock.Mock()
|
|
30
29
|
|
|
31
30
|
def __call__(
|
|
32
|
-
self, circuit: cirq.AbstractCircuit, *, context:
|
|
31
|
+
self, circuit: cirq.AbstractCircuit, *, context: cirq.TransformerContext | None = None
|
|
33
32
|
) -> cirq.Circuit:
|
|
34
33
|
self.mock(circuit, context)
|
|
35
34
|
return circuit.unfreeze()
|
|
@@ -53,7 +52,7 @@ class MockTransformerClassWithDefaults:
|
|
|
53
52
|
self,
|
|
54
53
|
circuit: cirq.AbstractCircuit,
|
|
55
54
|
*,
|
|
56
|
-
context:
|
|
55
|
+
context: cirq.TransformerContext | None = cirq.TransformerContext(),
|
|
57
56
|
atol: float = 1e-4,
|
|
58
57
|
custom_arg: CustomArg = CustomArg(),
|
|
59
58
|
) -> cirq.AbstractCircuit:
|
|
@@ -73,7 +72,7 @@ def make_transformer_func_with_defaults() -> cirq.TRANSFORMER:
|
|
|
73
72
|
def func(
|
|
74
73
|
circuit: cirq.AbstractCircuit,
|
|
75
74
|
*,
|
|
76
|
-
context:
|
|
75
|
+
context: cirq.TransformerContext | None = cirq.TransformerContext(),
|
|
77
76
|
atol: float = 1e-4,
|
|
78
77
|
custom_arg: CustomArg = CustomArg(),
|
|
79
78
|
) -> cirq.FrozenCircuit:
|
|
@@ -89,7 +88,7 @@ def make_transformer_func(add_deep_support: bool = False) -> cirq.TRANSFORMER:
|
|
|
89
88
|
|
|
90
89
|
@cirq.transformer(add_deep_support=add_deep_support)
|
|
91
90
|
def mock_tranformer_func(
|
|
92
|
-
circuit: cirq.AbstractCircuit, *, context:
|
|
91
|
+
circuit: cirq.AbstractCircuit, *, context: cirq.TransformerContext | None = None
|
|
93
92
|
) -> cirq.Circuit:
|
|
94
93
|
my_mock(circuit, context)
|
|
95
94
|
return circuit.unfreeze()
|
|
@@ -179,7 +178,7 @@ def test_transformer_decorator_adds_support_for_deep(transformer, supports_deep)
|
|
|
179
178
|
@cirq.transformer
|
|
180
179
|
class T1:
|
|
181
180
|
def __call__(
|
|
182
|
-
self, circuit: cirq.AbstractCircuit, context:
|
|
181
|
+
self, circuit: cirq.AbstractCircuit, context: cirq.TransformerContext | None = None
|
|
183
182
|
) -> cirq.AbstractCircuit:
|
|
184
183
|
assert context is not None
|
|
185
184
|
context.logger.log("First Verbose Log", "of T1", level=LogLevel.DEBUG)
|
|
@@ -193,7 +192,7 @@ t1 = T1()
|
|
|
193
192
|
|
|
194
193
|
@cirq.transformer
|
|
195
194
|
def t2(
|
|
196
|
-
circuit: cirq.AbstractCircuit, context:
|
|
195
|
+
circuit: cirq.AbstractCircuit, context: cirq.TransformerContext | None = None
|
|
197
196
|
) -> cirq.FrozenCircuit:
|
|
198
197
|
assert context is not None
|
|
199
198
|
context.logger.log("First INFO Log", "of T2 Start")
|
|
@@ -204,7 +203,7 @@ def t2(
|
|
|
204
203
|
|
|
205
204
|
@cirq.transformer
|
|
206
205
|
def t3(
|
|
207
|
-
circuit: cirq.AbstractCircuit, context:
|
|
206
|
+
circuit: cirq.AbstractCircuit, context: cirq.TransformerContext | None = None
|
|
208
207
|
) -> cirq.Circuit:
|
|
209
208
|
assert context is not None
|
|
210
209
|
context.logger.log("First INFO Log", "of T3 Start")
|
cirq/value/abc_alt.py
CHANGED
|
@@ -18,7 +18,7 @@ from __future__ import annotations
|
|
|
18
18
|
|
|
19
19
|
import abc
|
|
20
20
|
import functools
|
|
21
|
-
from typing import Callable, cast,
|
|
21
|
+
from typing import Callable, cast, TypeVar
|
|
22
22
|
|
|
23
23
|
T = TypeVar('T')
|
|
24
24
|
|
|
@@ -103,7 +103,7 @@ class ABCMetaImplementAnyOneOf(abc.ABCMeta):
|
|
|
103
103
|
return False
|
|
104
104
|
return True
|
|
105
105
|
|
|
106
|
-
def find_next_implementations(all_names:
|
|
106
|
+
def find_next_implementations(all_names: set[str]) -> bool:
|
|
107
107
|
next_implemented_by = {}
|
|
108
108
|
for name in all_names:
|
|
109
109
|
if has_some_implementation(name):
|
cirq/value/abc_alt_test.py
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
import abc
|
|
18
|
-
from typing import NoReturn
|
|
18
|
+
from typing import NoReturn
|
|
19
19
|
|
|
20
20
|
import pytest
|
|
21
21
|
|
|
@@ -160,11 +160,11 @@ def test_two_alternatives():
|
|
|
160
160
|
raise NotImplementedError
|
|
161
161
|
|
|
162
162
|
@abc.abstractmethod
|
|
163
|
-
def alt1(self) ->
|
|
163
|
+
def alt1(self) -> str | None:
|
|
164
164
|
pass
|
|
165
165
|
|
|
166
166
|
@abc.abstractmethod
|
|
167
|
-
def alt2(self) ->
|
|
167
|
+
def alt2(self) -> str | None:
|
|
168
168
|
pass
|
|
169
169
|
|
|
170
170
|
class TwoAlternativesChild(TwoAlternatives):
|
cirq/value/angle.py
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from typing import
|
|
17
|
+
from typing import overload, TYPE_CHECKING
|
|
18
18
|
|
|
19
19
|
import numpy as np
|
|
20
20
|
import sympy
|
|
@@ -24,9 +24,9 @@ if TYPE_CHECKING:
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
def chosen_angle_to_half_turns(
|
|
27
|
-
half_turns:
|
|
28
|
-
rads:
|
|
29
|
-
degs:
|
|
27
|
+
half_turns: type_alias.TParamVal | None = None,
|
|
28
|
+
rads: float | None = None,
|
|
29
|
+
degs: float | None = None,
|
|
30
30
|
default: float = 1.0,
|
|
31
31
|
) -> type_alias.TParamVal:
|
|
32
32
|
"""Returns a half_turns value based on the given arguments.
|
|
@@ -63,9 +63,9 @@ def chosen_angle_to_half_turns(
|
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
def chosen_angle_to_canonical_half_turns(
|
|
66
|
-
half_turns:
|
|
67
|
-
rads:
|
|
68
|
-
degs:
|
|
66
|
+
half_turns: type_alias.TParamVal | None = None,
|
|
67
|
+
rads: float | None = None,
|
|
68
|
+
degs: float | None = None,
|
|
69
69
|
default: float = 1.0,
|
|
70
70
|
) -> type_alias.TParamVal:
|
|
71
71
|
"""Returns a canonicalized half_turns based on the given arguments.
|
cirq/value/type_alias.py
CHANGED
|
@@ -14,8 +14,6 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from typing import Union
|
|
18
|
-
|
|
19
17
|
import numpy as np
|
|
20
18
|
import sympy
|
|
21
19
|
|
|
@@ -24,11 +22,11 @@ from cirq._doc import document
|
|
|
24
22
|
"""Supply aliases for commonly used types.
|
|
25
23
|
"""
|
|
26
24
|
|
|
27
|
-
TParamKey =
|
|
25
|
+
TParamKey = str | sympy.Expr
|
|
28
26
|
document(TParamKey, """A parameter that a parameter resolver may map to a value.""")
|
|
29
27
|
|
|
30
|
-
TParamVal =
|
|
28
|
+
TParamVal = float | sympy.Expr
|
|
31
29
|
document(TParamVal, """A value that a parameter resolver may return for a parameter.""")
|
|
32
30
|
|
|
33
|
-
TParamValComplex =
|
|
31
|
+
TParamValComplex = complex | np.number | sympy.Expr
|
|
34
32
|
document(TParamValComplex, """A complex value that parameter resolvers may use for parameters.""")
|
cirq/vis/density_matrix.py
CHANGED
|
@@ -16,8 +16,6 @@
|
|
|
16
16
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
|
-
from typing import Optional
|
|
20
|
-
|
|
21
19
|
import matplotlib.pyplot as plt
|
|
22
20
|
import numpy as np
|
|
23
21
|
from matplotlib import lines, patches
|
|
@@ -81,10 +79,10 @@ def _plot_element_of_density_matrix(ax, x, y, r, phase, show_rect=False, show_te
|
|
|
81
79
|
|
|
82
80
|
def plot_density_matrix(
|
|
83
81
|
matrix: np.ndarray,
|
|
84
|
-
ax:
|
|
82
|
+
ax: plt.Axes | None = None,
|
|
85
83
|
*,
|
|
86
84
|
show_text: bool = False,
|
|
87
|
-
title:
|
|
85
|
+
title: str | None = None,
|
|
88
86
|
) -> plt.Axes:
|
|
89
87
|
"""Generates a plot for a given density matrix.
|
|
90
88
|
|
cirq/vis/histogram.py
CHANGED
|
@@ -14,25 +14,25 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from typing import Any, Mapping,
|
|
17
|
+
from typing import Any, Mapping, Sequence, SupportsFloat
|
|
18
18
|
|
|
19
19
|
import numpy as np
|
|
20
20
|
from matplotlib import pyplot as plt
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
def integrated_histogram(
|
|
24
|
-
data:
|
|
25
|
-
ax:
|
|
24
|
+
data: Sequence[SupportsFloat] | Mapping[Any, SupportsFloat],
|
|
25
|
+
ax: plt.Axes | None = None,
|
|
26
26
|
*,
|
|
27
27
|
cdf_on_x: bool = False,
|
|
28
28
|
axis_label: str = '',
|
|
29
29
|
semilog: bool = True,
|
|
30
30
|
median_line: bool = True,
|
|
31
|
-
median_label:
|
|
31
|
+
median_label: str | None = 'median',
|
|
32
32
|
mean_line: bool = False,
|
|
33
|
-
mean_label:
|
|
33
|
+
mean_label: str | None = 'mean',
|
|
34
34
|
show_zero: bool = False,
|
|
35
|
-
title:
|
|
35
|
+
title: str | None = None,
|
|
36
36
|
**kwargs,
|
|
37
37
|
) -> plt.Axes:
|
|
38
38
|
"""Plot the integrated histogram for an array of data.
|
cirq/vis/state_histogram.py
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
19
|
import collections
|
|
20
|
-
from typing import
|
|
20
|
+
from typing import Sequence, SupportsFloat
|
|
21
21
|
|
|
22
22
|
import matplotlib.pyplot as plt
|
|
23
23
|
import numpy as np
|
|
@@ -54,13 +54,13 @@ def get_state_histogram(result: result.Result) -> np.ndarray:
|
|
|
54
54
|
|
|
55
55
|
|
|
56
56
|
def plot_state_histogram(
|
|
57
|
-
data:
|
|
58
|
-
ax:
|
|
57
|
+
data: result.Result | collections.Counter | Sequence[SupportsFloat],
|
|
58
|
+
ax: plt.Axes | None = None,
|
|
59
59
|
*,
|
|
60
|
-
tick_label:
|
|
61
|
-
xlabel:
|
|
62
|
-
ylabel:
|
|
63
|
-
title:
|
|
60
|
+
tick_label: Sequence[str] | None = None,
|
|
61
|
+
xlabel: str | None = 'qubit state',
|
|
62
|
+
ylabel: str | None = 'result count',
|
|
63
|
+
title: str | None = 'Result State Histogram',
|
|
64
64
|
) -> plt.Axes:
|
|
65
65
|
"""Plot the state histogram from either a single result with repetitions or
|
|
66
66
|
a histogram computed using `result.histogram()` or a flattened histogram
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import dataclasses
|
|
6
|
-
from typing import Iterable, TYPE_CHECKING
|
|
6
|
+
from typing import Iterable, TYPE_CHECKING
|
|
7
7
|
|
|
8
8
|
from cirq import circuits, ops, study
|
|
9
9
|
from cirq.work.observable_measurement import measure_grouped_settings, StoppingCriteria
|
|
@@ -15,7 +15,7 @@ if TYPE_CHECKING:
|
|
|
15
15
|
|
|
16
16
|
def calibrate_readout_error(
|
|
17
17
|
qubits: Iterable[ops.Qid],
|
|
18
|
-
sampler:
|
|
18
|
+
sampler: cirq.Simulator | cirq.Sampler,
|
|
19
19
|
stopping_criteria: StoppingCriteria,
|
|
20
20
|
):
|
|
21
21
|
# We know there won't be any fancy sweeps or observables so we can
|
{cirq_core-1.6.0.dev20250520234959.dist-info → cirq_core-1.6.0.dev20250521215048.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cirq-core
|
|
3
|
-
Version: 1.6.0.
|
|
3
|
+
Version: 1.6.0.dev20250521215048
|
|
4
4
|
Summary: A framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
|
|
5
5
|
Home-page: http://github.com/quantumlib/cirq
|
|
6
6
|
Author: The Cirq Developers
|