cirq-core 1.5.0.dev20240807173926__py3-none-any.whl → 1.5.0.dev20240814002711__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.dev20240807173926"
31
+ __version__ = "1.5.0.dev20240814002711"
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.dev20240807173926"
6
+ assert cirq.__version__ == "1.5.0.dev20240814002711"
@@ -741,6 +741,7 @@ def test_kak_decompose(unitary: np.ndarray):
741
741
  assert len(list(circuit.all_operations())) == 8
742
742
 
743
743
 
744
+ @cirq.testing.retry_once_with_later_random_values
744
745
  def test_num_two_qubit_gates_required():
745
746
  for i in range(4):
746
747
  assert (
@@ -870,7 +870,7 @@ def _projector_string_from_projector_dict(projector_dict, coefficient=1.0):
870
870
  return ProjectorString(dict(projector_dict), coefficient)
871
871
 
872
872
 
873
- @value.value_equality(approximate=True)
873
+ @value.value_equality(approximate=True, unhashable=True)
874
874
  class ProjectorSum:
875
875
  """List of mappings representing a sum of projector operators."""
876
876
 
@@ -46,8 +46,6 @@ _EXCLUDE_JSON_FILES = (
46
46
  "cirq/protocols/json_test_data/sympy.pi.json",
47
47
  # RigettiQCSAspenDevice does not pickle
48
48
  "cirq_rigetti/json_test_data/RigettiQCSAspenDevice.json",
49
- # TODO(#6674,pavoljuhas) - fix pickling of ProjectorSum
50
- "cirq/protocols/json_test_data/ProjectorSum.json",
51
49
  )
52
50
 
53
51
 
cirq/testing/__init__.py CHANGED
@@ -96,6 +96,8 @@ from cirq.testing.op_tree import assert_equivalent_op_tree
96
96
 
97
97
  from cirq.testing.order_tester import OrderTester
98
98
 
99
+ from cirq.testing.pytest_randomly_utils import retry_once_with_later_random_values
100
+
99
101
  from cirq.testing.random_circuit import (
100
102
  DEFAULT_GATE_DOMAIN,
101
103
  random_circuit,
@@ -0,0 +1,38 @@
1
+ # Copyright 2024 The Cirq Developers
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Support one retry of tests that fail for a specific seed from pytest-randomly."""
16
+
17
+ import functools
18
+ import warnings
19
+ from typing import Any, Callable
20
+
21
+
22
+ def retry_once_with_later_random_values(testfunc: Callable) -> Callable:
23
+ """Marks a test function for one retry with later random values.
24
+
25
+ This decorator is intended for test functions which occasionally fail
26
+ for specific random seeds from pytest-randomly.
27
+ """
28
+
29
+ @functools.wraps(testfunc)
30
+ def wrapped_func(*args, **kwargs) -> Any:
31
+ try:
32
+ return testfunc(*args, **kwargs)
33
+ except AssertionError:
34
+ pass
35
+ warnings.warn("Retrying in case we got a failing seed from pytest-randomly.")
36
+ return testfunc(*args, **kwargs)
37
+
38
+ return wrapped_func
@@ -0,0 +1,27 @@
1
+ # Copyright 2024 The Cirq Developers
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from unittest.mock import Mock
16
+
17
+ import pytest
18
+
19
+ import cirq
20
+
21
+
22
+ def test_retry_once_with_later_random_values():
23
+ testfunc = Mock(side_effect=[AssertionError("first call fails"), None])
24
+ decoratedfunc = cirq.testing.retry_once_with_later_random_values(testfunc)
25
+ with pytest.warns(UserWarning, match="Retrying.*failing seed.*pytest-randomly"):
26
+ decoratedfunc()
27
+ assert testfunc.call_count == 2
@@ -87,6 +87,7 @@ def test_decompose_specific_matrices():
87
87
  _test_decompose(cirq.unitary(gate), controls_count)
88
88
 
89
89
 
90
+ @cirq.testing.retry_once_with_later_random_values
90
91
  def test_decompose_random_unitary():
91
92
  for controls_count in range(5):
92
93
  for _ in range(10):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cirq-core
3
- Version: 1.5.0.dev20240807173926
3
+ Version: 1.5.0.dev20240814002711
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=jvby6efB3zbe4ahafK4kKy13_e_C0VNd6OXgl1c15K4,1206
8
- cirq/_version_test.py,sha256=r5EpZqLFuek4oLn_CnINb5NHRsLsYyE1kuF54es-zH4,147
7
+ cirq/_version.py,sha256=fmCyCY7Pm5UdYjGnHLzOVEiRXFk8VkblsSzjF2LHmUI,1206
8
+ cirq/_version_test.py,sha256=dC1KfSk_f4fRPpIE9BCHCMwad7uZ3ihLEXxj7uuZzs0,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
@@ -247,7 +247,7 @@ cirq/linalg/__init__.py,sha256=iMN1jVWzuZrSdHuE-gN2N1QyP0q6wgj6F4zetxJLCJQ,2527
247
247
  cirq/linalg/combinators.py,sha256=5q_cNjnJrDgC7qMX8rYdnCmBKXT_iVbtxnCeJQ4ZPTM,5350
248
248
  cirq/linalg/combinators_test.py,sha256=nZ3snkVA2nAOZ6WJK1hNd1f_i2a5xNdnostfMD1upbc,4699
249
249
  cirq/linalg/decompositions.py,sha256=cNIcKylK4tnGgIreO7X4cpsRmwvOycKRSS8xf9gaIG0,39229
250
- cirq/linalg/decompositions_test.py,sha256=-6q2u3BDG9b32QSUAjhmBNWrL3KzyiMH_R0WIHhdOqU,25790
250
+ cirq/linalg/decompositions_test.py,sha256=S6p9AJO_9wwQdmNHYTAgBK4TL6_lz1U93sLNNuUJmBw,25840
251
251
  cirq/linalg/diagonalize.py,sha256=Ym7C0JTAC9xfRQDYI72U6NxMYg0DfchjfXcbdg_92QE,10051
252
252
  cirq/linalg/diagonalize_test.py,sha256=H-JcLvcCBdN-DrKo2o1Gs7B8Q9SU70oAZmdT4yTLAi4,9089
253
253
  cirq/linalg/operator_spaces.py,sha256=uZSc9154p63R2UqFw6pniuWcUo20epe5RK6bL3tpkbM,3813
@@ -307,7 +307,7 @@ cirq/ops/identity.py,sha256=4H67nV4i85wi3HWY-k5ImC9hX9U6BjIZp61JalHpsTI,5503
307
307
  cirq/ops/identity_test.py,sha256=dGx9nzeFCoVo3SmlEbqCGJT1XyzJh-qoPl9n2gEd9WQ,7422
308
308
  cirq/ops/kraus_channel.py,sha256=tCPAEzr_GAL5vTwI43rBoiOnT04l-ebZanuuEuYWDo8,5085
309
309
  cirq/ops/kraus_channel_test.py,sha256=qH2Y9cngXzKCabd-Mq5xBYcM_wyL8c6KkrXw8kZr7Dc,4726
310
- cirq/ops/linear_combinations.py,sha256=1BynexPtrNc26McHXv3rErh6NYGzcxNqXWyWJ11ugDw,39668
310
+ cirq/ops/linear_combinations.py,sha256=vK-IKHwdIBbOEaUz92JaA3uC4WTIDgUYCOCa1zZpdkw,39685
311
311
  cirq/ops/linear_combinations_test.py,sha256=qpzRo53mJtcidYE11loKMP2b9guKMGtzrKWQ_u0jr4Y,66387
312
312
  cirq/ops/matrix_gates.py,sha256=8ARvpHWYFgwmlT99-Gxoa24i_mxKLvdj_RhoQvglKQw,9290
313
313
  cirq/ops/matrix_gates_test.py,sha256=m5rMwq_sqVvsmkc5opVr3Ikd1ERuULmSRNAvGZUg7ds,14224
@@ -399,7 +399,7 @@ cirq/protocols/has_stabilizer_effect_protocol.py,sha256=XH6Lv9SGuYhuuSB0mi5v8Eg5
399
399
  cirq/protocols/has_stabilizer_effect_protocol_test.py,sha256=0ia7ehyGpmscjRP448dBANZKwnlbqSODdPUYRUhDEN0,3879
400
400
  cirq/protocols/has_unitary_protocol.py,sha256=inj17qr8Pz2Zofj0Lsp2o7TWlfmdU1TybtRjs1TWVow,5372
401
401
  cirq/protocols/has_unitary_protocol_test.py,sha256=IjmJ3dqvteFUUO4FLwCTokgUvYy8H2HJjLmTDzt2__Q,5610
402
- cirq/protocols/hash_from_pickle_test.py,sha256=M95CrhwfXpavflvSetxUF7Qsm8boHoki4fZy2Tdijl8,4176
402
+ cirq/protocols/hash_from_pickle_test.py,sha256=kjGb1_7Hil8egA3b_fkvA8xOJpuac0vd5dH-GtWgMN8,4061
403
403
  cirq/protocols/inverse_protocol.py,sha256=CEqtGRRj86WQyyALonRXxQrNq-fENOs_Zqrlr_BVau8,4115
404
404
  cirq/protocols/inverse_protocol_test.py,sha256=pqqIU4_G4Npc9Z-SeoM9eCB2T5JRTeI02NCXhP0UtaI,2017
405
405
  cirq/protocols/json_serialization.py,sha256=Otrrzsi74rfE_2wbK-xBUI3QzQaRnEXqsY1D_ktW4jk,24360
@@ -943,7 +943,7 @@ cirq/study/sweepable.py,sha256=hHBXn5MQZJawiiIXWZdn_qygbPeIFtt300wIqVHiYl8,4356
943
943
  cirq/study/sweepable_test.py,sha256=ENv03_GJmbUc_ukJoqfgG-H5C_yyx1jCcvxohSMyQVU,5502
944
944
  cirq/study/sweeps.py,sha256=zKz8hmLnpukNzUp7YjsrD8wEGxf2peX19522kUKUfWI,19850
945
945
  cirq/study/sweeps_test.py,sha256=YdXHzZO10OHoPTU2ifmsfH7KByIJeeANy91AHqX8nwg,12135
946
- cirq/testing/__init__.py,sha256=cACho8s-V5tNOjBcDUtr2DipQxQcbUgbr4MESJb4l1I,3870
946
+ cirq/testing/__init__.py,sha256=nYda18836pCF9HkhLUYQD5Nd_tI-3Fyd-ZQ4cGmwX-Y,3954
947
947
  cirq/testing/circuit_compare.py,sha256=nBQES45wLVThOqC3WrPrYKLQP7HQ2pH5DjlJ5bHkrtU,19176
948
948
  cirq/testing/circuit_compare_test.py,sha256=AduZCzwBNFCYrjEpyS1DvIR6jU8GaFqQBBgPXyIALoU,19743
949
949
  cirq/testing/consistent_act_on.py,sha256=ofYxdotw7fDfEVaAoM3NJEG2-hTHmi5FlLZkLYfVBWE,7733
@@ -991,6 +991,8 @@ cirq/testing/op_tree.py,sha256=fb3bOoTihGWp_NvPHekI7s9YZIaBoiufDVhh4ARCfhQ,954
991
991
  cirq/testing/op_tree_test.py,sha256=MwDpi5Lw1e3Y_-9Psx9MPvbbW2x4JlOpp7hl8mBvOQA,1073
992
992
  cirq/testing/order_tester.py,sha256=0_tfixWyX_HrjTXpNrVFZT9bA6J585Ad8tjS-DsX8yU,6690
993
993
  cirq/testing/order_tester_test.py,sha256=2mifnUW_BT17jwWZjmM9p7EoJjq0Ouz54o3G8BqvDqw,5111
994
+ cirq/testing/pytest_randomly_utils.py,sha256=9zF-7EdoBoNO8bl5DRzvmttXSPZMsuoQ9ktEqv8sCZw,1352
995
+ cirq/testing/pytest_randomly_utils_test.py,sha256=gUz2C-azAtgDilAnWXLsOq5NzSJqLg7ykX8-86fLzoc,994
994
996
  cirq/testing/random_circuit.py,sha256=oMoz0_VWWVmUGmJ9mu1R7NByNKtSadxdLjFyDEE1qT0,5900
995
997
  cirq/testing/random_circuit_test.py,sha256=x0ovYOIc3-QNKFjCc87LbLkWNwFZKx6T97ZCN3QGRsI,7026
996
998
  cirq/testing/repr_pretty_tester.py,sha256=dtk713qmE87Biaez3c8R83Wb7tlb4xWFfzt44iKkbto,2899
@@ -1061,7 +1063,7 @@ cirq/transformers/analytical_decompositions/__init__.py,sha256=ZNtETntol3G_n6uqz
1061
1063
  cirq/transformers/analytical_decompositions/clifford_decomposition.py,sha256=DsuuP91pm2dX0CO4rWwmJAJyAfuXMcA1UJK0g8krp7k,6726
1062
1064
  cirq/transformers/analytical_decompositions/clifford_decomposition_test.py,sha256=AAZh_9vEb5f2E_EItPZTlMRNdv0d47AwqTn4BytX0UI,7102
1063
1065
  cirq/transformers/analytical_decompositions/controlled_gate_decomposition.py,sha256=iFF2vb5tI4PVQVHBOP_tuy8EKUtGg8aMDZSdK-74YMI,8675
1064
- cirq/transformers/analytical_decompositions/controlled_gate_decomposition_test.py,sha256=Pc1vNvRxcYJEERASHbCqPX1bqImGd7FzWnQcUcIo_YU,4950
1066
+ cirq/transformers/analytical_decompositions/controlled_gate_decomposition_test.py,sha256=oVr92Kdvent8x5xLpK3clT1a3OM0QTs2DmrsuJhV7ag,5000
1065
1067
  cirq/transformers/analytical_decompositions/cphase_to_fsim.py,sha256=RDg0wzYa_YXBJepCgloD_OIwTOwNco98dqGoe0UsnhI,9108
1066
1068
  cirq/transformers/analytical_decompositions/cphase_to_fsim_test.py,sha256=bwZa0BDclAd1sX3bD-GdNF2MO5DtH7mw2YLppEK0LG0,5568
1067
1069
  cirq/transformers/analytical_decompositions/pauli_string_decomposition.py,sha256=bU9IoY0igVZTmF_wsTdTxAfqPKWyqZ14Gt2AJoK5D_4,4524
@@ -1182,8 +1184,8 @@ cirq/work/sampler.py,sha256=JEAeQQRF3bqlO9AkOf4XbrTATDI5f5JgyM_FAUCNxao,19751
1182
1184
  cirq/work/sampler_test.py,sha256=B2ZsuqGT854gQtBIAh8k0LiG9Vj5wSzcGvkxOUoTcW4,13217
1183
1185
  cirq/work/zeros_sampler.py,sha256=x1C7cup66a43n-3tm8QjhiqJa07qcJW10FxNp9jJ59Q,2356
1184
1186
  cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
1185
- cirq_core-1.5.0.dev20240807173926.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1186
- cirq_core-1.5.0.dev20240807173926.dist-info/METADATA,sha256=_4_5OYVZqfwvNsyZ--WrZ69qIt6OjqM-0JKKVAsFq5c,1992
1187
- cirq_core-1.5.0.dev20240807173926.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
1188
- cirq_core-1.5.0.dev20240807173926.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1189
- cirq_core-1.5.0.dev20240807173926.dist-info/RECORD,,
1187
+ cirq_core-1.5.0.dev20240814002711.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1188
+ cirq_core-1.5.0.dev20240814002711.dist-info/METADATA,sha256=sNKverX-50tJKueK3U_MIsWlv0yQMQ4_-TxNc1d-tLE,1992
1189
+ cirq_core-1.5.0.dev20240814002711.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
1190
+ cirq_core-1.5.0.dev20240814002711.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1191
+ cirq_core-1.5.0.dev20240814002711.dist-info/RECORD,,