jax-ml/jax · error · ValueError
No input was provided to the clip function.
Error message
No input was provided to the clip function.
What it means
jnp.clip's first positional argument is the array to clip; if it is None (e.g. only min/max were supplied via keywords), the call is invalid. This often happens when using newer min/max keyword names with positional-style calls.
Source
Thrown at jax/_src/numpy/lax_numpy.py:3417
result will not be clipped to any maximum value. If specified, it should be
broadcast-compatible with ``arr`` and ``min``.
Returns:
An array containing values from ``arr``, with values smaller than ``min`` set
to ``min``, and values larger than ``max`` set to ``max``.
Wherever ``min`` is larger than ``max``, the value of ``max`` is returned.
See also:
- :func:`jax.numpy.minimum`: Compute the element-wise minimum value of two arrays.
- :func:`jax.numpy.maximum`: Compute the element-wise maximum value of two arrays.
Examples:
>>> arr = jnp.array([0, 1, 2, 3, 4, 5, 6, 7])
>>> jnp.clip(arr, 2, 5)
Array([2, 2, 2, 3, 4, 5, 5, 5], dtype=int32)
"""
if arr is None:
raise ValueError("No input was provided to the clip function.")
util.check_arraylike("clip", arr)
if any(iscomplexobj(t) for t in (arr, min, max)):
raise ValueError(
"Clip received a complex value either through the input or the min/max "
"keywords. Complex values have no ordering and cannot be clipped. "
"Please convert to a real value or array by taking the real or "
"imaginary components via jax.numpy.real/imag respectively.")
if min is not None:
arr = ufuncs.maximum(min, arr)
if max is not None:
arr = ufuncs.minimum(max, arr)
return asarray(arr)
@export
@api.jit(static_argnames=('decimals',))
def round(a: ArrayLike, decimals: int = 0, out: None = None) -> Array:View on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Always pass the array: jnp.clip(arr, 0, 1)
- Check for None upstream if arr may be conditionally absent
- Use explicit keywords to avoid positional mix-ups: jnp.clip(a=arr, min=0, max=1)
Example fix
// before jnp.clip(None, min=0, max=1) // after jnp.clip(arr, min=0, max=1)
Defensive patterns
Strategy: validation
Validate before calling
assert arr is not None, 'clip requires an input array'
Prevention
- Use keyword args (a=, min=, max=) in clip calls
- Reject None early in wrapper functions
When it happens
Trigger: Calling jnp.clip(a=None, min=0) — e.g. jnp.clip(None, 0, 1), or code ported from APIs where the array was optional.
Common situations: Refactorings where the array variable is conditionally None; calling clip(min=..., max=...) and forgetting a=; defaults from a config dict yielding None.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Context manager for {state.__name__} config option requires
- Either both or neither of the x and y arguments should be pr
- Clip received a complex value either through the input or th
- Missing required keyword argument: 'in_sharding'
- Missing required keyword argument: 'in_layouts'
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/26cbd49bf1a69a63.
Report an issue: GitHub.