# mlx.core.clip — MLX 0.0.7 documentation

Skip to main content
`Ctrl`+`K`

# mlx.core.clip

mlx.core.clip(a: array, /, a_min: Union[scalar, array , None ], a_max: Union[scalar, array , None ], *, stream: Union[ None , Stream , Device ] = None) → array

  Clip the values of the array between the given minimum and maximum.

  If either `a_min` or `a_max` are `None`, then corresponding edge is ignored. At least one of `a_min` and `a_max` cannot be `None`. The input `a` and the limits must broadcast with one another.

  Parameters:

    - a (array) – Input array.

    - a_min (scalar or array or None) – Minimum value to clip to.

    - a_max (scalar or array or None) – Maximum value to clip to.

  Returns:

    The clipped array.

  Return type:

    array