-
-
Notifications
You must be signed in to change notification settings - Fork 628
Fix ginac's ratlog method so log(int(0),2) does not hang #39135
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
Documentation preview for this PR (built with commit f9a3b43; changes) is ready! 🎉 |
Technically this makes the comment of the method incorrect (?) it says
an infinity is not a MPZ/MPQ. But then there's also a |
Good point. I think it makes sense to just add "(or an infinity)" at the end. How does that sound? |
Sounds good. |
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.
Looks good to me.
sagemathgh-39135: Fix ginac's ratlog method so log(int(0),2) does not hang Fixes sagemath#37794. It is explained in sagemath#37794 that calculating the logarithm of `int(0)` (zero represented as a python integer) can enter an infinite loop, due to a bug in ginac's `numeric::ratlog` method. This PR adds an `if` statement to return negative infinity for this value. (At this point in the code, the base of the logarithm is known to be a positive integer that is greater than 1, so the log of 0 is negative infinity, not positive infinity.) The PR also adds `log(int(0), 2)` as a doctest and, for good measure, also `log(int(0), 1/2)`. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39135 Reported by: DaveWitteMorris Reviewer(s): Lorenz Panny
Fixes #37794.
It is explained in #37794 that calculating the logarithm of
int(0)
(zero represented as a python integer) can enter an infinite loop, due to a bug in ginac'snumeric::ratlog
method. This PR adds anif
statement to return negative infinity for this value. (At this point in the code, the base of the logarithm is known to be a positive integer that is greater than 1, so the log of 0 is negative infinity, not positive infinity.)The PR also adds
log(int(0), 2)
as a doctest and, for good measure, alsolog(int(0), 1/2)
.📝 Checklist
⌛ Dependencies