E-TE0604 — Unexpected extra positional arguments to a reduction function

Error Type

Type Error

Phase

building expressions from Python

Python exception

TypeError (builtin)

Message

Unexpected extra positional arguments to `jijmodeling.{function}`.

Possible fix: call it in one of the following forms:
  - `{function}(expr)`
  - `{function}(expr, axis=...)`
  - `{function}(index_set, callable)`

({function} is sum or prod, depending on which function was called)

Cause

jm.sum or jm.prod was called with more than one positional argument, and the second one is not callable. The only supported call forms are a single expression, a single expression with an axis= keyword, or an index set followed by a callable building the body. Common triggers are passing the axis positionally, as in jm.sum(A, 0), or passing the body as a plain object such as a decision variable, as in jm.sum(N, x).

Fix

Pass the axis as a keyword, or wrap an index-dependent body in a callable:

jm.sum(A, axis=0)           # not jm.sum(A, 0)
jm.sum(N, lambda i: x[i])   # not jm.sum(N, x)