-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[sdlib] Add clamp
to math module
#3039
base: nightly
Are you sure you want to change the base?
Conversation
e72c5f3
to
d9b7195
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'm not in favor or against, just adding info here. In the Python stdlib, it's been discussed to add such a function in this mailing list the TLDR of the mailing list is that there are many different implementations of clamp
in the wild and they slightly differ on the way NaN
are handled. In the end it was not added to the stdlib due to the lack of concensus, mostly about NaN.
Maybe we should add information about how this new function handles NaN
in the docstring? Adding a test with NaN
would be good too as we should not change the way we handle them as time goes by.
We should also document how the In other words, we can take the syntactic trait idea from #2924, and make |
Since a
Out of curiosity I checked the |
Signed-off-by: Brian Grenier <[email protected]>
Thanks for the patch! Is there a direct motivation for this change? As pointed out, Python's |
@laszlokindrat I noticed we had a private function for this in |
clamp
to the math module_clip
function inList
withclamp