cirq-core 1.4.0.dev20231202032139__py3-none-any.whl → 1.4.0.dev20231205193004__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/_compat_test.py +45 -38
- cirq/_version.py +1 -1
- cirq/testing/_compat_test_data/__init__.py +3 -3
- cirq/testing/_compat_test_data/module_a/__init__.py +2 -2
- {cirq_core-1.4.0.dev20231202032139.dist-info → cirq_core-1.4.0.dev20231205193004.dist-info}/METADATA +1 -1
- {cirq_core-1.4.0.dev20231202032139.dist-info → cirq_core-1.4.0.dev20231205193004.dist-info}/RECORD +9 -9
- {cirq_core-1.4.0.dev20231202032139.dist-info → cirq_core-1.4.0.dev20231205193004.dist-info}/LICENSE +0 -0
- {cirq_core-1.4.0.dev20231202032139.dist-info → cirq_core-1.4.0.dev20231205193004.dist-info}/WHEEL +0 -0
- {cirq_core-1.4.0.dev20231202032139.dist-info → cirq_core-1.4.0.dev20231205193004.dist-info}/top_level.txt +0 -0
cirq/_compat_test.py
CHANGED
|
@@ -346,7 +346,7 @@ def test_wrap_module():
|
|
|
346
346
|
|
|
347
347
|
|
|
348
348
|
def test_deprecate_attributes_assert_attributes_in_sys_modules():
|
|
349
|
-
|
|
349
|
+
run_in_subprocess(_test_deprecate_attributes_assert_attributes_in_sys_modules)
|
|
350
350
|
|
|
351
351
|
|
|
352
352
|
def _test_deprecate_attributes_assert_attributes_in_sys_modules():
|
|
@@ -635,42 +635,49 @@ _repeated_child_deprecation_msg = [
|
|
|
635
635
|
] + _deprecation_origin
|
|
636
636
|
|
|
637
637
|
|
|
638
|
-
def _trace_unhandled_exceptions(*args, queue: 'multiprocessing.Queue', func: Callable
|
|
638
|
+
def _trace_unhandled_exceptions(*args, queue: 'multiprocessing.Queue', func: Callable):
|
|
639
639
|
try:
|
|
640
|
-
func(*args
|
|
640
|
+
func(*args)
|
|
641
641
|
queue.put(None)
|
|
642
642
|
except BaseException as ex:
|
|
643
643
|
msg = str(ex)
|
|
644
644
|
queue.put((type(ex).__name__, msg, traceback.format_exc()))
|
|
645
645
|
|
|
646
646
|
|
|
647
|
-
def
|
|
648
|
-
"""
|
|
647
|
+
def run_in_subprocess(test_func, *args):
|
|
648
|
+
"""Run a function in a subprocess.
|
|
649
|
+
|
|
650
|
+
This ensures that sys.modules changes in subprocesses won't impact the parent process.
|
|
651
|
+
|
|
652
|
+
Args:
|
|
653
|
+
test_func: The function to be run in a subprocess.
|
|
654
|
+
*args: Positional args to pass to the function.
|
|
655
|
+
"""
|
|
656
|
+
|
|
649
657
|
assert callable(test_func), (
|
|
650
|
-
"
|
|
658
|
+
"run_in_subprocess expects a function. Did you call the function instead of passing "
|
|
651
659
|
"it to this method?"
|
|
652
660
|
)
|
|
653
661
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
662
|
+
# Use spawn to ensure subprocesses are isolated.
|
|
663
|
+
# See https://github.com/quantumlib/Cirq/issues/6373
|
|
664
|
+
ctx = multiprocessing.get_context('spawn')
|
|
657
665
|
|
|
658
|
-
|
|
659
|
-
kwargs['queue'] = exception
|
|
660
|
-
kwargs['func'] = test_func
|
|
661
|
-
p = ctx.Process(target=_trace_unhandled_exceptions, args=args, kwargs=kwargs)
|
|
662
|
-
p.start()
|
|
663
|
-
p.join()
|
|
664
|
-
result = exception.get()
|
|
665
|
-
if result: # pragma: no cover
|
|
666
|
-
ex_type, msg, ex_trace = result
|
|
667
|
-
if ex_type == "Skipped":
|
|
668
|
-
warnings.warn(f"Skipping: {ex_type}: {msg}\n{ex_trace}")
|
|
669
|
-
pytest.skip(f'{ex_type}: {msg}\n{ex_trace}')
|
|
670
|
-
else:
|
|
671
|
-
pytest.fail(f'{ex_type}: {msg}\n{ex_trace}')
|
|
666
|
+
queue = ctx.Queue()
|
|
672
667
|
|
|
673
|
-
|
|
668
|
+
p = ctx.Process(
|
|
669
|
+
target=_trace_unhandled_exceptions, args=args, kwargs={'queue': queue, 'func': test_func}
|
|
670
|
+
)
|
|
671
|
+
p.start()
|
|
672
|
+
p.join()
|
|
673
|
+
result = queue.get()
|
|
674
|
+
if result: # pragma: no cover
|
|
675
|
+
ex_type, msg, ex_trace = result
|
|
676
|
+
if ex_type == "Skipped":
|
|
677
|
+
warnings.warn(f"Skipping: {ex_type}: {msg}\n{ex_trace}")
|
|
678
|
+
pytest.skip(f'{ex_type}: {msg}\n{ex_trace}')
|
|
679
|
+
else:
|
|
680
|
+
pytest.fail(f'{ex_type}: {msg}\n{ex_trace}')
|
|
674
681
|
|
|
675
682
|
|
|
676
683
|
@mock.patch.dict(os.environ, {"CIRQ_FORCE_DEDUPE_MODULE_DEPRECATION": "1"})
|
|
@@ -698,7 +705,7 @@ def subprocess_context(test_func):
|
|
|
698
705
|
],
|
|
699
706
|
)
|
|
700
707
|
def test_deprecated_module(outdated_method, deprecation_messages):
|
|
701
|
-
|
|
708
|
+
run_in_subprocess(_test_deprecated_module_inner, outdated_method, deprecation_messages)
|
|
702
709
|
|
|
703
710
|
|
|
704
711
|
def _test_deprecated_module_inner(outdated_method, deprecation_messages):
|
|
@@ -736,7 +743,7 @@ def test_same_name_submodule_earlier_in_subtree():
|
|
|
736
743
|
cirq.ops.engine.calibration packages. The wrong resolution resulted in false circular
|
|
737
744
|
imports!
|
|
738
745
|
"""
|
|
739
|
-
|
|
746
|
+
run_in_subprocess(_test_same_name_submodule_earlier_in_subtree_inner)
|
|
740
747
|
|
|
741
748
|
|
|
742
749
|
def _test_same_name_submodule_earlier_in_subtree_inner():
|
|
@@ -748,7 +755,7 @@ def _test_same_name_submodule_earlier_in_subtree_inner():
|
|
|
748
755
|
def test_metadata_search_path():
|
|
749
756
|
# to cater for metadata path finders
|
|
750
757
|
# https://docs.python.org/3/library/importlib.metadata.html#extending-the-search-algorithm
|
|
751
|
-
|
|
758
|
+
run_in_subprocess(_test_metadata_search_path_inner)
|
|
752
759
|
|
|
753
760
|
|
|
754
761
|
def _test_metadata_search_path_inner(): # pragma: no cover
|
|
@@ -760,7 +767,7 @@ def _test_metadata_search_path_inner(): # pragma: no cover
|
|
|
760
767
|
|
|
761
768
|
|
|
762
769
|
def test_metadata_distributions_after_deprecated_submodule():
|
|
763
|
-
|
|
770
|
+
run_in_subprocess(_test_metadata_distributions_after_deprecated_submodule)
|
|
764
771
|
|
|
765
772
|
|
|
766
773
|
def _test_metadata_distributions_after_deprecated_submodule():
|
|
@@ -779,7 +786,7 @@ def _test_metadata_distributions_after_deprecated_submodule():
|
|
|
779
786
|
|
|
780
787
|
|
|
781
788
|
def test_parent_spec_after_deprecated_submodule():
|
|
782
|
-
|
|
789
|
+
run_in_subprocess(_test_parent_spec_after_deprecated_submodule)
|
|
783
790
|
|
|
784
791
|
|
|
785
792
|
def _test_parent_spec_after_deprecated_submodule():
|
|
@@ -791,7 +798,7 @@ def _test_parent_spec_after_deprecated_submodule():
|
|
|
791
798
|
def test_type_repr_in_new_module():
|
|
792
799
|
# to cater for metadata path finders
|
|
793
800
|
# https://docs.python.org/3/library/importlib.metadata.html#extending-the-search-algorithm
|
|
794
|
-
|
|
801
|
+
run_in_subprocess(_test_type_repr_in_new_module_inner)
|
|
795
802
|
|
|
796
803
|
|
|
797
804
|
def _test_type_repr_in_new_module_inner():
|
|
@@ -849,19 +856,19 @@ def _test_broken_module_3_inner():
|
|
|
849
856
|
|
|
850
857
|
|
|
851
858
|
def test_deprecated_module_error_handling_1():
|
|
852
|
-
|
|
859
|
+
run_in_subprocess(_test_broken_module_1_inner)
|
|
853
860
|
|
|
854
861
|
|
|
855
862
|
def test_deprecated_module_error_handling_2():
|
|
856
|
-
|
|
863
|
+
run_in_subprocess(_test_broken_module_2_inner)
|
|
857
864
|
|
|
858
865
|
|
|
859
866
|
def test_deprecated_module_error_handling_3():
|
|
860
|
-
|
|
867
|
+
run_in_subprocess(_test_broken_module_3_inner)
|
|
861
868
|
|
|
862
869
|
|
|
863
870
|
def test_new_module_is_top_level():
|
|
864
|
-
|
|
871
|
+
run_in_subprocess(_test_new_module_is_top_level_inner)
|
|
865
872
|
|
|
866
873
|
|
|
867
874
|
def _test_new_module_is_top_level_inner():
|
|
@@ -877,7 +884,7 @@ def _test_new_module_is_top_level_inner():
|
|
|
877
884
|
|
|
878
885
|
|
|
879
886
|
def test_import_deprecated_with_no_attribute():
|
|
880
|
-
|
|
887
|
+
run_in_subprocess(_test_import_deprecated_with_no_attribute_inner)
|
|
881
888
|
|
|
882
889
|
|
|
883
890
|
def _test_import_deprecated_with_no_attribute_inner():
|
|
@@ -970,7 +977,7 @@ def test_deprecated_module_loader_repr():
|
|
|
970
977
|
|
|
971
978
|
def test_subprocess_test_failure():
|
|
972
979
|
with pytest.raises(Failed, match='ValueError.*this fails'):
|
|
973
|
-
|
|
980
|
+
run_in_subprocess(_test_subprocess_test_failure_inner)
|
|
974
981
|
|
|
975
982
|
|
|
976
983
|
def _test_subprocess_test_failure_inner():
|
|
@@ -978,7 +985,7 @@ def _test_subprocess_test_failure_inner():
|
|
|
978
985
|
|
|
979
986
|
|
|
980
987
|
def test_dir_is_still_valid():
|
|
981
|
-
|
|
988
|
+
run_in_subprocess(_dir_is_still_valid_inner)
|
|
982
989
|
|
|
983
990
|
|
|
984
991
|
def _dir_is_still_valid_inner():
|
|
@@ -986,7 +993,7 @@ def _dir_is_still_valid_inner():
|
|
|
986
993
|
|
|
987
994
|
import cirq.testing._compat_test_data as mod
|
|
988
995
|
|
|
989
|
-
for m in ['fake_a', '
|
|
996
|
+
for m in ['fake_a', 'logging', 'module_a']:
|
|
990
997
|
assert m in dir(mod)
|
|
991
998
|
|
|
992
999
|
|
cirq/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.4.0.
|
|
1
|
+
__version__ = "1.4.0.dev20231205193004"
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
See cirq/_compat_test.py for the tests.
|
|
4
4
|
This module contains example deprecations for modules.
|
|
5
5
|
"""
|
|
6
|
-
import
|
|
7
|
-
|
|
6
|
+
import logging
|
|
7
|
+
|
|
8
8
|
from cirq import _compat
|
|
9
9
|
|
|
10
|
-
info("init:compat_test_data")
|
|
10
|
+
logging.info("init:compat_test_data")
|
|
11
11
|
|
|
12
12
|
# simulates a rename of a child module
|
|
13
13
|
# fake_a -> module_a
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# pylint: disable=wrong-or-nonexistent-copyright-notice
|
|
2
2
|
"""module_a for module deprecation tests"""
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import logging
|
|
5
5
|
|
|
6
6
|
from cirq.testing._compat_test_data.module_a import module_b
|
|
7
7
|
|
|
@@ -11,4 +11,4 @@ from cirq.testing._compat_test_data.module_a.types import SampleType
|
|
|
11
11
|
|
|
12
12
|
MODULE_A_ATTRIBUTE = "module_a"
|
|
13
13
|
|
|
14
|
-
info("init:module_a")
|
|
14
|
+
logging.info("init:module_a")
|
{cirq_core-1.4.0.dev20231202032139.dist-info → cirq_core-1.4.0.dev20231205193004.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cirq-core
|
|
3
|
-
Version: 1.4.0.
|
|
3
|
+
Version: 1.4.0.dev20231205193004
|
|
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
|
{cirq_core-1.4.0.dev20231202032139.dist-info → cirq_core-1.4.0.dev20231205193004.dist-info}/RECORD
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
cirq/__init__.py,sha256=GlOnPWDvat-Y203LsbXhkC0UnGm9HHiNx2ywz7Bkc3o,15708
|
|
2
2
|
cirq/_compat.py,sha256=YPvewnC0gajEIRjauyz_EuDzs38g-bIBkY_0h91U4Pc,29363
|
|
3
|
-
cirq/_compat_test.py,sha256=
|
|
3
|
+
cirq/_compat_test.py,sha256=iQJYqIP1uyRe8mNUwi2VKccyUaJDFYH7b3Fg6cqQLQw,35053
|
|
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=
|
|
7
|
+
cirq/_version.py,sha256=bPusEL63Fj5s7vUPxSsbOc3T7QzxwWpnr6_TEAug_MA,40
|
|
8
8
|
cirq/_version_test.py,sha256=yYS6xm5-nuBRQJa9R3n41WdvFtVyY7Lb5Q8bea3VgBI,133
|
|
9
9
|
cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
|
|
10
10
|
cirq/json_resolver_cache.py,sha256=S0HaPOCUIck-vNSQlS6KxnQtle6w-2dGuSxkUbJQY9Y,13168
|
|
@@ -988,8 +988,8 @@ cirq/testing/sample_circuits.py,sha256=8HTrY_RWoPHV18q7aLz6e5Fjd2Twkt9Wkc_IDBzTE
|
|
|
988
988
|
cirq/testing/sample_circuits_test.py,sha256=IMz72CMXJeRt7Eg1rRB68hFV1v3k7OQpYUyhqmfjNpo,876
|
|
989
989
|
cirq/testing/sample_gates.py,sha256=qSCZhb-A-Mwm_J81Su2sUFyEUdvqfq7Je66dsk8cFy0,3277
|
|
990
990
|
cirq/testing/sample_gates_test.py,sha256=mkfYPNo4WFH6y33Vr_f9zy2Ry1oq5yYLpB__sqSCkjQ,2377
|
|
991
|
-
cirq/testing/_compat_test_data/__init__.py,sha256=
|
|
992
|
-
cirq/testing/_compat_test_data/module_a/__init__.py,sha256=
|
|
991
|
+
cirq/testing/_compat_test_data/__init__.py,sha256=T9LHBgX2CLUvAloqrH0F1AAXdtgMuQvG3vZZhNbg61A,3028
|
|
992
|
+
cirq/testing/_compat_test_data/module_a/__init__.py,sha256=MHrL6kJFnYTXaRT-bW-gVPzizJCN4bIU8ZFB-tXUGZg,384
|
|
993
993
|
cirq/testing/_compat_test_data/module_a/types.py,sha256=XFNOEP88FMOOCgF6jBumwsIBwIr-6KyK7ciaVzMN7T8,83
|
|
994
994
|
cirq/testing/_compat_test_data/module_a/dupe/__init__.py,sha256=1h4X6AYURm5r2WFH26BltHzn0RzAv94Lf80DlKaG6xc,78
|
|
995
995
|
cirq/testing/_compat_test_data/module_a/module_b/__init__.py,sha256=QPjVtgaK3kM9SPi3NocWmZ4FGh_V6Ct5qDHZkDIeCCU,159
|
|
@@ -1148,8 +1148,8 @@ cirq/work/sampler.py,sha256=JVv1vvfa6EgFiR3UeDk44U186dCrioH2NZXueCgsb9w,19828
|
|
|
1148
1148
|
cirq/work/sampler_test.py,sha256=zo1Hj6sn6fLs_WZMxYRApBqgBsldmptn74NL0jhNukc,12325
|
|
1149
1149
|
cirq/work/zeros_sampler.py,sha256=x1C7cup66a43n-3tm8QjhiqJa07qcJW10FxNp9jJ59Q,2356
|
|
1150
1150
|
cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
|
|
1151
|
-
cirq_core-1.4.0.
|
|
1152
|
-
cirq_core-1.4.0.
|
|
1153
|
-
cirq_core-1.4.0.
|
|
1154
|
-
cirq_core-1.4.0.
|
|
1155
|
-
cirq_core-1.4.0.
|
|
1151
|
+
cirq_core-1.4.0.dev20231205193004.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
|
|
1152
|
+
cirq_core-1.4.0.dev20231205193004.dist-info/METADATA,sha256=FwG8ECCsAQAUaqeF25XXgH2kY75fBlFEpyFijcsGkYs,2075
|
|
1153
|
+
cirq_core-1.4.0.dev20231205193004.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
1154
|
+
cirq_core-1.4.0.dev20231205193004.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
|
|
1155
|
+
cirq_core-1.4.0.dev20231205193004.dist-info/RECORD,,
|
{cirq_core-1.4.0.dev20231202032139.dist-info → cirq_core-1.4.0.dev20231205193004.dist-info}/LICENSE
RENAMED
|
File without changes
|
{cirq_core-1.4.0.dev20231202032139.dist-info → cirq_core-1.4.0.dev20231205193004.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|