-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Deprecated is_decade and is_close_to_int #22268
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
b095bf8
to
9f781ee
Compare
e31f60c
to
4847ec3
Compare
Too tired, so shouldn't have commented. I think I have now sorted out the issues though. |
528954f
to
ba0d30d
Compare
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 left one picky comment, but otherwise this looks good!
e4d2aae
to
42476a1
Compare
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 would not replace the internal usages of is_close_to_int
.
is_close_to_int(2 * x)
is more readable than np.isclose(2 * x, round(2 * x))
.
Agree with Tim, there are many ways to express "close to" so it is useful to wrap one way. |
Alright. Should I still deprecate the original |
42476a1
to
a3359f6
Compare
This is now updated. |
bf9b318
to
7d37c29
Compare
PR Summary
Deprecating two functions that should be internal. Original issue (as discussed on gitter):
Digging into ticker.py and found the following concern: is_close_to_int uses a keyword argument atol (absolute tolerance?) comparing using absolute tolerance. However, it is also called from isdecade where the keyword argument rtol (relative tolerance?) is passed as absolut tolerance.
If I would change this, I guess the safest way is to provide an additional keyword argument to is_close_to_int, rtol=None, check if that is set and if so use that instead? For isdecade it is not so obvious as making it consistent will break the behavior.
(I originally just wanted to use isdecade in a few places...)
Outcome:
is_decade
and introducing_is_decade
that usertol
as relative tolerance, not as absolute tolerance.is_close_to_int
which is not replaced (rely onmath.isclose
andnp.isclose
).The behavior is slightly changed, although it is hard to say that if it will actually be an issue. The tolerances seems quite arbitrarily set and considering that these are mainly used for exponents of bases, so typically rather small integers. But there may indeed be cases which will behave differently now.
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).