jax-ml/jax · error · TypeError
args argument to jax.scipy.optimize.minimize must be a…
Error message
args argument to jax.scipy.optimize.minimize must be a tuple, got {} What it means
Validation in jax.scipy.optimize.minimize: the extra arguments forwarded to the objective function must be passed as a tuple (they are bound positionally by the solvers). Passing args as a list or any other non-tuple type fails this check.
Solutions
- Wrap in a tuple: args=(X, y)
- If args may be a single value, still use a 1-tuple: args=(value,)
- Validate type before calling
Example fix
# before res = minimize(loss, x0, args=[X, y]) # after res = minimize(loss, x0, args=(X, y))
Defensive patterns
Strategy: type-guard
Validate before calling
args = tuple(args)
Type guard
def is_tuple_args(a) -> bool: return isinstance(a, tuple)
Prevention
- Always write args=(...) literal; lint for list args
When it happens
Trigger: Passing args=[X, y] (a list) or args=None-adjacent values; converting a config-loaded array to args.
Common situations: Copy-pasting scipy.optimize.minimize calls where lists are accepted; JSON/YAML configs producing lists.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- Method not recognized
- Argument ' ' of type ' ' is not a valid JAX type
- `bw_method` should be 'scott', 'silverman', a scalar, or a…
- `compute_on`'s compute_type argument must be a string.
- Expected kind to be on of
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/fb9a7f1764c35307.
Report an issue: GitHub.
Appendix: source
Thrown at jax/_src/scipy/optimize/minimize.py:103
args: extra arguments passed to the objective function.
method: solver type. Currently only ``"BFGS"`` is supported.
tol: tolerance for termination. For detailed control, use solver-specific
options.
options: a dictionary of solver options. All methods accept the following
generic options:
- maxiter (int): Maximum number of iterations to perform. Depending on the
method each iteration may use several function evaluations.
Returns:
An :class:`OptimizeResults` object.
"""
if options is None:
options = {}
if not isinstance(args, tuple):
msg = "args argument to jax.scipy.optimize.minimize must be a tuple, got {}"
raise TypeError(msg.format(args))
fun_with_args = lambda x: fun(x, *args)
if method.lower() == 'bfgs':
results = minimize_bfgs(fun_with_args, x0, **options)
success = results.converged & jnp.logical_not(results.failed)
return OptimizeResults(x=results.x_k,
success=success,
status=results.status,
fun=results.f_k,
jac=results.g_k,
hess_inv=results.H_k,
nfev=results.nfev,
njev=results.ngev,
nit=results.k)
if method.lower() == 'l-bfgs-experimental-do-not-rely-on-this':
results = _minimize_lbfgs(fun_with_args, x0, **options)View on GitHub (pinned to 1e1c6a8fc0)