cirq-core 1.6.0.dev20250722181350__py3-none-any.whl → 1.6.0.dev20250722195126__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, 11, 0): # pragma: no cover
28
28
  'of Cirq (e.g. "python -m pip install cirq==1.5.0")'
29
29
  )
30
30
 
31
- __version__ = "1.6.0.dev20250722181350"
31
+ __version__ = "1.6.0.dev20250722195126"
cirq/_version_test.py CHANGED
@@ -3,4 +3,4 @@ import cirq
3
3
 
4
4
 
5
5
  def test_version() -> None:
6
- assert cirq.__version__ == "1.6.0.dev20250722181350"
6
+ assert cirq.__version__ == "1.6.0.dev20250722195126"
@@ -17,6 +17,7 @@ from __future__ import annotations
17
17
  import dataclasses
18
18
  import functools
19
19
  import itertools
20
+ import uuid
20
21
  from typing import Any, cast, Iterator, Mapping, Sequence, TYPE_CHECKING
21
22
 
22
23
  import attrs
@@ -631,18 +632,24 @@ def single_qubit_state_tomography(
631
632
  Returns:
632
633
  A TomographyResult object that stores and plots the density matrix.
633
634
  """
634
- circuit_z = circuit + circuits.Circuit(ops.measure(qubit, key='z'))
635
+ keys = protocols.measurement_key_names(circuit)
636
+ tomo_key = "tomo_key"
637
+ while tomo_key in keys:
638
+ tomo_key = f"tomo_key{uuid.uuid4().hex}"
639
+
640
+ circuit_z = circuit + circuits.Circuit(ops.measure(qubit, key=tomo_key))
641
+
635
642
  results = sampler.run(circuit_z, repetitions=repetitions)
636
- rho_11 = np.mean(results.measurements['z'])
643
+ rho_11 = np.mean(results.records[tomo_key][:, -1, :])
637
644
  rho_00 = 1.0 - rho_11
638
645
 
639
- circuit_x = circuits.Circuit(circuit, ops.X(qubit) ** 0.5, ops.measure(qubit, key='z'))
646
+ circuit_x = circuits.Circuit(circuit, ops.X(qubit) ** 0.5, ops.measure(qubit, key=tomo_key))
640
647
  results = sampler.run(circuit_x, repetitions=repetitions)
641
- rho_01_im = np.mean(results.measurements['z']) - 0.5
648
+ rho_01_im = np.mean(results.records[tomo_key][:, -1, :]) - 0.5
642
649
 
643
- circuit_y = circuits.Circuit(circuit, ops.Y(qubit) ** -0.5, ops.measure(qubit, key='z'))
650
+ circuit_y = circuits.Circuit(circuit, ops.Y(qubit) ** -0.5, ops.measure(qubit, key=tomo_key))
644
651
  results = sampler.run(circuit_y, repetitions=repetitions)
645
- rho_01_re = 0.5 - np.mean(results.measurements['z'])
652
+ rho_01_re = 0.5 - np.mean(results.records[tomo_key][:, -1, :])
646
653
 
647
654
  rho_01 = rho_01_re + 1j * rho_01_im
648
655
  rho_10 = np.conj(rho_01)
@@ -157,24 +157,34 @@ def test_two_qubit_randomized_benchmarking():
157
157
  def test_single_qubit_state_tomography():
158
158
  # Check that the density matrices of the output states of X/2, Y/2 and
159
159
  # H + Y gates closely match the ideal cases.
160
+ # Checks that unique tomography keys are generated
160
161
  simulator = sim.Simulator()
161
- qubit = GridQubit(0, 0)
162
+ q_0 = GridQubit(0, 0)
163
+ q_1 = GridQubit(0, 1)
162
164
 
163
- circuit_1 = circuits.Circuit(ops.X(qubit) ** 0.5)
164
- circuit_2 = circuits.Circuit(ops.Y(qubit) ** 0.5)
165
- circuit_3 = circuits.Circuit(ops.H(qubit), ops.Y(qubit))
165
+ circuit_1 = circuits.Circuit(ops.X(q_0) ** 0.5)
166
+ circuit_2 = circuits.Circuit(ops.Y(q_0) ** 0.5)
167
+ circuit_3 = circuits.Circuit(ops.H(q_0), ops.Y(q_0))
168
+ circuit_4 = circuits.Circuit(ops.H(q_0), ops.Y(q_0), cirq.measure(q_1, key='z'))
169
+ circuit_5 = circuits.Circuit(ops.H(q_0), ops.Y(q_0), cirq.measure(q_1, key='tomo_key'))
166
170
 
167
- act_rho_1 = single_qubit_state_tomography(simulator, qubit, circuit_1, 1000).data
168
- act_rho_2 = single_qubit_state_tomography(simulator, qubit, circuit_2, 1000).data
169
- act_rho_3 = single_qubit_state_tomography(simulator, qubit, circuit_3, 1000).data
171
+ act_rho_1 = single_qubit_state_tomography(simulator, q_0, circuit_1, 1000).data
172
+ act_rho_2 = single_qubit_state_tomography(simulator, q_0, circuit_2, 1000).data
173
+ act_rho_3 = single_qubit_state_tomography(simulator, q_0, circuit_3, 1000).data
174
+ act_rho_4 = single_qubit_state_tomography(simulator, q_0, circuit_4, 1000).data
175
+ act_rho_5 = single_qubit_state_tomography(simulator, q_0, circuit_5, 1000).data
170
176
 
171
177
  tar_rho_1 = np.array([[0.5, 0.5j], [-0.5j, 0.5]])
172
178
  tar_rho_2 = np.array([[0.5, 0.5], [0.5, 0.5]])
173
179
  tar_rho_3 = np.array([[0.5, -0.5], [-0.5, 0.5]])
180
+ tar_rho_4 = np.array([[0.5, -0.5], [-0.5, 0.5]])
181
+ tar_rho_5 = np.array([[0.5, -0.5], [-0.5, 0.5]])
174
182
 
175
183
  np.testing.assert_almost_equal(act_rho_1, tar_rho_1, decimal=1)
176
184
  np.testing.assert_almost_equal(act_rho_2, tar_rho_2, decimal=1)
177
185
  np.testing.assert_almost_equal(act_rho_3, tar_rho_3, decimal=1)
186
+ np.testing.assert_almost_equal(act_rho_4, tar_rho_4, decimal=1)
187
+ np.testing.assert_almost_equal(act_rho_5, tar_rho_5, decimal=1)
178
188
 
179
189
 
180
190
  def test_two_qubit_state_tomography():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cirq-core
3
- Version: 1.6.0.dev20250722181350
3
+ Version: 1.6.0.dev20250722195126
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=emXpdD5ZvwLRlFAoQB8YatmZyU3b4e9jg6FppMTUhkU,33900
4
4
  cirq/_doc.py,sha256=BrnoABo1hk5RgB3Cgww4zLHUfiyFny0F1V-tOMCbdaU,2909
5
5
  cirq/_import.py,sha256=ixBu4EyGl46Ram2cP3p5eZVEFDW5L2DS-VyTjz4N9iw,8429
6
6
  cirq/_import_test.py,sha256=oF4izzOVZLc7NZ0aZHFcGv-r01eiFFt_JORx_x7_D4s,1089
7
- cirq/_version.py,sha256=dPvUeD0p3VMMLAyiICVFRbm1yJvEXNaiG30wk02c8AI,1206
8
- cirq/_version_test.py,sha256=3mAu7Ul-vkUZcgVrwiMQZpZj8M052sJ_TYRd61b6EZo,155
7
+ cirq/_version.py,sha256=CqKE5_bslTnb4lnk3aF_zBGLWYwhEQk8tEtz4j-WUA0,1206
8
+ cirq/_version_test.py,sha256=uhkyY_WahkcTDZEEcLtloNMPmRu6EV9x2PmGs52KEs8,155
9
9
  cirq/conftest.py,sha256=wSDKNdIQRDfLnXvOCWD3erheOw8JHRhdfQ53EyTUIXg,1239
10
10
  cirq/json_resolver_cache.py,sha256=A5DIgFAY1hUNt9vai_C3-gGBv24116CJMzQxMcXOax4,13726
11
11
  cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
@@ -189,8 +189,8 @@ cirq/experiments/n_qubit_tomography.py,sha256=16u0Tv14SyUM9WCk-ZxbBit9cl93MbZodG
189
189
  cirq/experiments/n_qubit_tomography_test.py,sha256=8wIgs0O8DtlCGOyC0MZA_d3tLNoURX1ARcqnnp1360g,4439
190
190
  cirq/experiments/purity_estimation.py,sha256=0F5uWh0pqNJ9RZQtNBzGeF8OUpapGFeqPWWVsdpEA7k,2503
191
191
  cirq/experiments/purity_estimation_test.py,sha256=OF3EtFBg7ZqPSBfRJK_-1ji2-xrNVEuD77lHO8Sm3Jc,959
192
- cirq/experiments/qubit_characterizations.py,sha256=BKvi1_A7nOT24lxT8zsTWdqeORMUIV_yhQFUS5gy6bE,40673
193
- cirq/experiments/qubit_characterizations_test.py,sha256=RZzyuQwYm9tHtQSZLigJnQcyhZdCzE7OiuyETQSiHxo,10319
192
+ cirq/experiments/qubit_characterizations.py,sha256=RO-gxOI_7n4HhGOmumgLGacV4Ve8bAY_s7XyxkOTUjo,40887
193
+ cirq/experiments/qubit_characterizations_test.py,sha256=maQmdNAWwZ15OcUDe0gqu7irYOK8ldwF1CVBY53rmxY,10971
194
194
  cirq/experiments/random_quantum_circuit_generation.py,sha256=pV6ubukLLdfPXLvJD2t979rVDCOTM32X6SB65vExeE4,28012
195
195
  cirq/experiments/random_quantum_circuit_generation_test.py,sha256=4GSfUK2hw2r90JAO7R2zSBqjtwWi8vXuAhw-iK6quwY,16512
196
196
  cirq/experiments/readout_confusion_matrix.py,sha256=qK6qDoNRuIHGTV7PS8xGkS7tCXGGyoDfUJJj6575-cE,20664
@@ -1224,8 +1224,8 @@ cirq/work/sampler.py,sha256=rxbMWvrhu3gfNSBjZKozw28lLKVvBAS_1EGyPdYe8Xg,19041
1224
1224
  cirq/work/sampler_test.py,sha256=SsMrRvLDYELyOAWLKISjkdEfrBwLYWRsT6D8WrsLM3Q,13533
1225
1225
  cirq/work/zeros_sampler.py,sha256=Fs2JWwq0n9zv7_G5Rm-9vPeHUag7uctcMOHg0JTkZpc,2371
1226
1226
  cirq/work/zeros_sampler_test.py,sha256=lQLgQDGBLtfImryys2HzQ2jOSGxHgc7-koVBUhv8qYk,3345
1227
- cirq_core-1.6.0.dev20250722181350.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1228
- cirq_core-1.6.0.dev20250722181350.dist-info/METADATA,sha256=kRx1cAUdxh87C7nuuzNgvNYFlP2sVjVj5BgcyhFC55s,4857
1229
- cirq_core-1.6.0.dev20250722181350.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
1230
- cirq_core-1.6.0.dev20250722181350.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1231
- cirq_core-1.6.0.dev20250722181350.dist-info/RECORD,,
1227
+ cirq_core-1.6.0.dev20250722195126.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1228
+ cirq_core-1.6.0.dev20250722195126.dist-info/METADATA,sha256=exITVufoGIpHGbL9qY1ECc5q4J0bozaKl87wTIojgIg,4857
1229
+ cirq_core-1.6.0.dev20250722195126.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
1230
+ cirq_core-1.6.0.dev20250722195126.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1231
+ cirq_core-1.6.0.dev20250722195126.dist-info/RECORD,,