cirq-core 1.5.0.dev20250330074424__py3-none-any.whl → 1.5.0.dev20250331190555__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/__init__.py +1 -0
- cirq/_version.py +1 -1
- cirq/_version_test.py +1 -1
- cirq/json_resolver_cache.py +1 -0
- cirq/protocols/json_serialization.py +7 -0
- cirq/protocols/json_serialization_test.py +13 -0
- cirq/protocols/json_test_data/BitMaskKeyCondition.json +86 -0
- cirq/protocols/json_test_data/BitMaskKeyCondition.repr +7 -0
- cirq/value/__init__.py +1 -0
- cirq/value/condition.py +107 -0
- cirq/value/condition_test.py +179 -0
- {cirq_core-1.5.0.dev20250330074424.dist-info → cirq_core-1.5.0.dev20250331190555.dist-info}/METADATA +1 -1
- {cirq_core-1.5.0.dev20250330074424.dist-info → cirq_core-1.5.0.dev20250331190555.dist-info}/RECORD +16 -14
- {cirq_core-1.5.0.dev20250330074424.dist-info → cirq_core-1.5.0.dev20250331190555.dist-info}/LICENSE +0 -0
- {cirq_core-1.5.0.dev20250330074424.dist-info → cirq_core-1.5.0.dev20250331190555.dist-info}/WHEEL +0 -0
- {cirq_core-1.5.0.dev20250330074424.dist-info → cirq_core-1.5.0.dev20250331190555.dist-info}/top_level.txt +0 -0
cirq/__init__.py
CHANGED
|
@@ -533,6 +533,7 @@ from cirq.value import (
|
|
|
533
533
|
canonicalize_half_turns as canonicalize_half_turns,
|
|
534
534
|
chosen_angle_to_canonical_half_turns as chosen_angle_to_canonical_half_turns,
|
|
535
535
|
chosen_angle_to_half_turns as chosen_angle_to_half_turns,
|
|
536
|
+
BitMaskKeyCondition as BitMaskKeyCondition,
|
|
536
537
|
ClassicalDataDictionaryStore as ClassicalDataDictionaryStore,
|
|
537
538
|
ClassicalDataStore as ClassicalDataStore,
|
|
538
539
|
ClassicalDataStoreReader as ClassicalDataStoreReader,
|
cirq/_version.py
CHANGED
cirq/_version_test.py
CHANGED
cirq/json_resolver_cache.py
CHANGED
|
@@ -107,6 +107,7 @@ def _class_resolver_dictionary() -> Dict[str, ObjectFactory]:
|
|
|
107
107
|
'AnyUnitaryGateFamily': cirq.AnyUnitaryGateFamily,
|
|
108
108
|
'AsymmetricDepolarizingChannel': cirq.AsymmetricDepolarizingChannel,
|
|
109
109
|
'BitFlipChannel': cirq.BitFlipChannel,
|
|
110
|
+
'BitMaskKeyCondition': cirq.BitMaskKeyCondition,
|
|
110
111
|
'BitstringAccumulator': cirq.work.BitstringAccumulator,
|
|
111
112
|
'BooleanHamiltonianGate': cirq.BooleanHamiltonianGate,
|
|
112
113
|
'CCNotPowGate': cirq.CCNotPowGate,
|
|
@@ -34,6 +34,7 @@ from typing import (
|
|
|
34
34
|
Union,
|
|
35
35
|
)
|
|
36
36
|
|
|
37
|
+
import attrs
|
|
37
38
|
import numpy as np
|
|
38
39
|
import pandas as pd
|
|
39
40
|
import sympy
|
|
@@ -182,6 +183,12 @@ def dataclass_json_dict(obj: Any) -> Dict[str, Any]:
|
|
|
182
183
|
return obj_to_dict_helper(obj, attribute_names)
|
|
183
184
|
|
|
184
185
|
|
|
186
|
+
def attrs_json_dict(obj: Any) -> Dict[str, Any]:
|
|
187
|
+
"""Return a dictionary suitable for `_json_dict_` from an attrs dataclass."""
|
|
188
|
+
attribute_names = [f.name for f in attrs.fields(type(obj))]
|
|
189
|
+
return obj_to_dict_helper(obj, attribute_names)
|
|
190
|
+
|
|
191
|
+
|
|
185
192
|
def _json_dict_with_cirq_type(obj: Any):
|
|
186
193
|
base_dict = obj._json_dict_()
|
|
187
194
|
if 'cirq_type' in base_dict:
|
|
@@ -24,6 +24,7 @@ import warnings
|
|
|
24
24
|
from typing import Dict, List, Optional, Tuple, Type
|
|
25
25
|
from unittest import mock
|
|
26
26
|
|
|
27
|
+
import attrs
|
|
27
28
|
import networkx as nx
|
|
28
29
|
import numpy as np
|
|
29
30
|
import pandas as pd
|
|
@@ -790,3 +791,15 @@ def test_datetime():
|
|
|
790
791
|
assert re_pst_dt == pst_dt
|
|
791
792
|
assert re_pst_dt == utc_dt
|
|
792
793
|
assert re_pst_dt == re_naive_dt
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
@attrs.frozen
|
|
797
|
+
class _TestAttrsClas:
|
|
798
|
+
name: str
|
|
799
|
+
x: int
|
|
800
|
+
|
|
801
|
+
|
|
802
|
+
def test_attrs_json_dict():
|
|
803
|
+
obj = _TestAttrsClas('test', x=123)
|
|
804
|
+
js = json_serialization.attrs_json_dict(obj)
|
|
805
|
+
assert js == {'name': 'test', 'x': 123}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"cirq_type": "BitMaskKeyCondition",
|
|
4
|
+
"key": {
|
|
5
|
+
"cirq_type": "MeasurementKey",
|
|
6
|
+
"name": "a",
|
|
7
|
+
"path": []
|
|
8
|
+
},
|
|
9
|
+
"index": 59,
|
|
10
|
+
"target_value": 0,
|
|
11
|
+
"equal_target": false,
|
|
12
|
+
"bitmask": null
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"cirq_type": "BitMaskKeyCondition",
|
|
16
|
+
"key": {
|
|
17
|
+
"cirq_type": "MeasurementKey",
|
|
18
|
+
"name": "b",
|
|
19
|
+
"path": []
|
|
20
|
+
},
|
|
21
|
+
"index": 58,
|
|
22
|
+
"target_value": 3,
|
|
23
|
+
"equal_target": false,
|
|
24
|
+
"bitmask": null
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"cirq_type": "BitMaskKeyCondition",
|
|
28
|
+
"key": {
|
|
29
|
+
"cirq_type": "MeasurementKey",
|
|
30
|
+
"name": "c",
|
|
31
|
+
"path": []
|
|
32
|
+
},
|
|
33
|
+
"index": 57,
|
|
34
|
+
"target_value": 0,
|
|
35
|
+
"equal_target": false,
|
|
36
|
+
"bitmask": 13
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"cirq_type": "BitMaskKeyCondition",
|
|
40
|
+
"key": {
|
|
41
|
+
"cirq_type": "MeasurementKey",
|
|
42
|
+
"name": "d",
|
|
43
|
+
"path": []
|
|
44
|
+
},
|
|
45
|
+
"index": 56,
|
|
46
|
+
"target_value": 12,
|
|
47
|
+
"equal_target": false,
|
|
48
|
+
"bitmask": 13
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"cirq_type": "BitMaskKeyCondition",
|
|
52
|
+
"key": {
|
|
53
|
+
"cirq_type": "MeasurementKey",
|
|
54
|
+
"name": "d",
|
|
55
|
+
"path": []
|
|
56
|
+
},
|
|
57
|
+
"index": 55,
|
|
58
|
+
"target_value": 12,
|
|
59
|
+
"equal_target": true,
|
|
60
|
+
"bitmask": 13
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"cirq_type": "BitMaskKeyCondition",
|
|
64
|
+
"key": {
|
|
65
|
+
"cirq_type": "MeasurementKey",
|
|
66
|
+
"name": "e",
|
|
67
|
+
"path": []
|
|
68
|
+
},
|
|
69
|
+
"index": 54,
|
|
70
|
+
"target_value": 11,
|
|
71
|
+
"equal_target": true,
|
|
72
|
+
"bitmask": 11
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"cirq_type": "BitMaskKeyCondition",
|
|
76
|
+
"key": {
|
|
77
|
+
"cirq_type": "MeasurementKey",
|
|
78
|
+
"name": "e",
|
|
79
|
+
"path": []
|
|
80
|
+
},
|
|
81
|
+
"index": 53,
|
|
82
|
+
"target_value": 9,
|
|
83
|
+
"equal_target": false,
|
|
84
|
+
"bitmask": 9
|
|
85
|
+
}
|
|
86
|
+
]
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[cirq.BitMaskKeyCondition(key=cirq.MeasurementKey(name='a'), index=59, target_value=0, equal_target=False, bitmask=None),
|
|
2
|
+
cirq.BitMaskKeyCondition(key=cirq.MeasurementKey(name='b'), index=58, target_value=3, equal_target=False, bitmask=None),
|
|
3
|
+
cirq.BitMaskKeyCondition(key=cirq.MeasurementKey(name='c'), index=57, target_value=0, equal_target=False, bitmask=13),
|
|
4
|
+
cirq.BitMaskKeyCondition(key=cirq.MeasurementKey(name='d'), index=56, target_value=12, equal_target=False, bitmask=13),
|
|
5
|
+
cirq.BitMaskKeyCondition(key=cirq.MeasurementKey(name='d'), index=55, target_value=12, equal_target=True, bitmask=13),
|
|
6
|
+
cirq.BitMaskKeyCondition(key=cirq.MeasurementKey(name='e'), index=54, target_value=11, equal_target=True, bitmask=11),
|
|
7
|
+
cirq.BitMaskKeyCondition(key=cirq.MeasurementKey(name='e'), index=53, target_value=9, equal_target=False, bitmask=9)]
|
cirq/value/__init__.py
CHANGED
cirq/value/condition.py
CHANGED
|
@@ -16,6 +16,7 @@ import abc
|
|
|
16
16
|
import dataclasses
|
|
17
17
|
from typing import Any, Dict, FrozenSet, Mapping, Optional, Tuple, TYPE_CHECKING
|
|
18
18
|
|
|
19
|
+
import attrs
|
|
19
20
|
import sympy
|
|
20
21
|
|
|
21
22
|
from cirq._compat import proper_repr
|
|
@@ -135,6 +136,112 @@ class KeyCondition(Condition):
|
|
|
135
136
|
return f'{key}==1'
|
|
136
137
|
|
|
137
138
|
|
|
139
|
+
@attrs.frozen
|
|
140
|
+
class BitMaskKeyCondition(Condition):
|
|
141
|
+
"""A multiqubit classical control condition with a bitmask.
|
|
142
|
+
|
|
143
|
+
The control is based on a single measurement key and allows comparing equality or inequality
|
|
144
|
+
after taking the bitwise and with a bitmask.
|
|
145
|
+
|
|
146
|
+
Examples:
|
|
147
|
+
- BitMaskKeycondition('a') -> a != 0
|
|
148
|
+
- BitMaskKeyCondition('a', bitmask=13) -> (a & 13) != 0
|
|
149
|
+
- BitMaskKeyCondition('a', bitmask=13, target_value=9) -> (a & 13) != 9
|
|
150
|
+
- BitMaskKeyCondition('a', bitmask=13, target_value=9, equal_target=True) -> (a & 13) == 9
|
|
151
|
+
- BitMaskKeyCondition.create_equal_mask('a', 13) -> (a & 13) == 13
|
|
152
|
+
- BitMaskKeyCondition.create_not_equal_mask('a', 13) -> (a & 13) != 13
|
|
153
|
+
|
|
154
|
+
The bits in the bitmask have the same order as the qubits passed to `cirq.measure(...)`. That's
|
|
155
|
+
the most significant bit corresponds to the the first (left most) qubit.
|
|
156
|
+
|
|
157
|
+
Attributes:
|
|
158
|
+
- key: Measurement key.
|
|
159
|
+
- index: integer index (same as KeyCondition.index).
|
|
160
|
+
- target_value: The value we compare with.
|
|
161
|
+
- equal_target: Whether to comapre with == or !=.
|
|
162
|
+
- bitmask: Optional bitmask to apply before doing the comparison.
|
|
163
|
+
"""
|
|
164
|
+
|
|
165
|
+
key: 'cirq.MeasurementKey' = attrs.field(
|
|
166
|
+
converter=lambda x: (
|
|
167
|
+
x
|
|
168
|
+
if isinstance(x, measurement_key.MeasurementKey)
|
|
169
|
+
else measurement_key.MeasurementKey(x)
|
|
170
|
+
)
|
|
171
|
+
)
|
|
172
|
+
index: int = -1
|
|
173
|
+
target_value: int = 0
|
|
174
|
+
equal_target: bool = False
|
|
175
|
+
bitmask: Optional[int] = None
|
|
176
|
+
|
|
177
|
+
@property
|
|
178
|
+
def keys(self):
|
|
179
|
+
return (self.key,)
|
|
180
|
+
|
|
181
|
+
@staticmethod
|
|
182
|
+
def create_equal_mask(
|
|
183
|
+
key: 'cirq.MeasurementKey', bitmask: int, *, index: int = -1
|
|
184
|
+
) -> 'BitMaskKeyCondition':
|
|
185
|
+
"""Creates a condition that evaluates (meas & bitmask) == bitmask."""
|
|
186
|
+
return BitMaskKeyCondition(
|
|
187
|
+
key, index, target_value=bitmask, equal_target=True, bitmask=bitmask
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
@staticmethod
|
|
191
|
+
def create_not_equal_mask(
|
|
192
|
+
key: 'cirq.MeasurementKey', bitmask: int, *, index: int = -1
|
|
193
|
+
) -> 'BitMaskKeyCondition':
|
|
194
|
+
"""Creates a condition that evaluates (meas & bitmask) != bitmask."""
|
|
195
|
+
return BitMaskKeyCondition(
|
|
196
|
+
key, index, target_value=bitmask, equal_target=False, bitmask=bitmask
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
def replace_key(self, current: 'cirq.MeasurementKey', replacement: 'cirq.MeasurementKey'):
|
|
200
|
+
return BitMaskKeyCondition(replacement) if self.key == current else self
|
|
201
|
+
|
|
202
|
+
def __str__(self):
|
|
203
|
+
s = str(self.key) if self.index == -1 else f'{self.key}[{self.index}]'
|
|
204
|
+
if self.bitmask is not None:
|
|
205
|
+
s = f'{s} & {self.bitmask}'
|
|
206
|
+
if self.equal_target:
|
|
207
|
+
if self.bitmask is not None:
|
|
208
|
+
s = f'({s})'
|
|
209
|
+
s = f'{s} == {self.target_value}'
|
|
210
|
+
elif self.target_value != 0:
|
|
211
|
+
if self.bitmask is not None:
|
|
212
|
+
s = f'({s})'
|
|
213
|
+
s = f'{s} != {self.target_value}'
|
|
214
|
+
return s
|
|
215
|
+
|
|
216
|
+
def __repr__(self):
|
|
217
|
+
values = attrs.asdict(self)
|
|
218
|
+
parameters = ', '.join(f'{f.name}={repr(values[f.name])}' for f in attrs.fields(type(self)))
|
|
219
|
+
return f'cirq.BitMaskKeyCondition({parameters})'
|
|
220
|
+
|
|
221
|
+
def resolve(self, classical_data: 'cirq.ClassicalDataStoreReader') -> bool:
|
|
222
|
+
if self.key not in classical_data.keys():
|
|
223
|
+
raise ValueError(f'Measurement key {self.key} missing when testing classical control')
|
|
224
|
+
value = classical_data.get_int(self.key, self.index)
|
|
225
|
+
if self.bitmask is not None:
|
|
226
|
+
value &= self.bitmask
|
|
227
|
+
if self.equal_target:
|
|
228
|
+
return value == self.target_value
|
|
229
|
+
return value != self.target_value
|
|
230
|
+
|
|
231
|
+
def _json_dict_(self):
|
|
232
|
+
return json_serialization.attrs_json_dict(self)
|
|
233
|
+
|
|
234
|
+
@classmethod
|
|
235
|
+
def _from_json_dict_(cls, key, **kwargs):
|
|
236
|
+
parameter_names = [f.name for f in attrs.fields(cls)[1:]]
|
|
237
|
+
parameters = {k: kwargs[k] for k in parameter_names if k in kwargs}
|
|
238
|
+
return cls(key=key, **parameters)
|
|
239
|
+
|
|
240
|
+
@property
|
|
241
|
+
def qasm(self):
|
|
242
|
+
raise NotImplementedError() # pragma: no cover
|
|
243
|
+
|
|
244
|
+
|
|
138
245
|
@dataclasses.dataclass(frozen=True)
|
|
139
246
|
class SympyCondition(Condition):
|
|
140
247
|
"""A classical control condition based on a sympy expression.
|
cirq/value/condition_test.py
CHANGED
|
@@ -193,3 +193,182 @@ def test_sympy_condition_qasm():
|
|
|
193
193
|
ValueError, match='QASM is defined only for SympyConditions of type key == constant'
|
|
194
194
|
):
|
|
195
195
|
_ = cirq.SympyCondition(sympy.Symbol('a') != 2).qasm
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
@pytest.mark.parametrize(
|
|
199
|
+
['cond', 'cond_str'],
|
|
200
|
+
[
|
|
201
|
+
(
|
|
202
|
+
cirq.BitMaskKeyCondition(
|
|
203
|
+
bitmask=None, equal_target=False, index=59, key='a', target_value=0
|
|
204
|
+
),
|
|
205
|
+
'a[59]',
|
|
206
|
+
),
|
|
207
|
+
(
|
|
208
|
+
cirq.BitMaskKeyCondition(
|
|
209
|
+
bitmask=None, equal_target=False, index=-1, key='a', target_value=0
|
|
210
|
+
),
|
|
211
|
+
'a',
|
|
212
|
+
),
|
|
213
|
+
(
|
|
214
|
+
cirq.BitMaskKeyCondition(
|
|
215
|
+
bitmask=None, equal_target=False, index=58, key='b', target_value=3
|
|
216
|
+
),
|
|
217
|
+
'b[58] != 3',
|
|
218
|
+
),
|
|
219
|
+
(
|
|
220
|
+
cirq.BitMaskKeyCondition(
|
|
221
|
+
bitmask=None, equal_target=False, index=-1, key='b', target_value=3
|
|
222
|
+
),
|
|
223
|
+
'b != 3',
|
|
224
|
+
),
|
|
225
|
+
(
|
|
226
|
+
cirq.BitMaskKeyCondition(
|
|
227
|
+
bitmask=13, equal_target=False, index=57, key='c', target_value=0
|
|
228
|
+
),
|
|
229
|
+
'c[57] & 13',
|
|
230
|
+
),
|
|
231
|
+
(
|
|
232
|
+
cirq.BitMaskKeyCondition(
|
|
233
|
+
bitmask=13, equal_target=False, index=-1, key='c', target_value=0
|
|
234
|
+
),
|
|
235
|
+
'c & 13',
|
|
236
|
+
),
|
|
237
|
+
(
|
|
238
|
+
cirq.BitMaskKeyCondition(
|
|
239
|
+
bitmask=13, equal_target=False, index=56, key='d', target_value=12
|
|
240
|
+
),
|
|
241
|
+
'(d[56] & 13) != 12',
|
|
242
|
+
),
|
|
243
|
+
(
|
|
244
|
+
cirq.BitMaskKeyCondition(
|
|
245
|
+
bitmask=13, equal_target=False, index=-1, key='d', target_value=12
|
|
246
|
+
),
|
|
247
|
+
'(d & 13) != 12',
|
|
248
|
+
),
|
|
249
|
+
(
|
|
250
|
+
cirq.BitMaskKeyCondition(
|
|
251
|
+
bitmask=13, equal_target=True, index=55, key='d', target_value=12
|
|
252
|
+
),
|
|
253
|
+
'(d[55] & 13) == 12',
|
|
254
|
+
),
|
|
255
|
+
(
|
|
256
|
+
cirq.BitMaskKeyCondition(
|
|
257
|
+
bitmask=13, equal_target=True, index=-1, key='d', target_value=12
|
|
258
|
+
),
|
|
259
|
+
'(d & 13) == 12',
|
|
260
|
+
),
|
|
261
|
+
(
|
|
262
|
+
cirq.BitMaskKeyCondition(
|
|
263
|
+
bitmask=11, equal_target=True, index=54, key='e', target_value=11
|
|
264
|
+
),
|
|
265
|
+
'(e[54] & 11) == 11',
|
|
266
|
+
),
|
|
267
|
+
(
|
|
268
|
+
cirq.BitMaskKeyCondition(
|
|
269
|
+
bitmask=11, equal_target=True, index=-1, key='e', target_value=11
|
|
270
|
+
),
|
|
271
|
+
'(e & 11) == 11',
|
|
272
|
+
),
|
|
273
|
+
(
|
|
274
|
+
cirq.BitMaskKeyCondition(
|
|
275
|
+
bitmask=9, equal_target=False, index=53, key='e', target_value=9
|
|
276
|
+
),
|
|
277
|
+
'(e[53] & 9) != 9',
|
|
278
|
+
),
|
|
279
|
+
(
|
|
280
|
+
cirq.BitMaskKeyCondition(
|
|
281
|
+
bitmask=9, equal_target=False, index=-1, key='e', target_value=9
|
|
282
|
+
),
|
|
283
|
+
'(e & 9) != 9',
|
|
284
|
+
),
|
|
285
|
+
],
|
|
286
|
+
)
|
|
287
|
+
def test_bitmask_condition_str(cond: cirq.BitMaskKeyCondition, cond_str: str):
|
|
288
|
+
assert str(cond) == cond_str
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
@pytest.mark.parametrize(
|
|
292
|
+
['cond', 'value'],
|
|
293
|
+
[
|
|
294
|
+
(cirq.BitMaskKeyCondition('c', bitmask=13, target_value=9), False),
|
|
295
|
+
(cirq.BitMaskKeyCondition('d', bitmask=13, target_value=12, equal_target=True), True),
|
|
296
|
+
],
|
|
297
|
+
)
|
|
298
|
+
def test_bitmask_condition_resolve(cond: cirq.BitMaskKeyCondition, value: bool):
|
|
299
|
+
resolver = cirq.ClassicalDataDictionaryStore(
|
|
300
|
+
_records={
|
|
301
|
+
cirq.MeasurementKey('c'): [(1, 0, 0, 1)],
|
|
302
|
+
cirq.MeasurementKey('d'): [(1, 0, 1, 1, 0, 0)],
|
|
303
|
+
}
|
|
304
|
+
)
|
|
305
|
+
assert cond.resolve(resolver) == value
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
def test_bitmask_condition_resolve_invalid_input_raises():
|
|
309
|
+
cond = cirq.BitMaskKeyCondition('a')
|
|
310
|
+
resolver = cirq.ClassicalDataDictionaryStore(
|
|
311
|
+
_records={
|
|
312
|
+
cirq.MeasurementKey('c'): [(1, 0, 0, 1)],
|
|
313
|
+
cirq.MeasurementKey('d'): [(1, 0, 1, 1, 0, 0)],
|
|
314
|
+
}
|
|
315
|
+
)
|
|
316
|
+
with pytest.raises(ValueError):
|
|
317
|
+
_ = cond.resolve(resolver)
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
@pytest.mark.parametrize(
|
|
321
|
+
'cond',
|
|
322
|
+
[
|
|
323
|
+
cirq.BitMaskKeyCondition(
|
|
324
|
+
bitmask=None, equal_target=False, index=59, key='a', target_value=0
|
|
325
|
+
),
|
|
326
|
+
cirq.BitMaskKeyCondition(
|
|
327
|
+
bitmask=None, equal_target=False, index=-1, key='a', target_value=0
|
|
328
|
+
),
|
|
329
|
+
cirq.BitMaskKeyCondition(
|
|
330
|
+
bitmask=None, equal_target=False, index=58, key='b', target_value=3
|
|
331
|
+
),
|
|
332
|
+
cirq.BitMaskKeyCondition(
|
|
333
|
+
bitmask=None, equal_target=False, index=-1, key='b', target_value=3
|
|
334
|
+
),
|
|
335
|
+
cirq.BitMaskKeyCondition(bitmask=13, equal_target=False, index=57, key='c', target_value=0),
|
|
336
|
+
cirq.BitMaskKeyCondition(bitmask=13, equal_target=False, index=-1, key='c', target_value=0),
|
|
337
|
+
cirq.BitMaskKeyCondition(
|
|
338
|
+
bitmask=13, equal_target=False, index=56, key='d', target_value=12
|
|
339
|
+
),
|
|
340
|
+
cirq.BitMaskKeyCondition(
|
|
341
|
+
bitmask=13, equal_target=False, index=-1, key='d', target_value=12
|
|
342
|
+
),
|
|
343
|
+
cirq.BitMaskKeyCondition(bitmask=13, equal_target=True, index=55, key='d', target_value=12),
|
|
344
|
+
cirq.BitMaskKeyCondition(bitmask=13, equal_target=True, index=-1, key='d', target_value=12),
|
|
345
|
+
cirq.BitMaskKeyCondition(bitmask=11, equal_target=True, index=54, key='e', target_value=11),
|
|
346
|
+
cirq.BitMaskKeyCondition(bitmask=11, equal_target=True, index=-1, key='e', target_value=11),
|
|
347
|
+
cirq.BitMaskKeyCondition(bitmask=9, equal_target=False, index=53, key='e', target_value=9),
|
|
348
|
+
cirq.BitMaskKeyCondition(bitmask=9, equal_target=False, index=-1, key='e', target_value=9),
|
|
349
|
+
],
|
|
350
|
+
)
|
|
351
|
+
def test_bitmask_condition_repr(cond):
|
|
352
|
+
cirq.testing.assert_equivalent_repr(cond)
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
def test_bitmask_condition_keys():
|
|
356
|
+
assert cirq.BitMaskKeyCondition('test').keys == ('test',)
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
def test_bitmask_create_equal_mask():
|
|
360
|
+
assert cirq.BitMaskKeyCondition.create_equal_mask('a', 9) == cirq.BitMaskKeyCondition(
|
|
361
|
+
'a', equal_target=True, bitmask=9, target_value=9
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
def test_bitmask_create_not_equal_mask():
|
|
366
|
+
assert cirq.BitMaskKeyCondition.create_not_equal_mask('b', 14) == cirq.BitMaskKeyCondition(
|
|
367
|
+
'b', equal_target=False, bitmask=14, target_value=14
|
|
368
|
+
)
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
def test_bitmask_replace_key():
|
|
372
|
+
cond = cirq.BitMaskKeyCondition('a')
|
|
373
|
+
assert cond.replace_key('a', 'b') == cirq.BitMaskKeyCondition('b')
|
|
374
|
+
assert cond.replace_key('c', 'd') is cond
|
{cirq_core-1.5.0.dev20250330074424.dist-info → cirq_core-1.5.0.dev20250331190555.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cirq-core
|
|
3
|
-
Version: 1.5.0.
|
|
3
|
+
Version: 1.5.0.dev20250331190555
|
|
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
|
{cirq_core-1.5.0.dev20250330074424.dist-info → cirq_core-1.5.0.dev20250331190555.dist-info}/RECORD
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
cirq/__init__.py,sha256=
|
|
1
|
+
cirq/__init__.py,sha256=rUfvQDtywCak2mJQoihOSyRjGxQahK-YOv909us0w5M,28132
|
|
2
2
|
cirq/_compat.py,sha256=_DknO27XngcjEidNApRsCzLUWDS4QmDk9M12BaqP5Is,29531
|
|
3
3
|
cirq/_compat_test.py,sha256=0m3sYIyxRNv9jvAo6rzJ-cnbpny3KGnAByrbU7bApgQ,34720
|
|
4
4
|
cirq/_doc.py,sha256=yDyWUD_2JDS0gShfGRb-rdqRt9-WeL7DhkqX7np0Nko,2879
|
|
5
5
|
cirq/_import.py,sha256=TZOcGFGV9cW53VvNe8ufqOQmrlxRVP9UP0CdRdTbcBw,8401
|
|
6
6
|
cirq/_import_test.py,sha256=6K_v0riZJXOXUphHNkGA8MY-JcmGlezFaGmvrNhm3OQ,1015
|
|
7
|
-
cirq/_version.py,sha256=
|
|
8
|
-
cirq/_version_test.py,sha256=
|
|
7
|
+
cirq/_version.py,sha256=4KCEx3HIsVvpwElMITJ_yy9yTOwwcnPK439KsAn3Z-k,1206
|
|
8
|
+
cirq/_version_test.py,sha256=NjrWCbs0IQ6LxcRo-nkSspuVSy2P2eq3Yh-xaoht0d4,147
|
|
9
9
|
cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
|
|
10
|
-
cirq/json_resolver_cache.py,sha256=
|
|
10
|
+
cirq/json_resolver_cache.py,sha256=YVamU72nCUT5dG0bhAvRKVX5lXcZMNTwP3H36v-cYag,13615
|
|
11
11
|
cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
|
|
12
12
|
cirq/circuits/__init__.py,sha256=HKunqRpZoDmjy1IiK9Cn84MTGT84_PMeQ5VDCPafcWk,1335
|
|
13
13
|
cirq/circuits/_block_diagram_drawer.py,sha256=XuqIQjyHc-B7TaSzuKJe9ZFwzItjxVGdmZjTDw0d2T0,9509
|
|
@@ -406,8 +406,8 @@ cirq/protocols/has_unitary_protocol_test.py,sha256=IjmJ3dqvteFUUO4FLwCTokgUvYy8H
|
|
|
406
406
|
cirq/protocols/hash_from_pickle_test.py,sha256=YvDlLEQKZLhTaVhtHXGB4MntUhxN1Za9rQqf7ZfAfdw,4634
|
|
407
407
|
cirq/protocols/inverse_protocol.py,sha256=aicyqdJVDbd-ZO-wKHA8S_5CcPl3HDhRklSSdosRdy0,4115
|
|
408
408
|
cirq/protocols/inverse_protocol_test.py,sha256=pqqIU4_G4Npc9Z-SeoM9eCB2T5JRTeI02NCXhP0UtaI,2017
|
|
409
|
-
cirq/protocols/json_serialization.py,sha256=
|
|
410
|
-
cirq/protocols/json_serialization_test.py,sha256=
|
|
409
|
+
cirq/protocols/json_serialization.py,sha256=VJCEXB9fkIZh3_d6dkh_QDxwjC3iJAlELGHsCmAMvE4,24779
|
|
410
|
+
cirq/protocols/json_serialization_test.py,sha256=AU2Rdr4gpjkSK0g5LasGf0n22RrdA0MK9ruKPeUmOUo,27976
|
|
411
411
|
cirq/protocols/kraus_protocol.py,sha256=9DROCafRytKDE2VNFtPBV9AGmaX7Ju4h-jPTXy8LDSk,9139
|
|
412
412
|
cirq/protocols/kraus_protocol_test.py,sha256=NYVayiCaEpfvelsoR7bP57lUKn2pjFKYOiVOFHeZn9Q,5400
|
|
413
413
|
cirq/protocols/measurement_key_protocol.py,sha256=vqoxjmthtmQ1nWbi7Xd4fdxFNe5y3WL7DZkQ3M_VPnc,13409
|
|
@@ -442,6 +442,8 @@ cirq/protocols/json_test_data/AsymmetricDepolarizingChannel.json,sha256=dsqeDJmj
|
|
|
442
442
|
cirq/protocols/json_test_data/AsymmetricDepolarizingChannel.repr,sha256=yxGsJgd17f0gqjR6Czu2S4driAi0gd9YElTbtIg3EnE,51
|
|
443
443
|
cirq/protocols/json_test_data/BitFlipChannel.json,sha256=4ZfpIzTz4499IaLZFj2kV2l20JUgNlANYvELa9IW5Qc,47
|
|
444
444
|
cirq/protocols/json_test_data/BitFlipChannel.repr,sha256=z_s9pPlKy_giiBKhm74FH2atbyHyaQDurqFWKwV2CdY,20
|
|
445
|
+
cirq/protocols/json_test_data/BitMaskKeyCondition.json,sha256=e39Vw4ZsMFshlgFfbRYK39XRHdms3eA2P38GiDAzYXY,1596
|
|
446
|
+
cirq/protocols/json_test_data/BitMaskKeyCondition.repr,sha256=bg5EWWsUcYOC9Xb904GnxnCLZJXz8YTUKBNLlx_OGh8,844
|
|
445
447
|
cirq/protocols/json_test_data/BitstringAccumulator.json,sha256=YewIkbw90dcbB0D0mGU5wf4obwH6nsyWO5EG9mh3rtc,5661
|
|
446
448
|
cirq/protocols/json_test_data/BitstringAccumulator.repr,sha256=7jc5mO0lwMODjK4sJAI3hQeHmYyw_jIKMtsSEYN2h9Q,1260
|
|
447
449
|
cirq/protocols/json_test_data/BooleanHamiltonian.json_inward,sha256=oHhPkTBsLogMKpgdAr7RKA4EJ4XNCaSStxalfN-OETQ,218
|
|
@@ -1146,15 +1148,15 @@ cirq/transformers/target_gatesets/cz_gateset.py,sha256=YPprTliaHN_0qITbFwCGr58TC
|
|
|
1146
1148
|
cirq/transformers/target_gatesets/cz_gateset_test.py,sha256=dPXItC91qmmGTsMUR1Fgrgfm54p7GZuMDe9YdR1iVtk,11279
|
|
1147
1149
|
cirq/transformers/target_gatesets/sqrt_iswap_gateset.py,sha256=_zyVEidlvZ2Grk4prWW390heLcCn9boiqRmfpBiL-PY,6278
|
|
1148
1150
|
cirq/transformers/target_gatesets/sqrt_iswap_gateset_test.py,sha256=T1Q7TVUiVbLkqhBOaVMtZpgd_pABU157cV9zrcztaZc,14392
|
|
1149
|
-
cirq/value/__init__.py,sha256=
|
|
1151
|
+
cirq/value/__init__.py,sha256=0OQimJUEjmT8HGPqRWYhWTEBuA9sMAD3IfwVTVbwrVc,2947
|
|
1150
1152
|
cirq/value/abc_alt.py,sha256=aTWmYTHNFu6yD8i7HcUMfsautsGbPoKuasNFe6-Vq3Q,5997
|
|
1151
1153
|
cirq/value/abc_alt_test.py,sha256=-N4ZZPVhkm1E5LaB2ZQEkOVObGFcbZbkdhS669cTtOg,9013
|
|
1152
1154
|
cirq/value/angle.py,sha256=uPa6RrAF-fH4vS8DxWVfBug1FZmT0yEMXdd4VlWOaJw,3315
|
|
1153
1155
|
cirq/value/angle_test.py,sha256=PqeTBGJw6zfain4cG8FYMobtYQsfyxLQeBu_CF5fIjg,3548
|
|
1154
1156
|
cirq/value/classical_data.py,sha256=LFW7Q87mjg-KpuU5iJqxyDFNqre5AlHUCXbMVKwFVV4,11608
|
|
1155
1157
|
cirq/value/classical_data_test.py,sha256=23ZraKZ-V3p-uux21bkcboQcEp81RW6VKnVIYPQc6_o,5231
|
|
1156
|
-
cirq/value/condition.py,sha256=
|
|
1157
|
-
cirq/value/condition_test.py,sha256=
|
|
1158
|
+
cirq/value/condition.py,sha256=QXgAsLYN6SYRGCsteMEykH-EKplFs59fGANNc9IqZWY,11997
|
|
1159
|
+
cirq/value/condition_test.py,sha256=RTDP4N3gGiAKX_tdpo1js0d2bK3jAfUFKXsrpN1q8CU,12913
|
|
1158
1160
|
cirq/value/digits.py,sha256=PLpenXpyhrtEpEETVe3rMle4IKZVGL4GrW5ugThHkeA,6024
|
|
1159
1161
|
cirq/value/digits_test.py,sha256=evx-y619LfjSN_gUO1B6K7O80X5HJmxxBPl61RrOovo,3812
|
|
1160
1162
|
cirq/value/duration.py,sha256=ieN9IMYMAr33VdakbbkTpebs2sfniHc0RXfAD7WGZyc,10358
|
|
@@ -1206,8 +1208,8 @@ cirq/work/sampler.py,sha256=sW0RhIelGABAKbqTM58shwyyCPgf86JIv9IGdJe__js,19186
|
|
|
1206
1208
|
cirq/work/sampler_test.py,sha256=mdk1J-WrvbPUYhY41VhWf9_te4DnXr_XMPcugWwc4-I,13281
|
|
1207
1209
|
cirq/work/zeros_sampler.py,sha256=8_Ne6dBkDANtTZuql7Eb0Qg_E_P3-_gu-ybFzxTbKAQ,2356
|
|
1208
1210
|
cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
|
|
1209
|
-
cirq_core-1.5.0.
|
|
1210
|
-
cirq_core-1.5.0.
|
|
1211
|
-
cirq_core-1.5.0.
|
|
1212
|
-
cirq_core-1.5.0.
|
|
1213
|
-
cirq_core-1.5.0.
|
|
1211
|
+
cirq_core-1.5.0.dev20250331190555.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
|
|
1212
|
+
cirq_core-1.5.0.dev20250331190555.dist-info/METADATA,sha256=ODiWyZ5E0kLarUwUl48ul8uQBpJ7u9DmZdUM0q0GqkU,4564
|
|
1213
|
+
cirq_core-1.5.0.dev20250331190555.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
1214
|
+
cirq_core-1.5.0.dev20250331190555.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
|
|
1215
|
+
cirq_core-1.5.0.dev20250331190555.dist-info/RECORD,,
|
{cirq_core-1.5.0.dev20250330074424.dist-info → cirq_core-1.5.0.dev20250331190555.dist-info}/LICENSE
RENAMED
|
File without changes
|
{cirq_core-1.5.0.dev20250330074424.dist-info → cirq_core-1.5.0.dev20250331190555.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|