-
-
Notifications
You must be signed in to change notification settings - Fork 11.8k
DEP: Deprecate NumPy warning control utilities #29550
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
Conversation
| with pytest.warns(DeprecationWarning): | ||
| ctypes_obj.get_strides() # type: ignore[deprecated] # pyright: ignore[reportDeprecated] | ||
| with np.testing.assert_warns(DeprecationWarning): | ||
| with pytest.warns(DeprecationWarning): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's also with pytest.deprecated_call(), probably doesn't matter
seberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks. Yeah, I hope both isn't used too much, with pytest being long there.
I remember seeing suppress_warnings() in the wild in places where I didn't want to see it, but I suspect that is largely fixed (and I never wanted to see it there ;)).
But no backporting. This clearly isn't a bug fix, adding deprecation warnings and thus breaking someones CI in a bug fix release isn't acceptable (at least not without a clear argument that this is such a big deal that breaking peoples CI when they don't expect it is clearly worth it.).
543bc5e to
55ff472
Compare
seberg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah, good Chuck noticed it said 2.5. Would be nice to also include the version in the message.
And thanks for fixing the stacklevel, that new file skipping feature is neat, but since it works stacklevel seems nicer!
Otherwise, please just go ahead and self-merge.
Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
|
Test failures are transient network issues. Merging because the last commit just changed some error messages and is syntactically correct. |
* DEP: Deprecate NumPy warning control utilities * TST: fix mypy tests * DEP: un-deprecate assert_no_warnings, which is thread-safe * DEP: un-deprecate clear_and_catch_warnings * TYP: update type stubs * STY: appease ruff * TST: update doctest deprecation filters * TST: fix warning test * DOC: add release note * Update numpy/tests/test_warnings.py * MNT: use stacklevel instead * TST: use pytest.deprecated_call() * MNT: fix deprecated version * Apply suggestions from code review Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net> --------- Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
* DEP: Deprecate NumPy warning control utilities * TST: fix mypy tests * DEP: un-deprecate assert_no_warnings, which is thread-safe * DEP: un-deprecate clear_and_catch_warnings * TYP: update type stubs * STY: appease ruff * TST: update doctest deprecation filters * TST: fix warning test * DOC: add release note * Update numpy/tests/test_warnings.py * MNT: use stacklevel instead * TST: use pytest.deprecated_call() * MNT: fix deprecated version * Apply suggestions from code review Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net> --------- Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
fixes #29293
Deprecates the following public API:
np.testing.assert_warnsnp.testing.suppress_warningsThese solve problems that no longer exist in modern Python versions. As of Python 3.14, where warnings can be made thread-safe, they're actively harmful because the implementation is not thread-safe. We should deprecate these helpers and point people at the standard library or pytest.
assert_warnsandsuppress_warningsused to be used heavily in NumPy and SciPy, but #29322 cleaned up NumPy and scipy/scipy#23275 cleaned up SciPy. I don't think there are any substantial uses in active open source codebases besides NumPy and SciPy, judging by Github code searches.I marked this for 2.5 but maybe we should backport it to the 2.4 branch?
I had to adjust some of the tests for
suppress_warningsslightly, because now a new warning is getting generated.I also used the
skip_file_prefixeskeyword forwarnings.warn, which is only available on 3.12 and newer. Do I need to care about 3.11 support to make the warning context nice? There's no singlestacklevelI can set.An earlier version of this PR also deprecated
clear_and_suppress_warningsandassert_no_warnings, but I ran into some issues getting the tests working again with the deprecation and I don't actually need to deprecate them, so I punted.