Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
4.82k stars 2.29k forks source link

DeprecationWarnings triggered by Numpy 2 and unittest interaction #12679

Open ElePT opened 3 days ago

ElePT commented 3 days ago

Environment

What is happening?

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.

How can we reproduce the issue?

CI

What should happen?

It works

Any suggestions?

Pin versions until fix is found

jakelishman commented 3 days ago

There's no need to pin Numpy (and #12676 doesn't do that) - the warning is entirely spurious and should be explicitly ignored. If, at some point in the future, numpy removes the numpy.linalg.linalg shim to numpy.linalg._linalg (possible) or Python's built-in unittest.TestCase.assertWarns changes how it works (unlikely), we can remove the warning skip, but that's about it.