Federico Salerno writes:

 > I feel clip fits best with the idea of a collection to... clip.

True, but you can (for this purpose) think of a scalar as a singleton.
Still, I think "clamp" is by far the best of the bunch (though I don't
see a need for this function in the stdlib, and definitely not a
builtin).

The problem with making this a builtin is that I don't think that
"clamp" is an unlikely identifier.  In particular, I guess clamping
the volume of a track in audio processing is a common operation.
"clip" is much worse, as it's used in all of audio, image, and video
processing, and I can imagine it as a place for keeping deleted or
copied objects.

math.clamp wouldn't be totally objectionable.

Which suggests the question: Is there a commonly used equivalent for
complex numbers?

 > As far as other options go, I agree with Mr D'Aprano's objection to
 > `minmax`,

Definitely out.

 > and I'd like to toss a possible `coerce`

Here my issue is that for me the *target* of a coercion should be a
"single thing", which could be a type, but might also be a scalar.  It
is true that type theorists consider x in Reals and y in [0,1] to be
different types, so "y = coerce(x) # to unit interval" could match
that concept, but somehow that doesn't work for me.  That may just be
me, the majority of native speakers may disagree.
_______________________________________________
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/7AWYMMZSTP7IE7PCO3MNZVWYRG6Y4NN6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to