clip#

bamengine.ops.clip(a, min_val, max_val, out=None)[source]#

Clip (limit) values to range [min_val, max_val].

Parameters:
  • a (array) – Array to clip.

  • min_val (float) – Minimum value.

  • max_val (float) – Maximum value.

  • out (array, optional) – Output array (in-place operation).

Returns:

Clipped array.

Return type:

array

Examples

>>> import bamengine.ops as ops
>>> # Keep prices in reasonable range
>>> prices = np.array([50, 100, 150, 200])
>>> reasonable_prices = ops.clip(prices, 80, 120)
>>> # reasonable_prices: [80, 100, 120, 120]