cirq-core 1.5.0.dev20241206010229__py3-none-any.whl → 1.5.0.dev20241207174114__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_test_data/Concat.json +19 -0
- cirq/protocols/json_test_data/Concat.repr +1 -0
- cirq/study/__init__.py +1 -0
- cirq/study/sweeps.py +57 -0
- cirq/study/sweeps_test.py +104 -0
- {cirq_core-1.5.0.dev20241206010229.dist-info → cirq_core-1.5.0.dev20241207174114.dist-info}/METADATA +1 -1
- {cirq_core-1.5.0.dev20241206010229.dist-info → cirq_core-1.5.0.dev20241207174114.dist-info}/RECORD +14 -12
- {cirq_core-1.5.0.dev20241206010229.dist-info → cirq_core-1.5.0.dev20241207174114.dist-info}/LICENSE +0 -0
- {cirq_core-1.5.0.dev20241206010229.dist-info → cirq_core-1.5.0.dev20241207174114.dist-info}/WHEEL +0 -0
- {cirq_core-1.5.0.dev20241206010229.dist-info → cirq_core-1.5.0.dev20241207174114.dist-info}/top_level.txt +0 -0
cirq/__init__.py
CHANGED
cirq/_version.py
CHANGED
cirq/_version_test.py
CHANGED
cirq/json_resolver_cache.py
CHANGED
|
@@ -120,6 +120,7 @@ def _class_resolver_dictionary() -> Dict[str, ObjectFactory]:
|
|
|
120
120
|
'CliffordState': cirq.CliffordState,
|
|
121
121
|
'CliffordTableau': cirq.CliffordTableau,
|
|
122
122
|
'CNotPowGate': cirq.CNotPowGate,
|
|
123
|
+
'Concat': cirq.Concat,
|
|
123
124
|
'ConstantQubitNoiseModel': cirq.ConstantQubitNoiseModel,
|
|
124
125
|
'ControlledGate': cirq.ControlledGate,
|
|
125
126
|
'ControlledOperation': cirq.ControlledOperation,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cirq.Concat(cirq.Linspace('a', start=0, stop=1, length=2), cirq.Linspace('a', start=0, stop=2, length=4))
|
cirq/study/__init__.py
CHANGED
cirq/study/sweeps.py
CHANGED
|
@@ -276,6 +276,63 @@ class Product(Sweep):
|
|
|
276
276
|
return Product(*factors)
|
|
277
277
|
|
|
278
278
|
|
|
279
|
+
class Concat(Sweep):
|
|
280
|
+
"""Concatenates multiple to a new sweep.
|
|
281
|
+
|
|
282
|
+
All sweeps must share the same descriptors.
|
|
283
|
+
|
|
284
|
+
If one sweep assigns 'a' to the values 0, 1, 2, and another sweep assigns
|
|
285
|
+
'a' to the values 3, 4, 5, the concatenation produces a sweep assigning
|
|
286
|
+
'a' to the values 0, 1, 2, 3, 4, 5 in sequence.
|
|
287
|
+
"""
|
|
288
|
+
|
|
289
|
+
def __init__(self, *sweeps: Sweep) -> None:
|
|
290
|
+
if not sweeps:
|
|
291
|
+
raise ValueError("Concat requires at least one sweep.")
|
|
292
|
+
|
|
293
|
+
# Validate consistency across sweeps
|
|
294
|
+
first_sweep = sweeps[0]
|
|
295
|
+
for sweep in sweeps[1:]:
|
|
296
|
+
if sweep.keys != first_sweep.keys:
|
|
297
|
+
raise ValueError("All sweeps must have the same descriptors.")
|
|
298
|
+
|
|
299
|
+
self.sweeps = sweeps
|
|
300
|
+
|
|
301
|
+
def __eq__(self, other):
|
|
302
|
+
if not isinstance(other, Concat):
|
|
303
|
+
return NotImplemented
|
|
304
|
+
return self.sweeps == other.sweeps
|
|
305
|
+
|
|
306
|
+
def __hash__(self):
|
|
307
|
+
return hash(tuple(self.sweeps))
|
|
308
|
+
|
|
309
|
+
@property
|
|
310
|
+
def keys(self) -> List['cirq.TParamKey']:
|
|
311
|
+
return self.sweeps[0].keys
|
|
312
|
+
|
|
313
|
+
def __len__(self) -> int:
|
|
314
|
+
return sum(len(sweep) for sweep in self.sweeps)
|
|
315
|
+
|
|
316
|
+
def param_tuples(self) -> Iterator[Params]:
|
|
317
|
+
for sweep in self.sweeps:
|
|
318
|
+
yield from sweep.param_tuples()
|
|
319
|
+
|
|
320
|
+
def __repr__(self) -> str:
|
|
321
|
+
sweeps_repr = ', '.join(repr(sweep) for sweep in self.sweeps)
|
|
322
|
+
return f'cirq.Concat({sweeps_repr})'
|
|
323
|
+
|
|
324
|
+
def __str__(self) -> str:
|
|
325
|
+
sweeps_repr = ', '.join(repr(s) for s in self.sweeps)
|
|
326
|
+
return f'Concat({sweeps_repr})'
|
|
327
|
+
|
|
328
|
+
def _json_dict_(self) -> Dict[str, Any]:
|
|
329
|
+
return protocols.obj_to_dict_helper(self, ['sweeps'])
|
|
330
|
+
|
|
331
|
+
@classmethod
|
|
332
|
+
def _from_json_dict_(cls, sweeps, **kwargs):
|
|
333
|
+
return Concat(*sweeps)
|
|
334
|
+
|
|
335
|
+
|
|
279
336
|
class Zip(Sweep):
|
|
280
337
|
"""Zip product (direct sum) of one or more sweeps.
|
|
281
338
|
|
cirq/study/sweeps_test.py
CHANGED
|
@@ -246,6 +246,8 @@ def test_equality():
|
|
|
246
246
|
et.make_equality_group(lambda: cirq.Linspace('b', 0, 10, 11))
|
|
247
247
|
et.make_equality_group(lambda: cirq.Points('a', list(range(11))))
|
|
248
248
|
et.make_equality_group(lambda: cirq.Points('b', list(range(11))))
|
|
249
|
+
et.make_equality_group(lambda: cirq.Concat(cirq.Linspace('a', 0, 10, 11)))
|
|
250
|
+
et.make_equality_group(lambda: cirq.Concat(cirq.Linspace('b', 0, 10, 11)))
|
|
249
251
|
|
|
250
252
|
# Product and Zip sweeps can also be equated.
|
|
251
253
|
et.make_equality_group(lambda: cirq.Linspace('a', 0, 5, 6) * cirq.Linspace('b', 10, 15, 6))
|
|
@@ -373,3 +375,105 @@ def test_dict_to_zip_sweep():
|
|
|
373
375
|
assert cirq.dict_to_zip_sweep({'t': [0, 1], 's': [2, 3], 'r': 4}) == (
|
|
374
376
|
cirq.Zip(cirq.Points('t', [0, 1]), cirq.Points('s', [2, 3]), cirq.Points('r', [4]))
|
|
375
377
|
)
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
def test_concat_linspace():
|
|
381
|
+
sweep1 = cirq.Linspace('a', 0.34, 9.16, 4)
|
|
382
|
+
sweep2 = cirq.Linspace('a', 10, 20, 4)
|
|
383
|
+
concat_sweep = cirq.Concat(sweep1, sweep2)
|
|
384
|
+
|
|
385
|
+
assert len(concat_sweep) == 8
|
|
386
|
+
assert concat_sweep.keys == ['a']
|
|
387
|
+
params = list(concat_sweep.param_tuples())
|
|
388
|
+
assert len(params) == 8
|
|
389
|
+
assert params[0] == (('a', 0.34),)
|
|
390
|
+
assert params[3] == (('a', 9.16),)
|
|
391
|
+
assert params[4] == (('a', 10.0),)
|
|
392
|
+
assert params[7] == (('a', 20.0),)
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
def test_concat_points():
|
|
396
|
+
sweep1 = cirq.Points('a', [1, 2])
|
|
397
|
+
sweep2 = cirq.Points('a', [3, 4, 5])
|
|
398
|
+
concat_sweep = cirq.Concat(sweep1, sweep2)
|
|
399
|
+
|
|
400
|
+
assert concat_sweep.keys == ['a']
|
|
401
|
+
assert len(concat_sweep) == 5
|
|
402
|
+
params = list(concat_sweep)
|
|
403
|
+
assert len(params) == 5
|
|
404
|
+
assert _values(concat_sweep, 'a') == [1, 2, 3, 4, 5]
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
def test_concat_many_points():
|
|
408
|
+
sweep1 = cirq.Points('a', [1, 2])
|
|
409
|
+
sweep2 = cirq.Points('a', [3, 4, 5])
|
|
410
|
+
sweep3 = cirq.Points('a', [6, 7, 8])
|
|
411
|
+
concat_sweep = cirq.Concat(sweep1, sweep2, sweep3)
|
|
412
|
+
|
|
413
|
+
assert len(concat_sweep) == 8
|
|
414
|
+
params = list(concat_sweep)
|
|
415
|
+
assert len(params) == 8
|
|
416
|
+
assert _values(concat_sweep, 'a') == [1, 2, 3, 4, 5, 6, 7, 8]
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
def test_concat_mixed():
|
|
420
|
+
sweep1 = cirq.Linspace('a', 0, 1, 3)
|
|
421
|
+
sweep2 = cirq.Points('a', [2, 3])
|
|
422
|
+
concat_sweep = cirq.Concat(sweep1, sweep2)
|
|
423
|
+
|
|
424
|
+
assert len(concat_sweep) == 5
|
|
425
|
+
assert _values(concat_sweep, 'a') == [0.0, 0.5, 1.0, 2, 3]
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
def test_concat_inconsistent_keys():
|
|
429
|
+
sweep1 = cirq.Linspace('a', 0, 1, 3)
|
|
430
|
+
sweep2 = cirq.Points('b', [2, 3])
|
|
431
|
+
|
|
432
|
+
with pytest.raises(ValueError, match="All sweeps must have the same descriptors"):
|
|
433
|
+
cirq.Concat(sweep1, sweep2)
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
def test_concat_sympy_symbol():
|
|
437
|
+
a = sympy.Symbol('a')
|
|
438
|
+
sweep1 = cirq.Linspace(a, 0, 1, 3)
|
|
439
|
+
sweep2 = cirq.Points(a, [2, 3])
|
|
440
|
+
concat_sweep = cirq.Concat(sweep1, sweep2)
|
|
441
|
+
|
|
442
|
+
assert len(concat_sweep) == 5
|
|
443
|
+
assert _values(concat_sweep, 'a') == [0.0, 0.5, 1.0, 2, 3]
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
def test_concat_repr_and_str():
|
|
447
|
+
sweep1 = cirq.Linspace('a', 0, 1, 3)
|
|
448
|
+
sweep2 = cirq.Points('a', [2, 3])
|
|
449
|
+
concat_sweep = cirq.Concat(sweep1, sweep2)
|
|
450
|
+
|
|
451
|
+
expected_repr = (
|
|
452
|
+
"cirq.Concat(cirq.Linspace('a', start=0, stop=1, length=3), cirq.Points('a', [2, 3]))"
|
|
453
|
+
)
|
|
454
|
+
expected_str = "Concat(cirq.Linspace('a', start=0, stop=1, length=3), cirq.Points('a', [2, 3]))"
|
|
455
|
+
|
|
456
|
+
assert repr(concat_sweep) == expected_repr
|
|
457
|
+
assert str(concat_sweep) == expected_str
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
def test_concat_large_sweep():
|
|
461
|
+
sweep1 = cirq.Points('a', list(range(101)))
|
|
462
|
+
sweep2 = cirq.Points('a', list(range(101, 202)))
|
|
463
|
+
concat_sweep = cirq.Concat(sweep1, sweep2)
|
|
464
|
+
|
|
465
|
+
assert len(concat_sweep) == 202
|
|
466
|
+
assert _values(concat_sweep, 'a') == list(range(101)) + list(range(101, 202))
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
def test_concat_different_keys_raises():
|
|
470
|
+
sweep1 = cirq.Linspace('a', 0, 1, 3)
|
|
471
|
+
sweep2 = cirq.Points('b', [2, 3])
|
|
472
|
+
|
|
473
|
+
with pytest.raises(ValueError, match="All sweeps must have the same descriptors."):
|
|
474
|
+
_ = cirq.Concat(sweep1, sweep2)
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
def test_concat_empty_sweep_raises():
|
|
478
|
+
with pytest.raises(ValueError, match="Concat requires at least one sweep."):
|
|
479
|
+
_ = cirq.Concat()
|
{cirq_core-1.5.0.dev20241206010229.dist-info → cirq_core-1.5.0.dev20241207174114.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.dev20241207174114
|
|
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.dev20241206010229.dist-info → cirq_core-1.5.0.dev20241207174114.dist-info}/RECORD
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
cirq/__init__.py,sha256=
|
|
1
|
+
cirq/__init__.py,sha256=Qi4qkUVdT7je-13VrMLdVVcF1RPHI3nR8oTUs90l9OI,28084
|
|
2
2
|
cirq/_compat.py,sha256=wl0Z7OYLpt07Vjts5l82jWjZE3WTy3uMHXaHwLwZKuo,29406
|
|
3
3
|
cirq/_compat_test.py,sha256=Qq3ZcfgD-Nb81cEppQdJqhAyrVqXKtfXZYGXT0p-Wh0,34718
|
|
4
4
|
cirq/_doc.py,sha256=yDyWUD_2JDS0gShfGRb-rdqRt9-WeL7DhkqX7np0Nko,2879
|
|
5
5
|
cirq/_import.py,sha256=p9gMHJscbtDDkfHOaulvd3Aer0pwUF5AXpL89XR8dNw,8402
|
|
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=A1qNRdgJODR_Wy5kBLRlVgJNks--0in6YvmUS5F2rpw,1206
|
|
8
|
+
cirq/_version_test.py,sha256=mvMHDO3Ij5dj8js-w0cA8h2l4jZ7ohKrSCr7admuD6Q,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=03MVo6Y-UYrzt9CKHmwpiBLN2ixL6uSU-OWnKZXfG7k,13302
|
|
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=06ceNV01cMx4irIGYnztfLt_HDNhK3AwfsiNh686hjU,9510
|
|
@@ -501,6 +501,8 @@ cirq/protocols/json_test_data/CliffordState.repr,sha256=irZZrWXfNYM-bjA4IqHhgJMl
|
|
|
501
501
|
cirq/protocols/json_test_data/CliffordState.repr_inward,sha256=irZZrWXfNYM-bjA4IqHhgJMlTDlG6rtlP34t9ix71co,52
|
|
502
502
|
cirq/protocols/json_test_data/CliffordTableau.json,sha256=ErcX0cp1XEM28GvuVCxbWNLOx7OfVQtsB6cYwGOHfms,209
|
|
503
503
|
cirq/protocols/json_test_data/CliffordTableau.repr,sha256=BA-VCQ1WeZNyhIwlQLeZUiLCeU2mTVuY4LA9Og0tJZE,34
|
|
504
|
+
cirq/protocols/json_test_data/Concat.json,sha256=yBNdsxH1jxEcLPnGpW1Ndji-68C1N8M-CQnco0WWCWA,311
|
|
505
|
+
cirq/protocols/json_test_data/Concat.repr,sha256=WG2vmD9Z1odmwXJA2N68cFjz4DkkoHJYPGNzOc0NUWo,105
|
|
504
506
|
cirq/protocols/json_test_data/ConstantQubitNoiseModel.json,sha256=dbe4xJvXXIOv1KyjGJXlvJ3kd3W7XEHQt5xFY0bGEtk,144
|
|
505
507
|
cirq/protocols/json_test_data/ConstantQubitNoiseModel.repr,sha256=OIRaaB6GlqJY_8TkEwvZQ8VpbPNi6fWii1vhTJn0t4o,36
|
|
506
508
|
cirq/protocols/json_test_data/ControlledGate.json,sha256=CjFsQaCrr84mZ-fD2els2AQ0QZNlK9Jv4AP0znV02kA,757
|
|
@@ -933,7 +935,7 @@ cirq/sim/clifford/stabilizer_simulation_state.py,sha256=mqADFqLHg2Kit9EsuhNp8ntZ
|
|
|
933
935
|
cirq/sim/clifford/stabilizer_simulation_state_test.py,sha256=dsphoXTaIwRCjprGJQirSs0qeVKHlni_pt_GZJn5Vpc,4317
|
|
934
936
|
cirq/sim/clifford/stabilizer_state_ch_form.py,sha256=vyyIKLcI-_Ox1QQbUSbTj_Zo4hotpDwvxQQ2u7zJxns,14049
|
|
935
937
|
cirq/sim/clifford/stabilizer_state_ch_form_test.py,sha256=FK0IsyrTfT6ZPZeBYmyPG2xpzUT7RG6P6UQw_61c6kU,3149
|
|
936
|
-
cirq/study/__init__.py,sha256=
|
|
938
|
+
cirq/study/__init__.py,sha256=OyJhZjBiEkNbtSuSZaOwHGwwnOIGgnn-W8ec0xHhHBI,1647
|
|
937
939
|
cirq/study/flatten_expressions.py,sha256=B-CQcj8eSWAJPIff5bQiZGobnYx8kB0c5WTLowfCVXo,15604
|
|
938
940
|
cirq/study/flatten_expressions_test.py,sha256=6e7pTkaBrZW-EmG4teZxcwemqnxCtJW3kq2KOlPcwW8,6078
|
|
939
941
|
cirq/study/resolver.py,sha256=dDEGIwWueP7ZICbEAUc6G5li2UoTFkPS9Qs2dSDCbV8,11906
|
|
@@ -942,8 +944,8 @@ cirq/study/result.py,sha256=KzjpjvDVCTFjMyq9r91pZSYdtcD1x3yj8jP_StlOSMg,19285
|
|
|
942
944
|
cirq/study/result_test.py,sha256=fq5BH78RswfTiYjMchJ4wEDDyaJu0QdJoGobMjKDeSI,15591
|
|
943
945
|
cirq/study/sweepable.py,sha256=hHBXn5MQZJawiiIXWZdn_qygbPeIFtt300wIqVHiYl8,4356
|
|
944
946
|
cirq/study/sweepable_test.py,sha256=ENv03_GJmbUc_ukJoqfgG-H5C_yyx1jCcvxohSMyQVU,5502
|
|
945
|
-
cirq/study/sweeps.py,sha256=
|
|
946
|
-
cirq/study/sweeps_test.py,sha256=
|
|
947
|
+
cirq/study/sweeps.py,sha256=v7wP0hh528tK4LRbNJU848ypbb2jTQgPZKY2oz7o7vA,21599
|
|
948
|
+
cirq/study/sweeps_test.py,sha256=rgnU7zB7hxOXLbalYJb0yy_QPCOd-LxKgUir1bcyC2s,15426
|
|
947
949
|
cirq/testing/__init__.py,sha256=m_HUdHcJ3HcKpGQBKCwZ6E6QSkKpIN-dUGr4e75o4tY,6217
|
|
948
950
|
cirq/testing/circuit_compare.py,sha256=nBQES45wLVThOqC3WrPrYKLQP7HQ2pH5DjlJ5bHkrtU,19176
|
|
949
951
|
cirq/testing/circuit_compare_test.py,sha256=AduZCzwBNFCYrjEpyS1DvIR6jU8GaFqQBBgPXyIALoU,19743
|
|
@@ -1187,8 +1189,8 @@ cirq/work/sampler.py,sha256=bE5tmVkcR6cZZMLETxDfHehdsYUMbx2RvBeIBetehI4,19187
|
|
|
1187
1189
|
cirq/work/sampler_test.py,sha256=hL2UWx3dz2ukZVNxWftiKVvJcQoLplLZdQm-k1QcA40,13282
|
|
1188
1190
|
cirq/work/zeros_sampler.py,sha256=x1C7cup66a43n-3tm8QjhiqJa07qcJW10FxNp9jJ59Q,2356
|
|
1189
1191
|
cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
|
|
1190
|
-
cirq_core-1.5.0.
|
|
1191
|
-
cirq_core-1.5.0.
|
|
1192
|
-
cirq_core-1.5.0.
|
|
1193
|
-
cirq_core-1.5.0.
|
|
1194
|
-
cirq_core-1.5.0.
|
|
1192
|
+
cirq_core-1.5.0.dev20241207174114.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
|
|
1193
|
+
cirq_core-1.5.0.dev20241207174114.dist-info/METADATA,sha256=GXOgvkVTPhl38qPeUxSwCABUFmCW-Dow6rJFVCrWvz8,1992
|
|
1194
|
+
cirq_core-1.5.0.dev20241207174114.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
1195
|
+
cirq_core-1.5.0.dev20241207174114.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
|
|
1196
|
+
cirq_core-1.5.0.dev20241207174114.dist-info/RECORD,,
|
{cirq_core-1.5.0.dev20241206010229.dist-info → cirq_core-1.5.0.dev20241207174114.dist-info}/LICENSE
RENAMED
|
File without changes
|
{cirq_core-1.5.0.dev20241206010229.dist-info → cirq_core-1.5.0.dev20241207174114.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|