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

DOC: Clean up errstate handling in our tests #23813

Merged
merged 2 commits into from
May 26, 2023
Merged

Conversation

seberg
Copy link
Member

@seberg seberg commented May 25, 2023

It is plausible that this doesn't fix everything, but it fixes at least most.


This is split out from gh-23812 and fixes the doctests (and also some actual doc errors). Unfortunately, without gh-23812, I don't think this is even tested....

It is plausible that this doesn't fix everything, but it fixes
at least most.
numpy/core/_ufunc_config.py Outdated Show resolved Hide resolved
>>> np.int16(32000) * np.int16(3)
30464
>>> np.seterr(over='raise')
{'divide': 'ignore', 'over': 'ignore', 'under': 'ignore', 'invalid': 'ignore'}
Copy link
Contributor

Choose a reason for hiding this comment

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

It's weird that this doesn't change the value in the returned dict, but indeed that is the behavior (the change is only reflected after calling geterr.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is a normal pattern for getters: you get back the old value so that you can reset it.

Honestly, we should maybe just remove this API in a follow-up and force users to use the errstate as only real api...

Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
@rossbar rossbar merged commit 2e9479e into numpy:main May 26, 2023
51 of 57 checks passed
@seberg seberg deleted the test-fp-err-fix branch May 26, 2023 08:00
@@ -155,14 +154,18 @@ def geterr():
--------
>>> np.geterr()
{'divide': 'warn', 'over': 'warn', 'under': 'ignore', 'invalid': 'warn'}
>>> np.arange(3.) / np.arange(3.)
>>> np.arange(3.) / np.arange(3.) # doctest: +SHOW_WARNINGS
Copy link
Member

Choose a reason for hiding this comment

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

SHOW_WARNINGS seems to be invalid and breaks the refguide checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants