clip

Contents

clip#

class brainunit.math.clip(a, a_min, a_max, **kwargs)#

Clip (limit) the values in an array.

Parameters:
  • a (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – Array containing elements to clip.

  • a_min (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – Minimum value. If None, clipping is not performed on the lower interval edge.

  • a_max (saiunit.Quantity | Array | ndarray | bool | number | bool | int | float | complex) – Maximum value. If None, clipping is not performed on the upper interval edge.

Returns:

out – Quantity if a is a Quantity, else an array.

Return type:

saiunit.Quantity | Array

Examples

>>> import saiunit as u
>>> a = [1, 2, 3, 4, 5] * u.meter
>>> u.math.clip(a, 2 * u.meter, 4 * u.meter)