cirq-core 1.6.0.dev20250616231428__py3-none-any.whl → 1.6.0.dev20250617235202__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.dev20250616231428"
31
+ __version__ = "1.6.0.dev20250617235202"
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.dev20250616231428"
6
+ assert cirq.__version__ == "1.6.0.dev20250617235202"
cirq/linalg/predicates.py CHANGED
@@ -115,8 +115,12 @@ def is_unitary(matrix: np.ndarray, *, rtol: float = 1e-5, atol: float = 1e-8) ->
115
115
  Returns:
116
116
  Whether the matrix is unitary within the given tolerance.
117
117
  """
118
- return matrix.shape[0] == matrix.shape[1] and np.allclose(
119
- matrix.dot(np.conj(matrix.T)), np.eye(matrix.shape[0]), rtol=rtol, atol=atol
118
+ return (
119
+ matrix.ndim == 2
120
+ and matrix.shape[0] == matrix.shape[1]
121
+ and np.allclose(
122
+ matrix.dot(np.conj(matrix.T)), np.eye(matrix.shape[0]), rtol=rtol, atol=atol
123
+ )
120
124
  )
121
125
 
122
126
 
@@ -103,10 +103,13 @@ def test_is_hermitian_tolerance():
103
103
 
104
104
 
105
105
  def test_is_unitary():
106
+ assert not cirq.is_unitary(np.empty((0,)))
106
107
  assert cirq.is_unitary(np.empty((0, 0)))
107
108
  assert not cirq.is_unitary(np.empty((1, 0)))
108
109
  assert not cirq.is_unitary(np.empty((0, 1)))
110
+ assert not cirq.is_unitary(np.empty((0, 0, 0)))
109
111
 
112
+ assert not cirq.is_unitary(np.array(1))
110
113
  assert cirq.is_unitary(np.array([[1]]))
111
114
  assert cirq.is_unitary(np.array([[-1]]))
112
115
  assert cirq.is_unitary(np.array([[1j]]))
@@ -118,7 +118,7 @@ def merge_single_qubit_moments_to_phxz(
118
118
 
119
119
  def can_merge_moment(m: cirq.Moment):
120
120
  return all(
121
- protocols.num_qubits(op) == 1
121
+ protocols.num_qubits(op) <= 1
122
122
  and protocols.has_unitary(op)
123
123
  and tags_to_ignore.isdisjoint(op.tags)
124
124
  for op in m
@@ -146,6 +146,10 @@ def merge_single_qubit_moments_to_phxz(
146
146
  )
147
147
  if gate:
148
148
  ret_ops.append(gate(q))
149
+ # Transfer global phase
150
+ for op in m1.operations + m2.operations:
151
+ if protocols.num_qubits(op) == 0:
152
+ ret_ops.append(op)
149
153
  return circuits.Moment(ret_ops)
150
154
 
151
155
  return transformer_primitives.merge_moments(
@@ -231,3 +231,35 @@ def test_merge_single_qubit_gates_to_phased_x_and_z_global_phase():
231
231
  c = cirq.Circuit(cirq.GlobalPhaseGate(1j).on())
232
232
  c2 = cirq.merge_single_qubit_gates_to_phased_x_and_z(c)
233
233
  assert c == c2
234
+
235
+
236
+ def test_merge_single_qubit_moments_to_phxz_with_global_phase_in_first_moment():
237
+ q0 = cirq.LineQubit(0)
238
+ c_orig = cirq.Circuit(
239
+ cirq.Moment(cirq.Y(q0) ** 0.5, cirq.GlobalPhaseGate(1j**0.5).on()), cirq.Moment(cirq.X(q0))
240
+ )
241
+ c_expected = cirq.Circuit(
242
+ cirq.Moment(
243
+ cirq.PhasedXZGate(axis_phase_exponent=-0.5, x_exponent=0.5, z_exponent=-1.0).on(q0),
244
+ cirq.GlobalPhaseGate(1j**0.5).on(),
245
+ )
246
+ )
247
+ context = cirq.TransformerContext(tags_to_ignore=["ignore"])
248
+ c_new = cirq.merge_single_qubit_moments_to_phxz(c_orig, context=context)
249
+ assert c_new == c_expected
250
+
251
+
252
+ def test_merge_single_qubit_moments_to_phxz_with_global_phase_in_second_moment():
253
+ q0 = cirq.LineQubit(0)
254
+ c_orig = cirq.Circuit(
255
+ cirq.Moment(cirq.Y(q0) ** 0.5), cirq.Moment(cirq.X(q0), cirq.GlobalPhaseGate(1j**0.5).on())
256
+ )
257
+ c_expected = cirq.Circuit(
258
+ cirq.Moment(
259
+ cirq.PhasedXZGate(axis_phase_exponent=-0.5, x_exponent=0.5, z_exponent=-1.0).on(q0),
260
+ cirq.GlobalPhaseGate(1j**0.5).on(),
261
+ )
262
+ )
263
+ context = cirq.TransformerContext(tags_to_ignore=["ignore"])
264
+ c_new = cirq.merge_single_qubit_moments_to_phxz(c_orig, context=context)
265
+ assert c_new == c_expected
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cirq-core
3
- Version: 1.6.0.dev20250616231428
3
+ Version: 1.6.0.dev20250617235202
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=LMvnkJDFuqv4moS6ve3V4bFYsa5xpyXLvO4GpZq544U,1206
8
- cirq/_version_test.py,sha256=adS7rpe0utyPMYSTDDwmfQuzFQLJwgK6-Ml_f6HCUKY,155
7
+ cirq/_version.py,sha256=DAW8LEf4vLpC1OOxWWHw_ReVqUpFny2UOAMlWahuEq0,1206
8
+ cirq/_version_test.py,sha256=Hwfvm55CewQiFvDuFWqKAiI7kh3IptDdP7Uyugq8V0w,155
9
9
  cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
10
10
  cirq/json_resolver_cache.py,sha256=hYyG53VJeV61X0oukK5ndZYega8lkL2FyaL1m0j6h5M,13556
11
11
  cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
@@ -260,8 +260,8 @@ cirq/linalg/diagonalize.py,sha256=3PpGmlI7CCkQS3JKr0AkgdHOZedXLniZkxmUtpCNQPk,10
260
260
  cirq/linalg/diagonalize_test.py,sha256=c6-ksL2PDZ5hqr2ib2iS0uEnJuCHSv16cuiJK4PLjok,9161
261
261
  cirq/linalg/operator_spaces.py,sha256=jUU-OYL8Lnn58kbhLskDyhkBeXZXPXVmR-hcIkq60JQ,4132
262
262
  cirq/linalg/operator_spaces_test.py,sha256=9puH8uqMhWVF4QvJImX0WvcxsxBMvvroUZUSNNvaTDQ,10729
263
- cirq/linalg/predicates.py,sha256=uVyZjCPlUpQnl8nwxIVVgdnHdjzGneeUfZqNwT-qUUc,12103
264
- cirq/linalg/predicates_test.py,sha256=lNtaVVbPhDFD1yXWZb2Ncz5ZsgSdkVxv-prBBXsvk0k,21540
263
+ cirq/linalg/predicates.py,sha256=z4f7eHM7rQIYucpjlRoM-ZoY6ObxQFTuD9XruaYK6kI,12164
264
+ cirq/linalg/predicates_test.py,sha256=ZEIqb3fPWFsAaY49HUBRwN3oGShM0k0YHq22WX149Sg,21683
265
265
  cirq/linalg/tolerance.py,sha256=4TZ_BjldOhPuP2CwYvMdzHCc9Lzfwi9ZkndSKObyyBg,1893
266
266
  cirq/linalg/tolerance_test.py,sha256=uAqJk--Rhxr9XXLh3dAvK_BDcbJUccEAFIFdLHiMEHU,2423
267
267
  cirq/linalg/transformations.py,sha256=YiQdLe2BNHupPxV9Gxt3VRSWKTRmqt4yObV0Wwij2Dw,32526
@@ -1071,8 +1071,8 @@ cirq/transformers/measurement_transformers.py,sha256=crAYKGK90drr_3GEh5t8-Z87eSE
1071
1071
  cirq/transformers/measurement_transformers_test.py,sha256=mJKYFqqMwZnD8KXVM1tmF2kcIZXkkZKlfOU9XbGxYpQ,29019
1072
1072
  cirq/transformers/merge_k_qubit_gates.py,sha256=v9vY3f52S9QR7D_Om4APSZ65rwJH6Z7g6Gf3pD_9H3I,4380
1073
1073
  cirq/transformers/merge_k_qubit_gates_test.py,sha256=523FmfCC7mGX_zecGaQ2tgdqBvMGiMinwJMIfKBgG8E,14016
1074
- cirq/transformers/merge_single_qubit_gates.py,sha256=OqQBPtKreJ7uqa7vjZpxCmX7oRN-llYMClG76TXt9kE,5806
1075
- cirq/transformers/merge_single_qubit_gates_test.py,sha256=0RgVmSuTOjiKSzmjSm8a3APwiOjRUWBzjbr7fHN4x1Y,9954
1074
+ cirq/transformers/merge_single_qubit_gates.py,sha256=86qjW19JTC5t38TdnTKtS-M8AG2tYUxSZ9w_tM59BsU,5968
1075
+ cirq/transformers/merge_single_qubit_gates_test.py,sha256=hj0iTOZVgsMxY8dQJl8EYvuCDICqzzs9Yw62p5Emsrk,11213
1076
1076
  cirq/transformers/noise_adding.py,sha256=ZBS-015Kc-BnoO-lMXfEGpCXbPu4whVgTXIB-E16ApQ,4476
1077
1077
  cirq/transformers/noise_adding_test.py,sha256=nHOoKUPBBOkWF6A_JhIO6-G0AuFkLKBCxH7e2BOem9M,2171
1078
1078
  cirq/transformers/optimize_for_target_gateset.py,sha256=QThizLtkzvZpUK-LG77ixuZXghDyWGNn6yHkNrzYR3o,7206
@@ -1220,8 +1220,8 @@ cirq/work/sampler.py,sha256=rxbMWvrhu3gfNSBjZKozw28lLKVvBAS_1EGyPdYe8Xg,19041
1220
1220
  cirq/work/sampler_test.py,sha256=SsMrRvLDYELyOAWLKISjkdEfrBwLYWRsT6D8WrsLM3Q,13533
1221
1221
  cirq/work/zeros_sampler.py,sha256=Fs2JWwq0n9zv7_G5Rm-9vPeHUag7uctcMOHg0JTkZpc,2371
1222
1222
  cirq/work/zeros_sampler_test.py,sha256=lQLgQDGBLtfImryys2HzQ2jOSGxHgc7-koVBUhv8qYk,3345
1223
- cirq_core-1.6.0.dev20250616231428.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1224
- cirq_core-1.6.0.dev20250616231428.dist-info/METADATA,sha256=T-f_H-p2BfE7d60tg9oVf-K619PMS2McnhqTYTgrm2E,4857
1225
- cirq_core-1.6.0.dev20250616231428.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
1226
- cirq_core-1.6.0.dev20250616231428.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1227
- cirq_core-1.6.0.dev20250616231428.dist-info/RECORD,,
1223
+ cirq_core-1.6.0.dev20250617235202.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1224
+ cirq_core-1.6.0.dev20250617235202.dist-info/METADATA,sha256=0Mkz-_pWOE6ULwSvbecsNQMwJ72cNZqTuQoG4G0-1Rk,4857
1225
+ cirq_core-1.6.0.dev20250617235202.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
1226
+ cirq_core-1.6.0.dev20250617235202.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1227
+ cirq_core-1.6.0.dev20250617235202.dist-info/RECORD,,