From 344764217971d388405a0ab8bbe0336e53b357ce Mon Sep 17 00:00:00 2001 From: Jake Lishman Date: Fri, 28 Jun 2024 01:42:38 +0100 Subject: [PATCH 1/4] Suppress nonsense `DeprecationWarning` caused by `unittest` `unittest.TestCase.assertWarns` in context-manager form has an awkward habit of querying the `__warningregistry__` attribute on every module in existence. This interacts poorly with a Numpy 2 deprecation warning trigger for code that's attempting to import functions from modules that became private in Numpy 2, if a warning has previously been triggered out of `numpy.linalg._linalg`. This simply suppresses that particular warning from the test suite. --- test/utils/base.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/utils/base.py b/test/utils/base.py index bebf03008858..51c4e053b3b1 100644 --- a/test/utils/base.py +++ b/test/utils/base.py @@ -204,6 +204,20 @@ def setUpClass(cls): warnings.filterwarnings("error", category=DeprecationWarning) warnings.filterwarnings("error", category=QiskitWarning) + # Numpy 2 made a few new modules private, and have warnings that trigger if you try to + # access attributes that _would_ have existed. Unfortunately, Python's `warnings` module + # adds a field called `__warningregistry__` to any module that triggers a warning, and + # `unittest.TestCase.assertWarns` then queries said fields on all existing modules. On + # macOS ARM, we see some (we think harmless) warnings come out of `numpy.linalg._linalg` (a + # now-private module) during transpilation, which means that subsequent `assertWarns` calls + # can spuriously trick Numpy into sending out a nonsense `DeprecationWarning`. + warnings.filterwarnings( + "ignore", + category=DeprecationWarning, + message="__warningregistry__", + module=r"numpy(\.\w+)*", + ) + # We only use pandas transitively through seaborn, so it's their responsibility to mark if # their use of pandas would be a problem. warnings.filterwarnings( From e1b4adc8dd933d905abed83c5049df17122e633c Mon Sep 17 00:00:00 2001 From: Jake Lishman Date: Fri, 28 Jun 2024 02:06:38 +0100 Subject: [PATCH 2/4] Refine filter --- test/utils/base.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/utils/base.py b/test/utils/base.py index 51c4e053b3b1..b9b5426b337a 100644 --- a/test/utils/base.py +++ b/test/utils/base.py @@ -214,8 +214,7 @@ def setUpClass(cls): warnings.filterwarnings( "ignore", category=DeprecationWarning, - message="__warningregistry__", - module=r"numpy(\.\w+)*", + message=r".*numpy\.(\w+\.)*__warningregistry__", ) # We only use pandas transitively through seaborn, so it's their responsibility to mark if From 3418a59db69277871036cdba799b68605b0f0d61 Mon Sep 17 00:00:00 2001 From: Jake Lishman Date: Fri, 28 Jun 2024 10:50:18 +0100 Subject: [PATCH 3/4] Pin Rustworkx to avoid buggy graphviz drawing --- constraints.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/constraints.txt b/constraints.txt index 6681de226d93..8c561f52f0f6 100644 --- a/constraints.txt +++ b/constraints.txt @@ -7,6 +7,10 @@ scipy<1.11; python_version<'3.12' # See https://github.com/Qiskit/qiskit/issues/12655 for current details. scipy==1.13.1; python_version=='3.12' +# Rustworkx 0.15.0 contains a bug that breaks graphviz-related tests. +# See https://github.com/Qiskit/rustworkx/pull/1229 for the fix. +rustworkx==0.14.2 + # z3-solver from 4.12.3 onwards upped the minimum macOS API version for its # wheels to 11.7. The Azure VM images contain pre-built CPythons, of which at # least CPython 3.8 was compiled for an older macOS, so does not match a From 71df67f103570383e7d95f3e703269da4d84ca00 Mon Sep 17 00:00:00 2001 From: Jake Lishman Date: Fri, 28 Jun 2024 13:30:13 +0100 Subject: [PATCH 4/4] Update test/utils/base.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com> --- test/utils/base.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/utils/base.py b/test/utils/base.py index b9b5426b337a..ce9509709bad 100644 --- a/test/utils/base.py +++ b/test/utils/base.py @@ -211,6 +211,7 @@ def setUpClass(cls): # macOS ARM, we see some (we think harmless) warnings come out of `numpy.linalg._linalg` (a # now-private module) during transpilation, which means that subsequent `assertWarns` calls # can spuriously trick Numpy into sending out a nonsense `DeprecationWarning`. + # Tracking issue: https://github.com/Qiskit/qiskit/issues/12679 warnings.filterwarnings( "ignore", category=DeprecationWarning,