cirq-core 1.5.0.dev20240607171515__py3-none-any.whl → 1.5.0.dev20240610203324__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.dev20240607171515"
31
+ __version__ = "1.5.0.dev20240610203324"
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.dev20240607171515"
6
+ assert cirq.__version__ == "1.5.0.dev20240610203324"
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(
@@ -12,11 +12,9 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
  """Estimation of fidelity associated with experimental circuit executions."""
15
- import concurrent
16
15
  import os
17
16
  import time
18
17
  import uuid
19
- from concurrent.futures.thread import ThreadPoolExecutor
20
18
  from dataclasses import dataclass
21
19
  from typing import (
22
20
  Callable,
@@ -276,18 +274,16 @@ def _execute_sample_2q_xeb_tasks_in_batches(
276
274
  run_batch = _SampleInBatches(
277
275
  sampler=sampler, repetitions=repetitions, combinations_by_layer=combinations_by_layer
278
276
  )
279
- with ThreadPoolExecutor(max_workers=2) as pool:
280
- futures = [pool.submit(run_batch, task_batch) for task_batch in batched_tasks]
281
277
 
282
- records = []
283
- with progress_bar(total=len(batched_tasks) * batch_size) as progress:
284
- for future in concurrent.futures.as_completed(futures):
285
- new_records = future.result()
286
- if dataset_directory is not None:
287
- os.makedirs(f'{dataset_directory}', exist_ok=True)
288
- protocols.to_json(new_records, f'{dataset_directory}/xeb.{uuid.uuid4()}.json')
289
- records.extend(new_records)
290
- progress.update(batch_size)
278
+ records = []
279
+ with progress_bar(total=len(batched_tasks) * batch_size) as progress:
280
+ for task in batched_tasks:
281
+ new_records = run_batch(task)
282
+ if dataset_directory is not None:
283
+ os.makedirs(f'{dataset_directory}', exist_ok=True)
284
+ protocols.to_json(new_records, f'{dataset_directory}/xeb.{uuid.uuid4()}.json')
285
+ records.extend(new_records)
286
+ progress.update(batch_size)
291
287
  return records
292
288
 
293
289
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cirq-core
3
- Version: 1.5.0.dev20240607171515
3
+ Version: 1.5.0.dev20240610203324
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=N3CtNHJi_Uhc3l9epMohWPBwjLOegHqi1Zjxzcu9Jwc,1206
8
- cirq/_version_test.py,sha256=OH0wy_zYf4zMe3CcEVnr0ofScvD9kV5Q3mDfoRvhZqw,147
7
+ cirq/_version.py,sha256=X6TQ2nt8-RjX2OqWZ4LM2bgjBhLgQB__Gc7sMjMG2S4,1206
8
+ cirq/_version_test.py,sha256=uj9Hg6-l3bVWFvda0wTEAtaQ2lNEp9rgHP0tb0m_Vhg,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
@@ -200,7 +200,7 @@ cirq/experiments/two_qubit_xeb.py,sha256=wdLxBi3LrAlPF-SQV9Tf66k31XC2cVHNPhpR-VL
200
200
  cirq/experiments/two_qubit_xeb_test.py,sha256=Tlr32vuJpyepkMBVVkN6ipjRyDr8DIixfBumEeGXzDM,10073
201
201
  cirq/experiments/xeb_fitting.py,sha256=54FKzGqhZgyvAkP_AR2-7peDnL-PJxOp-MkQdfp8bfU,27178
202
202
  cirq/experiments/xeb_fitting_test.py,sha256=nfFhKPr_Nx5rbfCcvrcUFQxphCZuTnJVnpT-xBjxRFI,14349
203
- cirq/experiments/xeb_sampling.py,sha256=plcwC4GNV2hW39ZFPBG1jWMnSIWcMh5rwsV8i6cQ_t4,15266
203
+ cirq/experiments/xeb_sampling.py,sha256=6ZOidGi7Kt6p4cMQCjK7qQuIUXVHCYl47B2GnL8M-Bw,14987
204
204
  cirq/experiments/xeb_sampling_test.py,sha256=0XkQGvcURsug3IblE_wZrHVDoOQV3WuQilrqCJbDHjI,6784
205
205
  cirq/experiments/xeb_simulation.py,sha256=DpCWVxzWnZvjrdfgIbwR9rWenehqz7Su3LPIVHoK7gI,5055
206
206
  cirq/experiments/xeb_simulation_test.py,sha256=gx0GqGZ4TDwrNW5ULK5JEWfzL-Dvb8TpAxIgdpiB8Tg,5430
@@ -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.dev20240607171515.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1179
- cirq_core-1.5.0.dev20240607171515.dist-info/METADATA,sha256=4Lyw-hWTnbbrGFL7iMHxvnYGNwg3B8erDSTTPb5oqkI,1998
1180
- cirq_core-1.5.0.dev20240607171515.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
1181
- cirq_core-1.5.0.dev20240607171515.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1182
- cirq_core-1.5.0.dev20240607171515.dist-info/RECORD,,
1178
+ cirq_core-1.5.0.dev20240610203324.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1179
+ cirq_core-1.5.0.dev20240610203324.dist-info/METADATA,sha256=T_KZxLr9s0X7baudscpUcLSH_DKi_sHnXRObFG9lMnE,1998
1180
+ cirq_core-1.5.0.dev20240610203324.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
1181
+ cirq_core-1.5.0.dev20240610203324.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1182
+ cirq_core-1.5.0.dev20240610203324.dist-info/RECORD,,