cupy.clip#

cupy.clip(a, a_min, a_max, out=None)[source]#

Clips the values of an array to a given interval.

This is equivalent to maximum(minimum(a, a_max), a_min), while this function is more efficient.

Parameters:
  • a (cupy.ndarray) – The source array.

  • a_min (scalar, cupy.ndarray or None) – The left side of the interval. When it is None, it is ignored.

  • a_max (scalar, cupy.ndarray or None) – The right side of the interval. When it is None, it is ignored.

  • out (cupy.ndarray) – Output array.

Returns:

Clipped array.

Return type:

cupy.ndarray

See also

numpy.clip()

Notes

When a_min is greater than a_max, clip returns an array in which all values are equal to a_max.