-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
BUG: Removed RuntimeWarning
when dividing Polynomial([inf]) by a float, Regarding Issue #21358
#21980
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
base: main
Are you sure you want to change the base?
BUG: Removed RuntimeWarning
when dividing Polynomial([inf]) by a float, Regarding Issue #21358
#21980
Conversation
RuntimeWarning
when Polynomial([inf]) divided by a floatRuntimeWarning
when dividing Polynomial([inf]) by a float, Regarding Issue #21343
RuntimeWarning
when dividing Polynomial([inf]) by a float, Regarding Issue #21343RuntimeWarning
when dividing Polynomial([inf]) by a float, Regarding Issue #21358
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.
I don't think we'd want to introduce numpy.testing
in non-testing code. In fact I don't think warnings filtering is the right way to go here, as I don't think it's thread-safe.
Instead, maybe there's a way to reorganize the operation to avoid the differing scalar/array behavior.
You may want to open an issue to remove the usage in
that's true |
This PR still has left over prints and imports as well. |
I opened gh-21991 |
…l/tests/test_classes.py
Removed redundant code & lines from As @rossbar doesn't recommend the current fix, can you suggest an alternative to using |
Perhaps taking a closer look at |
The best solution is to not ignore any warning, since the warning could probably be correct in certain cases (or argue that "invalid value" cannot be). The correct way to hide floating point warnings/errors would be using |
…1-random-uniform-datetime-ShehanAT
I've replaced
Let me know what you think. |
@ShehanAT errstate is better than warning filtering, but as also Ross said, this still silences warnings broadly (which can mean silencing correct warnings). Yes, I mentioned It would be good to look into avoiding the warning, otherwise it is never an ideal solution and requires a trade-off. |
The two are computed together so that they are compatible. Computing them separately led to problems, i.e., floor_divide + remainder didn't give the original number.. |
Description
This fix removes the
RuntimeWarning
that appears as a result of dividingPolynomial([inf])
by a float. For example:Produces the following warning:
The fix consists of importing the
warnings
library and usingfilterwarnings('ignore')
to suppress theRuntimeWarning
, like so:Fixes #21358
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
I've ran the all the test files in the
numpy/polynomial/tests
folder with all of them passing.Checklist: