cirq-core 1.5.0.dev20240611212047__py3-none-any.whl → 1.5.0.dev20240612172743__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 CHANGED
@@ -28,4 +28,4 @@ if sys.version_info < (3, 10, 0): # pragma: no cover
28
28
  'of cirq (e.g. "python -m pip install cirq==1.1.*")'
29
29
  )
30
30
 
31
- __version__ = "1.5.0.dev20240611212047"
31
+ __version__ = "1.5.0.dev20240612172743"
cirq/_version_test.py CHANGED
@@ -3,4 +3,4 @@ import cirq
3
3
 
4
4
 
5
5
  def test_version():
6
- assert cirq.__version__ == "1.5.0.dev20240611212047"
6
+ assert cirq.__version__ == "1.5.0.dev20240612172743"
cirq/study/sweepable.py CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  """Defines which types are Sweepable."""
16
16
 
17
- from typing import Iterable, Iterator, List, Sequence, Union, cast
17
+ from typing import Iterable, Iterator, List, Optional, Sequence, Union, cast
18
18
  import warnings
19
19
  from typing_extensions import Protocol
20
20
 
@@ -44,12 +44,12 @@ def to_resolvers(sweepable: Sweepable) -> Iterator[ParamResolver]:
44
44
  yield from sweep
45
45
 
46
46
 
47
- def to_sweeps(sweepable: Sweepable) -> List[Sweep]:
47
+ def to_sweeps(sweepable: Sweepable, metadata: Optional[dict] = None) -> List[Sweep]:
48
48
  """Converts a Sweepable to a list of Sweeps."""
49
49
  if sweepable is None:
50
50
  return [UnitSweep]
51
51
  if isinstance(sweepable, ParamResolver):
52
- return [_resolver_to_sweep(sweepable)]
52
+ return [_resolver_to_sweep(sweepable, metadata)]
53
53
  if isinstance(sweepable, Sweep):
54
54
  return [sweepable]
55
55
  if isinstance(sweepable, dict):
@@ -63,9 +63,13 @@ def to_sweeps(sweepable: Sweepable) -> List[Sweep]:
63
63
  stacklevel=2,
64
64
  )
65
65
  product_sweep = dict_to_product_sweep(sweepable)
66
- return [_resolver_to_sweep(resolver) for resolver in product_sweep]
66
+ return [_resolver_to_sweep(resolver, metadata) for resolver in product_sweep]
67
67
  if isinstance(sweepable, Iterable) and not isinstance(sweepable, str):
68
- return [sweep for item in sweepable for sweep in to_sweeps(item)] # type: ignore[arg-type]
68
+ return [
69
+ sweep
70
+ for item in sweepable
71
+ for sweep in to_sweeps(item, metadata) # type: ignore[arg-type]
72
+ ]
69
73
  raise TypeError(f'Unrecognized sweepable type: {type(sweepable)}.\nsweepable: {sweepable}')
70
74
 
71
75
 
@@ -98,8 +102,13 @@ def to_sweep(
98
102
  raise TypeError(f'Unexpected sweep-like value: {sweep_or_resolver_list}')
99
103
 
100
104
 
101
- def _resolver_to_sweep(resolver: ParamResolver) -> Sweep:
105
+ def _resolver_to_sweep(resolver: ParamResolver, metadata: Optional[dict]) -> Sweep:
102
106
  params = resolver.param_dict
103
107
  if not params:
104
108
  return UnitSweep
105
- return Zip(*[Points(key, [cast(float, value)]) for key, value in params.items()])
109
+ return Zip(
110
+ *[
111
+ Points(key, [cast(float, value)], metadata=metadata.get(key) if metadata else None)
112
+ for key, value in params.items()
113
+ ]
114
+ )
@@ -147,3 +147,30 @@ def test_to_sweep_resolver_list(r_list_gen):
147
147
  def test_to_sweep_type_error():
148
148
  with pytest.raises(TypeError, match='Unexpected sweep'):
149
149
  cirq.to_sweep(5)
150
+
151
+
152
+ def test_to_sweeps_with_param_dict_appends_metadata():
153
+ params = {'a': 1, 'b': 2, 'c': 3}
154
+ unit_map = {'a': 'ns', 'b': 'ns'}
155
+
156
+ sweep = cirq.to_sweeps(params, unit_map)
157
+
158
+ assert sweep == [
159
+ cirq.Zip(
160
+ cirq.Points('a', [1], metadata='ns'),
161
+ cirq.Points('b', [2], metadata='ns'),
162
+ cirq.Points('c', [3]),
163
+ )
164
+ ]
165
+
166
+
167
+ def test_to_sweeps_with_param_list_appends_metadata():
168
+ resolvers = [cirq.ParamResolver({'a': 2}), cirq.ParamResolver({'a': 1})]
169
+ unit_map = {'a': 'ns'}
170
+
171
+ sweeps = cirq.study.to_sweeps(resolvers, unit_map)
172
+
173
+ assert sweeps == [
174
+ cirq.Zip(cirq.Points('a', [2], metadata='ns')),
175
+ cirq.Zip(cirq.Points('a', [1], metadata='ns')),
176
+ ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cirq-core
3
- Version: 1.5.0.dev20240611212047
3
+ Version: 1.5.0.dev20240612172743
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
@@ -8,7 +8,7 @@ Author-email: cirq-dev@googlegroups.com
8
8
  License: Apache 2
9
9
  Requires-Python: >=3.10.0
10
10
  License-File: LICENSE
11
- Requires-Dist: attrs
11
+ Requires-Dist: attrs >=21.3.0
12
12
  Requires-Dist: duet >=0.2.8
13
13
  Requires-Dist: matplotlib ~=3.0
14
14
  Requires-Dist: networkx >=2.4
@@ -4,8 +4,8 @@ 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=GIsfgCUY8ZV55WFRC205GNUpbSu7Jgf0gIy4ZmGbvdk,1206
8
- cirq/_version_test.py,sha256=QugnBRf3_zf_YqbDdGgzHzlwOi9c1e8Wt0YMcpu02GY,147
7
+ cirq/_version.py,sha256=xmYoyHWit1r14JEequoLl7rv01RixPWRo_yYhsOM7II,1206
8
+ cirq/_version_test.py,sha256=AABs-160Fj5gKNW-bDHvvS92P-TytvZ8CoJZsMCg4cc,147
9
9
  cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
10
10
  cirq/json_resolver_cache.py,sha256=ytePZtNZgKjOF2NiVpUTuotB-JKZmQNOFIFdvXqsxHw,13271
11
11
  cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
@@ -936,8 +936,8 @@ cirq/study/resolver.py,sha256=-X6R4FQ5nkEyaf4YsNFTN1Ui8Ss-Mkn39pHOV-vgsZQ,11773
936
936
  cirq/study/resolver_test.py,sha256=QQe9Rr0z6qNbSWPEvCKd_DNka6454AWVKbG2J2DD1Wg,10228
937
937
  cirq/study/result.py,sha256=KzjpjvDVCTFjMyq9r91pZSYdtcD1x3yj8jP_StlOSMg,19285
938
938
  cirq/study/result_test.py,sha256=fq5BH78RswfTiYjMchJ4wEDDyaJu0QdJoGobMjKDeSI,15591
939
- cirq/study/sweepable.py,sha256=BMgq8lxVnyJGBeu4gFUt_0P_v4gFwKgazZFftRUEwnA,4185
940
- cirq/study/sweepable_test.py,sha256=xjUksIurfbh240fEC7Al_TuiHGz7xZGktQUh86XBG9U,4772
939
+ cirq/study/sweepable.py,sha256=IsOw1rdaKGT4HGj6zpOM1ZhaiRoETRwIeqyyzJIRXMU,4428
940
+ cirq/study/sweepable_test.py,sha256=ENv03_GJmbUc_ukJoqfgG-H5C_yyx1jCcvxohSMyQVU,5502
941
941
  cirq/study/sweeps.py,sha256=8mUc5dnOJxZH8m_6ncgkZRY7a2TBe7_9d3WcvJAyZlA,19900
942
942
  cirq/study/sweeps_test.py,sha256=YdXHzZO10OHoPTU2ifmsfH7KByIJeeANy91AHqX8nwg,12135
943
943
  cirq/testing/__init__.py,sha256=cACho8s-V5tNOjBcDUtr2DipQxQcbUgbr4MESJb4l1I,3870
@@ -1175,8 +1175,8 @@ cirq/work/sampler.py,sha256=JEAeQQRF3bqlO9AkOf4XbrTATDI5f5JgyM_FAUCNxao,19751
1175
1175
  cirq/work/sampler_test.py,sha256=B2ZsuqGT854gQtBIAh8k0LiG9Vj5wSzcGvkxOUoTcW4,13217
1176
1176
  cirq/work/zeros_sampler.py,sha256=x1C7cup66a43n-3tm8QjhiqJa07qcJW10FxNp9jJ59Q,2356
1177
1177
  cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
1178
- cirq_core-1.5.0.dev20240611212047.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1179
- cirq_core-1.5.0.dev20240611212047.dist-info/METADATA,sha256=Ab_zKoiuGaXGdGtO8IP-vhqerXLJ8j5PoQ2NL81r8f0,1998
1180
- cirq_core-1.5.0.dev20240611212047.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
1181
- cirq_core-1.5.0.dev20240611212047.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1182
- cirq_core-1.5.0.dev20240611212047.dist-info/RECORD,,
1178
+ cirq_core-1.5.0.dev20240612172743.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1179
+ cirq_core-1.5.0.dev20240612172743.dist-info/METADATA,sha256=1dI7mDTgwgeT57GV7DNRn7XYOqMbvXPKDNcZ2LzdG3E,2007
1180
+ cirq_core-1.5.0.dev20240612172743.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
1181
+ cirq_core-1.5.0.dev20240612172743.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1182
+ cirq_core-1.5.0.dev20240612172743.dist-info/RECORD,,