cirq-core 1.2.0.dev20230519015255__py3-none-any.whl → 1.2.0.dev20230523193942__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.
cirq/_version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "1.2.0.dev20230519015255"
1
+ __version__ = "1.2.0.dev20230523193942"
@@ -1,7 +1,20 @@
1
- {
2
- "cirq_type": "Linspace",
3
- "key": "a",
4
- "start": 0,
5
- "stop": 1,
6
- "length": 4
7
- }
1
+ [
2
+ {
3
+ "cirq_type": "Linspace",
4
+ "key": "a",
5
+ "start": 0,
6
+ "stop": 1,
7
+ "length": 4
8
+ },
9
+ {
10
+ "cirq_type": "Linspace",
11
+ "key": "b",
12
+ "start": 1,
13
+ "stop": 2,
14
+ "length": 3,
15
+ "metadata": {
16
+ "cirq_type": "NamedQubit",
17
+ "name": "b"
18
+ }
19
+ }
20
+ ]
@@ -1 +1,4 @@
1
- cirq.Linspace("a", start=0, stop=1, length=4)
1
+ [
2
+ cirq.Linspace("a", start=0, stop=1, length=4),
3
+ cirq.Linspace("b", start=1, stop=2, length=3, metadata=cirq.NamedQubit("b"))
4
+ ]
@@ -1,8 +1,19 @@
1
- {
2
- "cirq_type": "Points",
3
- "key": "a",
4
- "points": [
5
- 0,
6
- 0.4
7
- ]
8
- }
1
+ [
2
+ {
3
+ "cirq_type": "Points",
4
+ "key": "a",
5
+ "points": [
6
+ 0,
7
+ 0.4
8
+ ]
9
+ },
10
+ {
11
+ "cirq_type": "Points",
12
+ "key": "amp",
13
+ "points": [
14
+ 0,
15
+ 1
16
+ ],
17
+ "metadata": "used to turn amp on or off"
18
+ }
19
+ ]
@@ -1 +1,4 @@
1
- cirq.Points('a', [0, 0.4])
1
+ [
2
+ cirq.Points('a', [0, 0.4]),
3
+ cirq.Points('amp', [0, 1], metadata='used to turn amp on or off'),
4
+ ]
cirq/study/sweeps.py CHANGED
@@ -18,6 +18,7 @@ from typing import (
18
18
  Iterable,
19
19
  Iterator,
20
20
  List,
21
+ Optional,
21
22
  overload,
22
23
  Sequence,
23
24
  TYPE_CHECKING,
@@ -421,9 +422,23 @@ class SingleSweep(Sweep):
421
422
  class Points(SingleSweep):
422
423
  """A simple sweep with explicitly supplied values."""
423
424
 
424
- def __init__(self, key: 'cirq.TParamKey', points: Sequence[float]) -> None:
425
- super(Points, self).__init__(key)
425
+ def __init__(
426
+ self, key: 'cirq.TParamKey', points: Sequence[float], metadata: Optional[Any] = None
427
+ ) -> None:
428
+ """Creates a sweep on a variable with supplied values.
429
+
430
+ Args:
431
+ key: sympy.Symbol or equivalent to sweep across.
432
+ points: sequence of floating point values that represent
433
+ the values to sweep across. The length of the sweep
434
+ will be equivalent to the length of this sequence.
435
+ metadata: Optional metadata to attach to the sweep to
436
+ annotate the sweep or its variable.
437
+
438
+ """
439
+ super().__init__(key)
426
440
  self.points = points
441
+ self.metadata = metadata
427
442
 
428
443
  def _tuple(self) -> Tuple[Union[str, sympy.Expr], Sequence[float]]:
429
444
  return self.key, tuple(self.points)
@@ -435,25 +450,44 @@ class Points(SingleSweep):
435
450
  return iter(self.points)
436
451
 
437
452
  def __repr__(self) -> str:
438
- return f'cirq.Points({self.key!r}, {self.points!r})'
453
+ metadata_repr = f', metadata={self.metadata!r}' if self.metadata is not None else ""
454
+ return f'cirq.Points({self.key!r}, {self.points!r}{metadata_repr})'
439
455
 
440
456
  def _json_dict_(self) -> Dict[str, Any]:
457
+ if self.metadata is not None:
458
+ return protocols.obj_to_dict_helper(self, ["key", "points", "metadata"])
441
459
  return protocols.obj_to_dict_helper(self, ["key", "points"])
442
460
 
443
461
 
444
462
  class Linspace(SingleSweep):
445
463
  """A simple sweep over linearly-spaced values."""
446
464
 
447
- def __init__(self, key: 'cirq.TParamKey', start: float, stop: float, length: int) -> None:
465
+ def __init__(
466
+ self,
467
+ key: 'cirq.TParamKey',
468
+ start: float,
469
+ stop: float,
470
+ length: int,
471
+ metadata: Optional[Any] = None,
472
+ ) -> None:
448
473
  """Creates a linear-spaced sweep for a given key.
449
474
 
450
475
  For the given args, assigns to the list of values
451
476
  start, start + (stop - start) / (length - 1), ..., stop
477
+
478
+ Args:
479
+ key: sympy.Symbol or equivalent to sweep across.
480
+ start: minimum value of linear sweep.
481
+ stop: maximum value of linear sweep.
482
+ length: number of points in the sweep.
483
+ metadata: Optional metadata to attach to the sweep to
484
+ annotate the sweep or its variable.
452
485
  """
453
- super(Linspace, self).__init__(key)
486
+ super().__init__(key)
454
487
  self.start = start
455
488
  self.stop = stop
456
489
  self.length = length
490
+ self.metadata = metadata
457
491
 
458
492
  def _tuple(self) -> Tuple[Union[str, sympy.Expr], float, float, int]:
459
493
  return (self.key, self.start, self.stop, self.length)
@@ -470,12 +504,17 @@ class Linspace(SingleSweep):
470
504
  yield self.start * (1 - p) + self.stop * p
471
505
 
472
506
  def __repr__(self) -> str:
507
+ metadata_repr = f', metadata={self.metadata!r}' if self.metadata is not None else ""
473
508
  return (
474
509
  f'cirq.Linspace({self.key!r}, start={self.start!r}, '
475
- f'stop={self.stop!r}, length={self.length!r})'
510
+ f'stop={self.stop!r}, length={self.length!r}{metadata_repr})'
476
511
  )
477
512
 
478
513
  def _json_dict_(self) -> Dict[str, Any]:
514
+ if self.metadata is not None:
515
+ return protocols.obj_to_dict_helper(
516
+ self, ["key", "start", "stop", "length", "metadata"]
517
+ )
479
518
  return protocols.obj_to_dict_helper(self, ["key", "start", "stop", "length"])
480
519
 
481
520
 
cirq/study/sweeps_test.py CHANGED
@@ -273,6 +273,12 @@ def test_repr():
273
273
  )
274
274
  cirq.testing.assert_equivalent_repr(cirq.Points('zero&pi', [0, 3.14159]))
275
275
  cirq.testing.assert_equivalent_repr(cirq.Linspace('I/10', 0, 1, 10))
276
+ cirq.testing.assert_equivalent_repr(
277
+ cirq.Points('zero&pi', [0, 3.14159], metadata='example str')
278
+ )
279
+ cirq.testing.assert_equivalent_repr(
280
+ cirq.Linspace('for_q0', 0, 1, 10, metadata=cirq.LineQubit(0))
281
+ )
276
282
 
277
283
 
278
284
  def test_zip_product_str():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cirq-core
3
- Version: 1.2.0.dev20230519015255
3
+ Version: 1.2.0.dev20230523193942
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
@@ -4,7 +4,7 @@ cirq/_compat_test.py,sha256=715FwOmqB8ZFhREgMHckalA0txpGgOMfien8c5o1h0U,34178
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=ImkfZZRnsS1iFt47Mr4q-GqCnVC-Wgt5sssulL4WtJU,40
7
+ cirq/_version.py,sha256=4-SYoxE_lRq5qjSnLKj-TnatcLDnN4TlwI37HrJ7U7Y,40
8
8
  cirq/_version_test.py,sha256=ZM9GLAiU02rzyJQ_HOT2o_tZixJ0lMXs4tCkOareqTA,133
9
9
  cirq/conftest.py,sha256=mHCDs5--u17oLFDAfIlkTS4TRGSc35eLnZ2CXuIuB7I,1175
10
10
  cirq/json_resolver_cache.py,sha256=JJiO1dhHsEqYClUv68eg-hiOzbb_C1QiQ-BCcvoe4Ck,13067
@@ -593,8 +593,8 @@ cirq/protocols/json_test_data/LineTopology.json,sha256=zy-oVNfzkyc7DwLHfWXUNjxzT
593
593
  cirq/protocols/json_test_data/LineTopology.repr,sha256=6XRmh7knnEW1zeWssm26_ySTY7xyNUKkne_ol7otidg,30
594
594
  cirq/protocols/json_test_data/LinearDict.json,sha256=EqCoSR3SqwmTfkuqII-AP7iL0EObemfWvlFAfCAsX1I,520
595
595
  cirq/protocols/json_test_data/LinearDict.repr,sha256=nzooCij_zEBNKhKW6q33JahEvuHfLIKvzHOuG3CtmOI,126
596
- cirq/protocols/json_test_data/Linspace.json,sha256=XtvkCdUvOSE9TfAlQB_ZEwtzh-Dzk4U71eWufqIDtZY,85
597
- cirq/protocols/json_test_data/Linspace.repr,sha256=bwbI37oBpIvJTjfImNusTZ53WRaCHcJuu7ss5s15fP4,45
596
+ cirq/protocols/json_test_data/Linspace.json,sha256=ygvT3kNsZuq_PKyPRhRthfOHXCfsaYthGXlhdTsE9m8,329
597
+ cirq/protocols/json_test_data/Linspace.repr,sha256=PJbvEv4bwJckZhaTTtgiuzI-9ug-fYXKi4FhbvSj73E,136
598
598
  cirq/protocols/json_test_data/ListSweep.json,sha256=I1_NvIs06X4xaZdswIvXb0FD_DopX54TPhSZ_MizMRQ,311
599
599
  cirq/protocols/json_test_data/ListSweep.repr,sha256=8pbPgdn325CqWWWHKO40KV1guu97zBABL_AL1E9CS8A,81
600
600
  cirq/protocols/json_test_data/MatrixGate.json,sha256=0wyhxqGnR-j5roWX58TC2mRwkulO8796D9nRGYbaMhw,3806
@@ -667,8 +667,8 @@ cirq/protocols/json_test_data/PhasedXPowGate.json,sha256=ewn2xXnpIVF7NjvG5HjiaIY
667
667
  cirq/protocols/json_test_data/PhasedXPowGate.repr,sha256=zI_RuyoAIM-EslzgKf6aDeEE08L29zquNKeyRbfzEUM,77
668
668
  cirq/protocols/json_test_data/PhasedXZGate.json,sha256=rMzDLWKmNnTY8P5oLyqYYbUYhr-ZVAFrsGh6yVuBPKk,123
669
669
  cirq/protocols/json_test_data/PhasedXZGate.repr,sha256=VFYDGRF1Hry_RSHRARfaVJqwCot5N4UPxN6dLP9ubWQ,81
670
- cirq/protocols/json_test_data/Points.json,sha256=bkPTIda9-ZgG7cg4gyA-994ZZGb5PFZEP6eAnemhpMo,75
671
- cirq/protocols/json_test_data/Points.repr,sha256=wer06uz5U-DmcP2tNx82UpfOrHcGLLXhKUHqci_MIPA,26
670
+ cirq/protocols/json_test_data/Points.json,sha256=GNCyYvsJqDwWzAYMtZ7xOXb7V7W92-uKOZXTW0SAZds,269
671
+ cirq/protocols/json_test_data/Points.repr,sha256=lu59UtH-fJdBZ63pycWOyVAYg0sZfFHjqAvfmcbFj6o,107
672
672
  cirq/protocols/json_test_data/Product.json,sha256=MJDuyFnoWdanmKRisswWNcQ-Ma3LA2NczLQRTSzNz9k,277
673
673
  cirq/protocols/json_test_data/Product.repr,sha256=qrZLz0E3ibSAbdFOnlNhoYciOqU8EhpbX0scqEz73Dg,107
674
674
  cirq/protocols/json_test_data/ProductOfSums.json,sha256=L7tvSt3w6hjqcqt6VFonRybF6oAMCO5n1bBfOqa4xjU,101
@@ -918,8 +918,8 @@ cirq/study/result.py,sha256=rvExmeYnHbFKKkRU9zdBtxrCm8Y4B3UycZf62QTeOP0,18772
918
918
  cirq/study/result_test.py,sha256=3hmwqehcv-LukZtrUY3q1PAQlawPKXDraiTeElKvDWI,15347
919
919
  cirq/study/sweepable.py,sha256=BMgq8lxVnyJGBeu4gFUt_0P_v4gFwKgazZFftRUEwnA,4185
920
920
  cirq/study/sweepable_test.py,sha256=xjUksIurfbh240fEC7Al_TuiHGz7xZGktQUh86XBG9U,4772
921
- cirq/study/sweeps.py,sha256=3BLtKMh_tfWZrLEaHxbjGU8yauasxjkNRwssJ-hWA14,18298
922
- cirq/study/sweeps_test.py,sha256=t71MLsPfMGaNaoxbf6EFQOysEOKKo4YvtjvMg_7U3Yk,11733
921
+ cirq/study/sweeps.py,sha256=IzonyU-LgEcMpvQrKZbl14v-BHi01oncp9CmHtLw0J4,19813
922
+ cirq/study/sweeps_test.py,sha256=IqZp0ywYA430nNE_slBfc4vdKjULttzPl8ytxHLlgWo,11966
923
923
  cirq/testing/__init__.py,sha256=nJTO5qjZoStFDoTSK2elK3l0BnOvL0MHqqPAcLQ5kDA,3605
924
924
  cirq/testing/circuit_compare.py,sha256=sZEXjD1zwBgLOXZfCGpUlHg_silzhlCsq9TgiW0ZcMg,19258
925
925
  cirq/testing/circuit_compare_test.py,sha256=6Xw1hrBUDavhji_ygpCKLBHUt_0melvy2VTjH2VcJwk,19743
@@ -1128,8 +1128,8 @@ cirq/work/sampler.py,sha256=JVv1vvfa6EgFiR3UeDk44U186dCrioH2NZXueCgsb9w,19828
1128
1128
  cirq/work/sampler_test.py,sha256=zo1Hj6sn6fLs_WZMxYRApBqgBsldmptn74NL0jhNukc,12325
1129
1129
  cirq/work/zeros_sampler.py,sha256=D3hbNZC-jXKuNAWg2OUiUuT8pmDV_WFnEfMank6In4o,2357
1130
1130
  cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
1131
- cirq_core-1.2.0.dev20230519015255.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1132
- cirq_core-1.2.0.dev20230519015255.dist-info/METADATA,sha256=k0_Y64LCaj-WLEyO7BgtC8CXZU6MkzA17bMqicUk9Ng,2155
1133
- cirq_core-1.2.0.dev20230519015255.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
1134
- cirq_core-1.2.0.dev20230519015255.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1135
- cirq_core-1.2.0.dev20230519015255.dist-info/RECORD,,
1131
+ cirq_core-1.2.0.dev20230523193942.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1132
+ cirq_core-1.2.0.dev20230523193942.dist-info/METADATA,sha256=dtDU_x89bSCHSdFoQQgsmJRDsq_rTjMlfyH0r6cuFCk,2155
1133
+ cirq_core-1.2.0.dev20230523193942.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
1134
+ cirq_core-1.2.0.dev20230523193942.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1135
+ cirq_core-1.2.0.dev20230523193942.dist-info/RECORD,,