On Sun, Jul 5, 2020 at 9:38 PM Steven D'Aprano <st...@pearwood.info> wrote:
> > >I agree with you that `clamp(lower=x, value=NAN, upper= x)` should > > >return x. > > Sorry Greg, on this point at least the IEEE-754 standard is firm: if a > function will return the same result for every non-NAN argument, then it > must return the same result for NAN arguments too. > > clamp(value, x, x) > > will always return x for every finite and infinite value, so it must > return x for NANs too. > I strongly agree with Steven here. Also about order-dependence in results of min() and max() being disturbing and contrary to IEEE-754. ... so, umm... Steven... statistics.median()?! Btw, definitely +1 on math.clamp(value, *, lower=None, upper=None) . -1 on built-in. -0 on any other function signature. Actually, I'm fine with math.clip() as well, but clamp seems more popular.
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/7X64MLI6G4Q5ZSIZNBRCU3HAYWWWYOI3/ Code of Conduct: http://python.org/psf/codeofconduct/