FWIW, numpy calls it "clip":
numpy.clip(a, a_min, a_max, out=None, **kwargs)
Clip (limit) the values in an array.
Given an interval, values outside the interval are clipped to the
interval edges.
For example, if an interval of [0, 1] is specified, values smaller than
0 become 0, and
values larger than 1 become 1.
Equivalent to but faster than np.minimum(a_max, np.maximum(a, a_min)).
No check is performed to ensure a_min < a_max.-CHB
On Fri, Jul 3, 2020 at 5:37 PM Christopher Barker <[email protected]>
wrote:
> On Fri, Jul 3, 2020 at 5:25 PM <[email protected]> wrote:
>
>> > I'd go for val[min:max] tbh.
>>
>
> another reason this is Not Good: in slicing syntax, a:b means >=a and < b
> -- this asymmetry is not what we would want here.
>
> -CHB
>
>
> --
> Christopher Barker, PhD
>
> Python Language Consulting
> - Teaching
> - Scientific Software Development
> - Desktop GUI and Web Development
> - wxPython, numpy, scipy, Cython
>
--
Christopher Barker, PhD
Python Language Consulting
- Teaching
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/2MSEO3H5UK4GTNNANZWXE5JKNXEUTCOQ/
Code of Conduct: http://python.org/psf/codeofconduct/