On 6/07/20 3:55 am, Steven D'Aprano wrote:
With that interpretation, a NAN passed as the lower or upper bounds can
be seen as another way of saying "no lower bounds" (i.e. negative
infinity) or "no upper bounds" (i.e. positive infinity), not "some
unknown bounds".

Python already has a value for representing missing or unspecified
data, i.e. None. So we don't need to use NaN for that, and can
instead reserve it to mean "no correct answer".

I agree with you that `clamp(lower=x, value=NAN, upper= x)` should
return x.

I don't think I agree with that, because it relies on assuming that
the lower and upper bounds can meaningfully be compared for exact
equality, which may not be true depending on the circumstances.

Treat a NAN bounds as *missing data*, which effectively means "there is
no limit", i.e. as if you had passed the infinity of the appropriate
sign for the bounds.

If one of the bounds is missing, you don't need clamp(), you
can use min() or max().

--
Greg
_______________________________________________
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/WD4RO57XMIKUDYWAXCRPE3MSJ2RZEBRU/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to