neclib.core.math.clip_impl#

Aliases#

SupportsComparison

None

clip(value: T, minimum: T, maximum: T, /) T[source]#
clip(value: T, absmax: T, /) T

Limit the value to the range [minimum, maximum].

Parameters:
  • value – Arbitrary parameter.

  • minimum – Lower limit of value, if maximum is given. Otherwise, absolute value of this is used as the upper limit, and negative of that is the lower limit.

  • maximum – Upper limit of value.

Examples

>>> neclib.utils.clip(1.2, 0, 1)
1
>>> neclib.utils.clip(41, 0, 100)
41
>>> neclib.utils.clip(-4, 3)
-3