cirq-core 1.6.0.dev20250521011052__py3-none-any.whl → 1.6.0.dev20250522221502__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 +3 -3
- 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/decompositions.py +1 -1
- cirq/linalg/predicates.py +2 -2
- cirq/linalg/tolerance.py +2 -2
- cirq/ops/arithmetic_operation.py +5 -5
- cirq/ops/arithmetic_operation_test.py +2 -4
- cirq/ops/common_gate_families.py +7 -7
- cirq/ops/controlled_gate_test.py +2 -2
- cirq/ops/controlled_operation_test.py +2 -2
- cirq/ops/linear_combinations_test.py +8 -9
- cirq/ops/op_tree.py +1 -1
- cirq/ops/qid_util.py +2 -2
- cirq/ops/qubit_order_or_list.py +2 -2
- cirq/ops/raw_types.py +1 -1
- 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.dev20250521011052.dist-info → cirq_core-1.6.0.dev20250522221502.dist-info}/METADATA +1 -1
- {cirq_core-1.6.0.dev20250521011052.dist-info → cirq_core-1.6.0.dev20250522221502.dist-info}/RECORD +77 -77
- {cirq_core-1.6.0.dev20250521011052.dist-info → cirq_core-1.6.0.dev20250522221502.dist-info}/WHEEL +0 -0
- {cirq_core-1.6.0.dev20250521011052.dist-info → cirq_core-1.6.0.dev20250522221502.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.6.0.dev20250521011052.dist-info → cirq_core-1.6.0.dev20250522221502.dist-info}/top_level.txt +0 -0
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
from __future__ import annotations
|
|
17
17
|
|
|
18
18
|
from types import NotImplementedType
|
|
19
|
-
from typing import Any,
|
|
19
|
+
from typing import Any, TYPE_CHECKING
|
|
20
20
|
|
|
21
21
|
from typing_extensions import Protocol
|
|
22
22
|
|
|
@@ -37,7 +37,7 @@ class SupportsControlKey(Protocol):
|
|
|
37
37
|
"""
|
|
38
38
|
|
|
39
39
|
@doc_private
|
|
40
|
-
def _control_keys_(self) ->
|
|
40
|
+
def _control_keys_(self) -> frozenset[cirq.MeasurementKey] | NotImplementedType | None:
|
|
41
41
|
"""Return the keys for controls referenced by the receiving object.
|
|
42
42
|
|
|
43
43
|
Returns:
|
|
@@ -46,7 +46,7 @@ class SupportsControlKey(Protocol):
|
|
|
46
46
|
"""
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
def control_keys(val: Any) ->
|
|
49
|
+
def control_keys(val: Any) -> frozenset[cirq.MeasurementKey]:
|
|
50
50
|
"""Gets the keys that the value is classically controlled by.
|
|
51
51
|
|
|
52
52
|
Args:
|
|
@@ -64,7 +64,7 @@ def control_keys(val: Any) -> FrozenSet[cirq.MeasurementKey]:
|
|
|
64
64
|
return frozenset()
|
|
65
65
|
|
|
66
66
|
|
|
67
|
-
def measurement_keys_touched(val: Any) ->
|
|
67
|
+
def measurement_keys_touched(val: Any) -> frozenset[cirq.MeasurementKey]:
|
|
68
68
|
"""Returns all the measurement keys used by the value.
|
|
69
69
|
|
|
70
70
|
This would be the case if the value is or contains a measurement gate, or
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
import itertools
|
|
18
|
-
from typing import Optional
|
|
19
18
|
from unittest import mock
|
|
20
19
|
|
|
21
20
|
import pytest
|
|
@@ -231,7 +230,7 @@ def test_decompose_intercept() -> None:
|
|
|
231
230
|
|
|
232
231
|
# Accepts a context, when provided.
|
|
233
232
|
def _intercept_with_context(
|
|
234
|
-
op: cirq.Operation, context:
|
|
233
|
+
op: cirq.Operation, context: cirq.DecompositionContext | None = None
|
|
235
234
|
):
|
|
236
235
|
assert context is not None
|
|
237
236
|
if op.gate == cirq.SWAP:
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from typing import Any
|
|
17
|
+
from typing import Any
|
|
18
18
|
|
|
19
19
|
import cirq.protocols.decompose_protocol as decompose_protocol
|
|
20
20
|
import cirq.protocols.has_unitary_protocol as has_unitary_protocol
|
|
@@ -52,7 +52,7 @@ def has_stabilizer_effect(val: Any) -> bool:
|
|
|
52
52
|
return False
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
def _strat_has_stabilizer_effect_from_has_stabilizer_effect(val: Any) ->
|
|
55
|
+
def _strat_has_stabilizer_effect_from_has_stabilizer_effect(val: Any) -> bool | None:
|
|
56
56
|
"""Infer whether val has stabilizer effect via its `_has_stabilizer_effect_` method."""
|
|
57
57
|
if hasattr(val, '_has_stabilizer_effect_'):
|
|
58
58
|
result = val._has_stabilizer_effect_()
|
|
@@ -61,14 +61,14 @@ def _strat_has_stabilizer_effect_from_has_stabilizer_effect(val: Any) -> Optiona
|
|
|
61
61
|
return None
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
def _strat_has_stabilizer_effect_from_gate(val: Any) ->
|
|
64
|
+
def _strat_has_stabilizer_effect_from_gate(val: Any) -> bool | None:
|
|
65
65
|
"""Infer whether val's gate has stabilizer effect via the _has_stabilizer_effect_ method."""
|
|
66
66
|
if hasattr(val, 'gate'):
|
|
67
67
|
return _strat_has_stabilizer_effect_from_has_stabilizer_effect(val.gate)
|
|
68
68
|
return None
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
def _strat_has_stabilizer_effect_from_unitary(val: Any) ->
|
|
71
|
+
def _strat_has_stabilizer_effect_from_unitary(val: Any) -> bool | None:
|
|
72
72
|
"""Attempts to infer whether val has stabilizer effect from its unitary.
|
|
73
73
|
|
|
74
74
|
Returns whether unitary of `val` normalizes the Pauli group. Works only for
|
|
@@ -103,7 +103,7 @@ def _strat_has_stabilizer_effect_from_unitary(val: Any) -> Optional[bool]:
|
|
|
103
103
|
return True
|
|
104
104
|
|
|
105
105
|
|
|
106
|
-
def _strat_has_stabilizer_effect_from_decompose(val: Any) ->
|
|
106
|
+
def _strat_has_stabilizer_effect_from_decompose(val: Any) -> bool | None:
|
|
107
107
|
decomposition, _, _ = decompose_protocol._try_decompose_into_operations_and_qubits(val)
|
|
108
108
|
if decomposition is None:
|
|
109
109
|
return None
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from typing import Any,
|
|
17
|
+
from typing import Any, TypeVar
|
|
18
18
|
|
|
19
19
|
import numpy as np
|
|
20
20
|
from typing_extensions import Protocol
|
|
@@ -110,7 +110,7 @@ def has_unitary(val: Any, *, allow_decompose: bool = True) -> bool:
|
|
|
110
110
|
return False
|
|
111
111
|
|
|
112
112
|
|
|
113
|
-
def _strat_has_unitary_from_has_unitary(val: Any) ->
|
|
113
|
+
def _strat_has_unitary_from_has_unitary(val: Any) -> bool | None:
|
|
114
114
|
"""Attempts to infer a value's unitary-ness via its _has_unitary_ method."""
|
|
115
115
|
if hasattr(val, '_has_unitary_'):
|
|
116
116
|
result = val._has_unitary_()
|
|
@@ -120,7 +120,7 @@ def _strat_has_unitary_from_has_unitary(val: Any) -> Optional[bool]:
|
|
|
120
120
|
return None
|
|
121
121
|
|
|
122
122
|
|
|
123
|
-
def _strat_has_unitary_from_unitary(val: Any) ->
|
|
123
|
+
def _strat_has_unitary_from_unitary(val: Any) -> bool | None:
|
|
124
124
|
"""Attempts to infer a value's unitary-ness via its _unitary_ method."""
|
|
125
125
|
getter = getattr(val, '_unitary_', None)
|
|
126
126
|
if getter is None:
|
|
@@ -129,7 +129,7 @@ def _strat_has_unitary_from_unitary(val: Any) -> Optional[bool]:
|
|
|
129
129
|
return result is not NotImplemented and result is not None
|
|
130
130
|
|
|
131
131
|
|
|
132
|
-
def _strat_has_unitary_from_decompose(val: Any) ->
|
|
132
|
+
def _strat_has_unitary_from_decompose(val: Any) -> bool | None:
|
|
133
133
|
"""Attempts to infer a value's unitary-ness via its _decompose_ method."""
|
|
134
134
|
operations, _, _ = _try_decompose_into_operations_and_qubits(val)
|
|
135
135
|
if operations is None:
|
|
@@ -137,7 +137,7 @@ def _strat_has_unitary_from_decompose(val: Any) -> Optional[bool]:
|
|
|
137
137
|
return all(has_unitary(op) for op in operations)
|
|
138
138
|
|
|
139
139
|
|
|
140
|
-
def _strat_has_unitary_from_apply_unitary(val: Any) ->
|
|
140
|
+
def _strat_has_unitary_from_apply_unitary(val: Any) -> bool | None:
|
|
141
141
|
"""Attempts to infer a value's unitary-ness via its _apply_unitary_ method."""
|
|
142
142
|
method = getattr(val, '_apply_unitary_', None)
|
|
143
143
|
if method is None:
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
from __future__ import annotations
|
|
18
18
|
|
|
19
|
-
from typing import Any, TypeVar
|
|
19
|
+
from typing import Any, TypeVar
|
|
20
20
|
|
|
21
21
|
from typing_extensions import Protocol
|
|
22
22
|
|
|
@@ -48,9 +48,9 @@ class SupportsPauliExpansion(Protocol):
|
|
|
48
48
|
def pauli_expansion(
|
|
49
49
|
val: Any,
|
|
50
50
|
*,
|
|
51
|
-
default:
|
|
51
|
+
default: value.LinearDict[str] | TDefault = RaiseTypeErrorIfNotProvided,
|
|
52
52
|
atol: float = 1e-9,
|
|
53
|
-
) ->
|
|
53
|
+
) -> value.LinearDict[str] | TDefault:
|
|
54
54
|
"""Returns coefficients of the expansion of val in the Pauli basis.
|
|
55
55
|
|
|
56
56
|
Args:
|
cirq/protocols/pow_protocol.py
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from typing import Any, Callable,
|
|
17
|
+
from typing import Any, Callable, overload, TYPE_CHECKING, TypeVar
|
|
18
18
|
|
|
19
19
|
if TYPE_CHECKING:
|
|
20
20
|
import cirq
|
|
@@ -38,17 +38,17 @@ def pow(val: cirq.Operation, exponent: Any) -> cirq.Operation:
|
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
@overload
|
|
41
|
-
def pow(val: cirq.Gate, exponent: Any, default: TDefault) ->
|
|
41
|
+
def pow(val: cirq.Gate, exponent: Any, default: TDefault) -> TDefault | cirq.Gate:
|
|
42
42
|
pass
|
|
43
43
|
|
|
44
44
|
|
|
45
45
|
@overload
|
|
46
|
-
def pow(val: cirq.Operation, exponent: Any, default: TDefault) ->
|
|
46
|
+
def pow(val: cirq.Operation, exponent: Any, default: TDefault) -> TDefault | cirq.Operation:
|
|
47
47
|
pass
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
@overload
|
|
51
|
-
def pow(val: cirq.Circuit, exponent: int, default: TDefault) ->
|
|
51
|
+
def pow(val: cirq.Circuit, exponent: int, default: TDefault) -> TDefault | cirq.Circuit:
|
|
52
52
|
pass
|
|
53
53
|
|
|
54
54
|
|
|
@@ -84,7 +84,7 @@ def pow(val: Any, exponent: Any, default: Any = RaiseTypeErrorIfNotProvided) ->
|
|
|
84
84
|
TypeError: `val` doesn't have a __pow__ method (or that method returned
|
|
85
85
|
NotImplemented) and no `default` value was specified.
|
|
86
86
|
"""
|
|
87
|
-
raiser:
|
|
87
|
+
raiser: Callable | None = getattr(val, '__pow__', None)
|
|
88
88
|
result = NotImplemented if raiser is None else raiser(exponent)
|
|
89
89
|
if result is not NotImplemented:
|
|
90
90
|
return result
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from typing import Any,
|
|
17
|
+
from typing import Any, Sequence, TypeVar
|
|
18
18
|
|
|
19
19
|
import numpy as np
|
|
20
20
|
from typing_extensions import Protocol
|
|
@@ -81,7 +81,7 @@ def trace_distance_bound(val: Any) -> float:
|
|
|
81
81
|
return 1.0
|
|
82
82
|
|
|
83
83
|
|
|
84
|
-
def _strat_from_trace_distance_bound_method(val: Any) ->
|
|
84
|
+
def _strat_from_trace_distance_bound_method(val: Any) -> float | None:
|
|
85
85
|
"""Attempts to use a specialized method."""
|
|
86
86
|
getter = getattr(val, '_trace_distance_bound_', None)
|
|
87
87
|
result = NotImplemented if getter is None else getter()
|
|
@@ -95,7 +95,7 @@ def _strat_from_trace_distance_bound_method(val: Any) -> Optional[float]:
|
|
|
95
95
|
return NotImplemented
|
|
96
96
|
|
|
97
97
|
|
|
98
|
-
def _strat_distance_from_unitary(val: Any) ->
|
|
98
|
+
def _strat_distance_from_unitary(val: Any) -> float | None:
|
|
99
99
|
"""Attempts to compute a value's trace_distance_bound from its unitary."""
|
|
100
100
|
u = unitary_protocol.unitary(val, default=None)
|
|
101
101
|
|
|
@@ -111,7 +111,7 @@ def _strat_distance_from_unitary(val: Any) -> Optional[float]:
|
|
|
111
111
|
return trace_distance_from_angle_list(np.angle(np.linalg.eigvals(u)))
|
|
112
112
|
|
|
113
113
|
|
|
114
|
-
def trace_distance_from_angle_list(angle_list:
|
|
114
|
+
def trace_distance_from_angle_list(angle_list: Sequence[float] | np.ndarray) -> float:
|
|
115
115
|
"""Given a list of arguments of the eigenvalues of a unitary matrix,
|
|
116
116
|
calculates the trace distance bound of the unitary effect.
|
|
117
117
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
17
|
from types import NotImplementedType
|
|
18
|
-
from typing import Any,
|
|
18
|
+
from typing import Any, TypeVar
|
|
19
19
|
|
|
20
20
|
import numpy as np
|
|
21
21
|
from typing_extensions import Protocol
|
|
@@ -39,7 +39,7 @@ class SupportsUnitary(Protocol):
|
|
|
39
39
|
"""An object that may be describable by a unitary matrix."""
|
|
40
40
|
|
|
41
41
|
@doc_private
|
|
42
|
-
def _unitary_(self) ->
|
|
42
|
+
def _unitary_(self) -> np.ndarray | NotImplementedType:
|
|
43
43
|
"""A unitary matrix describing this value, e.g. the matrix of a gate.
|
|
44
44
|
|
|
45
45
|
This method is used by the global `cirq.unitary` method. If this method
|
|
@@ -78,8 +78,8 @@ class SupportsUnitary(Protocol):
|
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
def unitary(
|
|
81
|
-
val: Any, default:
|
|
82
|
-
) ->
|
|
81
|
+
val: Any, default: np.ndarray | TDefault = RaiseTypeErrorIfNotProvided
|
|
82
|
+
) -> np.ndarray | TDefault:
|
|
83
83
|
"""Returns a unitary matrix describing the given value.
|
|
84
84
|
|
|
85
85
|
The matrix is determined by any one of the following techniques:
|
|
@@ -142,7 +142,7 @@ def unitary(
|
|
|
142
142
|
)
|
|
143
143
|
|
|
144
144
|
|
|
145
|
-
def _strat_unitary_from_unitary(val: Any) ->
|
|
145
|
+
def _strat_unitary_from_unitary(val: Any) -> np.ndarray | None:
|
|
146
146
|
"""Attempts to compute a value's unitary via its _unitary_ method."""
|
|
147
147
|
getter = getattr(val, '_unitary_', None)
|
|
148
148
|
if getter is None:
|
|
@@ -150,7 +150,7 @@ def _strat_unitary_from_unitary(val: Any) -> Optional[np.ndarray]:
|
|
|
150
150
|
return getter()
|
|
151
151
|
|
|
152
152
|
|
|
153
|
-
def _strat_unitary_from_apply_unitary(val: Any) ->
|
|
153
|
+
def _strat_unitary_from_apply_unitary(val: Any) -> np.ndarray | None:
|
|
154
154
|
"""Attempts to compute a value's unitary via its _apply_unitary_ method."""
|
|
155
155
|
# Check for the magic method.
|
|
156
156
|
method = getattr(val, '_apply_unitary_', None)
|
|
@@ -171,7 +171,7 @@ def _strat_unitary_from_apply_unitary(val: Any) -> Optional[np.ndarray]:
|
|
|
171
171
|
return result.reshape((state_len, state_len))
|
|
172
172
|
|
|
173
173
|
|
|
174
|
-
def _strat_unitary_from_decompose(val: Any) ->
|
|
174
|
+
def _strat_unitary_from_decompose(val: Any) -> np.ndarray | None:
|
|
175
175
|
"""Attempts to compute a value's unitary via its _decompose_ method."""
|
|
176
176
|
# Check if there's a decomposition.
|
|
177
177
|
operations, qubits, val_qid_shape = _try_decompose_into_operations_and_qubits(val)
|
|
@@ -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
|
|
|
@@ -77,7 +75,7 @@ class FullyImplemented(cirq.Gate):
|
|
|
77
75
|
def _has_unitary_(self) -> bool:
|
|
78
76
|
return self.unitary_value
|
|
79
77
|
|
|
80
|
-
def _unitary_(self) ->
|
|
78
|
+
def _unitary_(self) -> np.ndarray | None:
|
|
81
79
|
if not self.unitary_value:
|
|
82
80
|
return None
|
|
83
81
|
return m1
|
cirq/qis/entropy.py
CHANGED
|
@@ -17,7 +17,7 @@ from __future__ import annotations
|
|
|
17
17
|
from collections.abc import Sequence
|
|
18
18
|
from concurrent.futures import ThreadPoolExecutor
|
|
19
19
|
from itertools import product
|
|
20
|
-
from typing import Any, cast, Iterator
|
|
20
|
+
from typing import Any, cast, Iterator
|
|
21
21
|
|
|
22
22
|
import numpy as np
|
|
23
23
|
import numpy.typing as npt
|
|
@@ -94,7 +94,7 @@ def _compute_bitstrings_contribution_to_purity(bitstrings: npt.NDArray[np.int8])
|
|
|
94
94
|
def process_renyi_entropy_from_bitstrings(
|
|
95
95
|
measured_bitstrings: npt.NDArray[np.int8],
|
|
96
96
|
subsystem: tuple[int] | None = None,
|
|
97
|
-
pool:
|
|
97
|
+
pool: ThreadPoolExecutor | None = None,
|
|
98
98
|
) -> float:
|
|
99
99
|
"""Compute the Rényi entropy of an array of bitstrings.
|
|
100
100
|
Args:
|
|
@@ -17,7 +17,7 @@ for Clifford Simulator."""
|
|
|
17
17
|
|
|
18
18
|
from __future__ import annotations
|
|
19
19
|
|
|
20
|
-
from typing import
|
|
20
|
+
from typing import Sequence, TYPE_CHECKING
|
|
21
21
|
|
|
22
22
|
from cirq.qis import clifford_tableau
|
|
23
23
|
from cirq.sim.clifford.stabilizer_simulation_state import StabilizerSimulationState
|
|
@@ -34,9 +34,9 @@ class CliffordTableauSimulationState(StabilizerSimulationState[clifford_tableau.
|
|
|
34
34
|
def __init__(
|
|
35
35
|
self,
|
|
36
36
|
tableau: cirq.CliffordTableau,
|
|
37
|
-
prng:
|
|
38
|
-
qubits:
|
|
39
|
-
classical_data:
|
|
37
|
+
prng: np.random.RandomState | None = None,
|
|
38
|
+
qubits: Sequence[cirq.Qid] | None = None,
|
|
39
|
+
classical_data: cirq.ClassicalDataStore | None = None,
|
|
40
40
|
):
|
|
41
41
|
"""Inits CliffordTableauSimulationState.
|
|
42
42
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
-
from typing import
|
|
17
|
+
from typing import Sequence, TYPE_CHECKING
|
|
18
18
|
|
|
19
19
|
from cirq._compat import proper_repr
|
|
20
20
|
from cirq.sim.clifford import stabilizer_state_ch_form
|
|
@@ -34,10 +34,10 @@ class StabilizerChFormSimulationState(
|
|
|
34
34
|
def __init__(
|
|
35
35
|
self,
|
|
36
36
|
*,
|
|
37
|
-
prng:
|
|
38
|
-
qubits:
|
|
39
|
-
initial_state:
|
|
40
|
-
classical_data:
|
|
37
|
+
prng: np.random.RandomState | None = None,
|
|
38
|
+
qubits: Sequence[cirq.Qid] | None = None,
|
|
39
|
+
initial_state: int | cirq.StabilizerStateChForm = 0,
|
|
40
|
+
classical_data: cirq.ClassicalDataStore | None = None,
|
|
41
41
|
):
|
|
42
42
|
"""Initializes with the given state and the axes for the operation.
|
|
43
43
|
|
|
@@ -16,7 +16,7 @@ from __future__ import annotations
|
|
|
16
16
|
|
|
17
17
|
import abc
|
|
18
18
|
from types import NotImplementedType
|
|
19
|
-
from typing import Any, cast, Generic,
|
|
19
|
+
from typing import Any, cast, Generic, Sequence, TYPE_CHECKING, TypeVar
|
|
20
20
|
|
|
21
21
|
import sympy
|
|
22
22
|
|
|
@@ -44,9 +44,9 @@ class StabilizerSimulationState(
|
|
|
44
44
|
self,
|
|
45
45
|
*,
|
|
46
46
|
state: TStabilizerState,
|
|
47
|
-
prng:
|
|
48
|
-
qubits:
|
|
49
|
-
classical_data:
|
|
47
|
+
prng: np.random.RandomState | None = None,
|
|
48
|
+
qubits: Sequence[cirq.Qid] | None = None,
|
|
49
|
+
classical_data: cirq.ClassicalDataStore | None = None,
|
|
50
50
|
):
|
|
51
51
|
"""Initializes the StabilizerSimulationState.
|
|
52
52
|
|
|
@@ -69,7 +69,7 @@ class StabilizerSimulationState(
|
|
|
69
69
|
|
|
70
70
|
def _act_on_fallback_(
|
|
71
71
|
self, action: Any, qubits: Sequence[cirq.Qid], allow_decompose: bool = True
|
|
72
|
-
) ->
|
|
72
|
+
) -> bool | NotImplementedType:
|
|
73
73
|
strats = [self._strat_apply_gate, self._strat_apply_mixture]
|
|
74
74
|
if allow_decompose:
|
|
75
75
|
strats.append(self._strat_decompose)
|