On Sat, 4 Jul 2020 at 19:58, Christopher Barker
Hmm.
Since NaN is neither greater than nor less that anything, it seems the only correct answer to any Min,max,clamp involving a NaN is NaN.
Simplifying the signature, in Python we have: def min(*iterable): iterator = iter(iterable) minimum = next(iterable) for item in iterator: if item < minimum: minimum = item return minimum Due to this, min(0, float('nan')) == 0 and same for max. I would hence expect clamp to behave similarly. As a side note, the documentation actually underspecifies as in these kind of situations the iterable overall does not have a well-defined "minimum" (in a mathematical sense it simply does not have one): - how you look at the list (forward or backwards) - how you approach the comparison (item < minimum or not(minimum <= item)) change the behaviour: - max({0}, {0, 2}, {0, 1}, {1}) = {0, 2} v.s. {0, 1} when you reverse the iterable - min(0, float('nan')) = 0 v.s. float('nan') when you change the comparison Should this be clarified/specified in the docs?