Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress nonsense DeprecationWarning caused by unittest #12676

Merged
merged 4 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Contributor

@Cryoris Cryoris Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this then unrelated to the NumPy deprecation warning? Edit: Nvm just saw the offline discussion 🙂

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's just that Rustworkx 0.14 wasn't compatible with Numpy 2 and Rustworkx 0.15 is, so the release caused us to start pulling in Numpy 2 in CI. We didn't see the failures before because not only do you need Numpy 2, you also need to have the test suite generate a warning out of np.linalg._linalg, which we don't do on most platforms, but there are some about numerical-precision things on macOS ARM specifically, and we weren't running the Numpy 2 tests on macOS ARM previously because it wasn't available to us at the time.

# 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
Expand Down
14 changes: 14 additions & 0 deletions test/utils/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
jakelishman marked this conversation as resolved.
Show resolved Hide resolved
# Tracking issue: https://github.com/Qiskit/qiskit/issues/12679
warnings.filterwarnings(
"ignore",
category=DeprecationWarning,
message=r".*numpy\.(\w+\.)*__warningregistry__",
)

# 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(
Expand Down
Loading