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

Conversation

jakelishman
Copy link
Member

@jakelishman jakelishman commented Jun 28, 2024

Summary

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.

Details and comments

@jakelishman jakelishman added type: qa Issues and PRs that relate to testing and code quality stable backport potential The bug might be minimal and/or import enough to be port to stable Changelog: None Do not include in changelog labels Jun 28, 2024
@jakelishman jakelishman requested a review from a team as a code owner June 28, 2024 00:44
@qiskit-bot
Copy link
Collaborator

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

`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.
@coveralls
Copy link

coveralls commented Jun 28, 2024

Pull Request Test Coverage Report for Build 9705924154

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 11 unchanged lines in 2 files lost coverage.
  • Overall coverage increased (+0.01%) to 89.75%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 5 92.62%
crates/qasm2/src/parse.rs 6 97.15%
Totals Coverage Status
Change from base Build 9703107599: 0.01%
Covered Lines: 63805
Relevant Lines: 71092

💛 - Coveralls

@@ -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.

Eric-Arellano
Eric-Arellano previously approved these changes Jun 28, 2024
Copy link
Collaborator

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

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

Consider creating tracking issues so that we don't forget to follow up on these things

ElePT
ElePT previously approved these changes Jun 28, 2024
Copy link
Contributor

@ElePT ElePT left a comment

Choose a reason for hiding this comment

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

I created a tracking issue and added it to the comment! Let me know if it works.

test/utils/base.py Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Jun 28, 2024

Pull Request Test Coverage Report for Build 9710892224

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 4 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.03%) to 89.774%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 4 93.89%
Totals Coverage Status
Change from base Build 9703107599: 0.03%
Covered Lines: 63822
Relevant Lines: 71092

💛 - Coveralls

@jakelishman jakelishman dismissed stale reviews from ElePT and Eric-Arellano via 71df67f June 28, 2024 12:30
Co-authored-by: Elena Peña Tapia <[email protected]>
@coveralls
Copy link

coveralls commented Jun 28, 2024

Pull Request Test Coverage Report for Build 9712800437

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.03%) to 89.77%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/lex.rs 3 93.13%
Totals Coverage Status
Change from base Build 9703107599: 0.03%
Covered Lines: 63819
Relevant Lines: 71092

💛 - Coveralls

@jakelishman jakelishman added this pull request to the merge queue Jun 28, 2024
Merged via the queue into Qiskit:main with commit 3adcd5d Jun 28, 2024
15 checks passed
mergify bot pushed a commit that referenced this pull request Jun 28, 2024
* 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.

* Refine filter

* Pin Rustworkx to avoid buggy graphviz drawing

* Update test/utils/base.py

Co-authored-by: Elena Peña Tapia <[email protected]>

---------

Co-authored-by: Elena Peña Tapia <[email protected]>
(cherry picked from commit 3adcd5d)
@jakelishman jakelishman deleted the numpy-warnings branch June 28, 2024 14:43
github-merge-queue bot pushed a commit that referenced this pull request Jun 28, 2024
…12687)

* 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.

* Refine filter

* Pin Rustworkx to avoid buggy graphviz drawing

* Update test/utils/base.py

Co-authored-by: Elena Peña Tapia <[email protected]>

---------

Co-authored-by: Elena Peña Tapia <[email protected]>
(cherry picked from commit 3adcd5d)

Co-authored-by: Jake Lishman <[email protected]>
Procatv pushed a commit to Procatv/qiskit-terra-catherines that referenced this pull request Aug 1, 2024
…2676)

* 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.

* Refine filter

* Pin Rustworkx to avoid buggy graphviz drawing

* Update test/utils/base.py

Co-authored-by: Elena Peña Tapia <[email protected]>

---------

Co-authored-by: Elena Peña Tapia <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog stable backport potential The bug might be minimal and/or import enough to be port to stable type: qa Issues and PRs that relate to testing and code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants