cirq-core 1.5.0.dev20240603222230__py3-none-any.whl → 1.5.0.dev20240607182648__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
@@ -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.dev20240603222230"
31
+ __version__ = "1.5.0.dev20240607182648"
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.dev20240603222230"
6
+ assert cirq.__version__ == "1.5.0.dev20240607182648"
cirq/circuits/circuit.py CHANGED
@@ -145,29 +145,31 @@ class AbstractCircuit(abc.ABC):
145
145
  """
146
146
 
147
147
  @classmethod
148
- def from_moments(cls: Type[CIRCUIT_TYPE], *moments: 'cirq.OP_TREE') -> CIRCUIT_TYPE:
148
+ def from_moments(cls: Type[CIRCUIT_TYPE], *moments: Optional['cirq.OP_TREE']) -> CIRCUIT_TYPE:
149
149
  """Create a circuit from moment op trees.
150
150
 
151
151
  Args:
152
- *moments: Op tree for each moment. If an op tree is a moment, it
153
- will be included directly in the new circuit. If an op tree is
154
- a circuit, it will be frozen, wrapped in a CircuitOperation, and
155
- included in its own moment in the new circuit. Otherwise, the
156
- op tree will be passed to `cirq.Moment` to create a new moment
157
- which is then included in the new circuit. Note that in the
158
- latter case we have the normal restriction that operations in a
159
- moment must be applied to disjoint sets of qubits.
152
+ *moments: Op trees for each moment, which can be one of the following:
153
+ - Moment: will be included directly in the new circuit.
154
+ - AbstractCircuit: will be frozen, wrapped in a CircuitOperation,
155
+ and included in its own moment in the new circuit.
156
+ - None: will be skipped and omitted from the circuit. This can be
157
+ used to include or skip a moment based on a conditional, for example.
158
+ - Other OP_TREE: will be passed to `cirq.Moment` to create a new moment
159
+ which is then included in the new circuit. Note that in this
160
+ case we have the normal restriction that operations in a
161
+ moment must be applied to disjoint sets of qubits.
160
162
  """
161
163
  return cls._from_moments(cls._make_moments(moments))
162
164
 
163
165
  @staticmethod
164
- def _make_moments(moments: Iterable['cirq.OP_TREE']) -> Iterator['cirq.Moment']:
166
+ def _make_moments(moments: Iterable[Optional['cirq.OP_TREE']]) -> Iterator['cirq.Moment']:
165
167
  for m in moments:
166
168
  if isinstance(m, Moment):
167
169
  yield m
168
170
  elif isinstance(m, AbstractCircuit):
169
171
  yield Moment(m.freeze().to_op())
170
- else:
172
+ elif m is not None:
171
173
  yield Moment(m)
172
174
 
173
175
  @classmethod
@@ -80,6 +80,7 @@ def test_from_moments():
80
80
  [cirq.X(c)],
81
81
  [],
82
82
  cirq.Z(d),
83
+ None,
83
84
  [cirq.measure(a, b, key='ab'), cirq.measure(c, d, key='cd')],
84
85
  )
85
86
  assert circuit == cirq.Circuit(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cirq-core
3
- Version: 1.5.0.dev20240603222230
3
+ Version: 1.5.0.dev20240607182648
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,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=PJ8Z8x2c4ka0YEi3kIHdui1cJuk0G7p_UFnryC1xszc,1206
8
- cirq/_version_test.py,sha256=YgziIiEXrUz2Wfp1AB4_LAleHRYCjs4Yi2cyk3hT4sw,147
7
+ cirq/_version.py,sha256=C0QmQwT7TUbkI3YNMwNv5p2FrLfJa60OX5E3lqKcKhk,1206
8
+ cirq/_version_test.py,sha256=cU0bdfzE7CPPv0_NHrmnXMnE22HTSIgaKLd_pnfyRH0,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
@@ -17,10 +17,10 @@ cirq/circuits/_box_drawing_character_data.py,sha256=QLoCXwcLL7091RdxEKO259goxt4R
17
17
  cirq/circuits/_box_drawing_character_data_test.py,sha256=XO94z0piwZRHaNZHTf-5tKHQ4MKcDruMeRIKdT8GbYA,1624
18
18
  cirq/circuits/_bucket_priority_queue.py,sha256=hxFuii2fKD8G6EKT_aVLEsA7FmSfqFXPwIbA0KsoSC4,6745
19
19
  cirq/circuits/_bucket_priority_queue_test.py,sha256=t6u_hG7K2e2WKWrgCsKxNRtp4ghKwiCrp0_WSY0W25k,5288
20
- cirq/circuits/circuit.py,sha256=iYdNez1apyEOrLWQIx6qT89Yddl083t6iWlocB74apA,114406
20
+ cirq/circuits/circuit.py,sha256=XIwQh9Gkb8ya4Q2Q92EfsAUh9W6YZemcGqlu1cZCi2s,114620
21
21
  cirq/circuits/circuit_operation.py,sha256=D4u8jDD4fGOca1xnZPN1obuKTIouXENUfnxOF2JrwgU,34375
22
22
  cirq/circuits/circuit_operation_test.py,sha256=_0iQJ3h_dnQcQmbGRZbc-NqdglJTXantbj72ggqLKNE,44724
23
- cirq/circuits/circuit_test.py,sha256=_hb29zDdLaEuUTROtVc5VKpmtlsHQGFyDlKQ2Nxqc3s,160103
23
+ cirq/circuits/circuit_test.py,sha256=sRZC558PZZZUHByZ1R00_j8ez6TL9l5ZmT8YLGopH_Q,160117
24
24
  cirq/circuits/frozen_circuit.py,sha256=_0SkmIiQ4UjIug-k_iO00ulDFoFnxmAHvXX2I2HHN8k,9262
25
25
  cirq/circuits/frozen_circuit_test.py,sha256=rHyii8hLhOQ6jdA8dC1OcYPGnyeBC4uY5Q53XspkkCk,4133
26
26
  cirq/circuits/insert_strategy.py,sha256=L0OLXuo24TtBfdJGOAG2PsVDMrbvQl4iN5lUk6IPuyo,2851
@@ -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.dev20240603222230.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1179
- cirq_core-1.5.0.dev20240603222230.dist-info/METADATA,sha256=mdPyB1nwhwCXinM2bHlnrU5--Td2ezAgXvuzG60jxvQ,1998
1180
- cirq_core-1.5.0.dev20240603222230.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
1181
- cirq_core-1.5.0.dev20240603222230.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1182
- cirq_core-1.5.0.dev20240603222230.dist-info/RECORD,,
1178
+ cirq_core-1.5.0.dev20240607182648.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1179
+ cirq_core-1.5.0.dev20240607182648.dist-info/METADATA,sha256=ml-LsuwbNmQCppBs9mzsisvifgdtMMx8mBWvXjXkj6k,1998
1180
+ cirq_core-1.5.0.dev20240607182648.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
1181
+ cirq_core-1.5.0.dev20240607182648.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1182
+ cirq_core-1.5.0.dev20240607182648.dist-info/RECORD,,