From 662aa05659efc9440e976a552aca8614f4437ee8 Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Wed, 14 Feb 2024 14:13:36 -0800 Subject: [PATCH 1/5] Temporarily error on DeprecationWarning-s so they show up in the CI --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 35a7af04740..2942c61972f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,6 +8,9 @@ skip-magic-trailing-comma = true filterwarnings = [ "ignore:Matplotlib is currently using agg:UserWarning", "ignore:FigureCanvasAgg is non-interactive.*cannot be shown:UserWarning", + # temporarily expose following deprecations in the CI + "error:`np.*` is a deprecated alias:DeprecationWarning:(cirq|)", + "error:NotImplemented should not be used in a boolean context:DeprecationWarning", ] markers = [ "rigetti_integration: tests that connect to Quil compiler or QVM.", From c23dcf176e2f759085f87a9e612616c9a9e23aa1 Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Wed, 14 Feb 2024 14:16:25 -0800 Subject: [PATCH 2/5] Replace deprecated numpy aliases for dtype-s * replace `np.int0` --> `np.intp` * replace `np.uint0` --> `np.uintp` --- .../cirq/protocols/approximate_equality_protocol_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cirq-core/cirq/protocols/approximate_equality_protocol_test.py b/cirq-core/cirq/protocols/approximate_equality_protocol_test.py index 7d8f8319143..57435be748d 100644 --- a/cirq-core/cirq/protocols/approximate_equality_protocol_test.py +++ b/cirq-core/cirq/protocols/approximate_equality_protocol_test.py @@ -47,11 +47,11 @@ def test_approx_eq_mixed_primitives(): def test_numpy_dtype_compatibility(): i_a, i_b, i_c = 0, 1, 2 - i_types = [np.intc, np.intp, np.int0, np.int8, np.int16, np.int32, np.int64] + i_types = [np.intc, np.intp, np.int8, np.int16, np.int32, np.int64] for i_type in i_types: assert cirq.approx_eq(i_type(i_a), i_type(i_b), atol=1) assert not cirq.approx_eq(i_type(i_a), i_type(i_c), atol=1) - u_types = [np.uint, np.uint0, np.uint8, np.uint16, np.uint32, np.uint64] + u_types = [np.uint, np.uintp, np.uint8, np.uint16, np.uint32, np.uint64] for u_type in u_types: assert cirq.approx_eq(u_type(i_a), u_type(i_b), atol=1) assert not cirq.approx_eq(u_type(i_a), u_type(i_c), atol=1) From ba462165440269226af3b9f35d984c2430da77bf Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Wed, 14 Feb 2024 14:54:33 -0800 Subject: [PATCH 3/5] Address deprecation warning about NotImplemented used as boolean --- cirq-core/cirq/protocols/resolve_parameters.py | 6 ++++-- cirq-core/cirq/sim/simulation_state_test.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cirq-core/cirq/protocols/resolve_parameters.py b/cirq-core/cirq/protocols/resolve_parameters.py index 3243f26b555..967780ff3fb 100644 --- a/cirq-core/cirq/protocols/resolve_parameters.py +++ b/cirq-core/cirq/protocols/resolve_parameters.py @@ -178,8 +178,10 @@ def resolve_parameters( if isinstance(val, (list, tuple)): return cast(T, type(val)(resolve_parameters(e, param_resolver, recursive) for e in val)) - is_parameterized = getattr(val, '_is_parameterized_', None) - if is_parameterized is not None and not is_parameterized(): + is_parameterized = ( + val._is_parameterized_() if hasattr(val, '_is_parameterized_') else NotImplemented + ) + if is_parameterized is NotImplemented or not is_parameterized: return val getter = getattr(val, '_resolve_parameters_', None) diff --git a/cirq-core/cirq/sim/simulation_state_test.py b/cirq-core/cirq/sim/simulation_state_test.py index eab1e884676..f493c1f1435 100644 --- a/cirq-core/cirq/sim/simulation_state_test.py +++ b/cirq-core/cirq/sim/simulation_state_test.py @@ -43,8 +43,8 @@ def _act_on_fallback_( return True def add_qubits(self, qubits): - ret = super().add_qubits(qubits) - return self if NotImplemented else ret + super().add_qubits(qubits) + return self class DelegatingAncillaZ(cirq.Gate): From 5a8c13b649c37350ed9703dcbfc23107f7080e5e Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Wed, 14 Feb 2024 15:17:36 -0800 Subject: [PATCH 4/5] Fix typo in boolean expression --- cirq-core/cirq/protocols/resolve_parameters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cirq-core/cirq/protocols/resolve_parameters.py b/cirq-core/cirq/protocols/resolve_parameters.py index 967780ff3fb..cc515f45522 100644 --- a/cirq-core/cirq/protocols/resolve_parameters.py +++ b/cirq-core/cirq/protocols/resolve_parameters.py @@ -181,7 +181,7 @@ def resolve_parameters( is_parameterized = ( val._is_parameterized_() if hasattr(val, '_is_parameterized_') else NotImplemented ) - if is_parameterized is NotImplemented or not is_parameterized: + if is_parameterized is not NotImplemented and not is_parameterized: return val getter = getattr(val, '_resolve_parameters_', None) From f6254ff3492f3eb7822c43cc69da5a0779335427 Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Thu, 15 Feb 2024 10:22:03 -0800 Subject: [PATCH 5/5] Revert "Temporarily error on DeprecationWarning-s so they show up in the CI" This reverts commit 662aa05659efc9440e976a552aca8614f4437ee8. --- pyproject.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2942c61972f..35a7af04740 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,9 +8,6 @@ skip-magic-trailing-comma = true filterwarnings = [ "ignore:Matplotlib is currently using agg:UserWarning", "ignore:FigureCanvasAgg is non-interactive.*cannot be shown:UserWarning", - # temporarily expose following deprecations in the CI - "error:`np.*` is a deprecated alias:DeprecationWarning:(cirq|)", - "error:NotImplemented should not be used in a boolean context:DeprecationWarning", ] markers = [ "rigetti_integration: tests that connect to Quil compiler or QVM.",