[issue41408] Add a `clamp` function to the `math` module

2020-07-28 Thread Mark Dickinson
Change by Mark Dickinson : -- resolution: rejected -> duplicate superseder: -> Add clamp() function to builtins ___ Python tracker ___

[issue41408] Add a `clamp` function to the `math` module

2020-07-27 Thread Avinash Maddikonda
Avinash Maddikonda added the comment: Okay, I'm rejecting this issue. But please let me know/contribute if anyone is going to add a clamp function as a built-in method or a math module function. -- ___ Python tracker

[issue41408] Add a `clamp` function to the `math` module

2020-07-27 Thread Avinash Maddikonda
Change by Avinash Maddikonda : -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Pyt

[issue41408] Add a `clamp` function to the `math` module

2020-07-27 Thread Avinash Maddikonda
Avinash Maddikonda added the comment: So should I delete/reject this now? Because I think it would be more useful than functions like copysign (I mean copysign can be written easily without confusion, but clamp is confusing sometimes as the max function takes minimum and the min of value and

[issue41408] Add a `clamp` function to the `math` module

2020-07-27 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: I will leave it to math module experts to keep it open or close it. There wasn't strong consensus on adding it math module either without a discussion in python-ideas https://bugs.python.org/msg358789. -- nosy: +mark.dickinson, rhettinger,

[issue41408] Add a `clamp` function to the `math` module

2020-07-27 Thread Avinash Maddikonda
Avinash Maddikonda added the comment: Oh, I didn't know that. But I was thinking of adding it to the math module and not as a built-in method. I mean, it is definitely more useful than copysign, right? -- ___ Python tracker

[issue41408] Add a `clamp` function to the `math` module

2020-07-27 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan added the comment: This seems to be a duplicate of https://bugs.python.org/issue36788 -- nosy: +xtreak ___ Python tracker ___

[issue41408] Add a `clamp` function to the `math` module

2020-07-27 Thread Avinash Maddikonda
New submission from Avinash Maddikonda : Add a `clamp` function to the `math` module which does something like this: ```py def clamp(value=0.5, minimum=0, maximum=1): """Clamps the *value* between the *minimum* and *maximum* and returns it.. """ return max(minimum, min(value, max