E-TE0615 — Iterables of different lengths passed to is_same
Error Type |
|
|---|---|
Phase |
calling |
Python exception |
|
Message
The iterables passed to `is_same` have different lengths (the `{longer}` argument is longer).
Possible fix: pass iterables with the same number of elements.
({longer} is src when the first argument is the longer one and dst when the second one is)
Cause
Both arguments to jm.is_same were consumed as iterables and compared element by element; every paired element compared as the same, but then one iterable produced more elements than the other.
The comparison stops at the first surplus element, so the error reports only which side is longer, not by how much.
As with E-TE0614, the element-by-element comparison applies when the arguments cannot be read as single collection expressions, for example iterables of Problem or Constraint objects, or generators; two lists of plain expressions with different lengths are instead compared in one piece and return False.
Fix
Pass iterables with the same number of elements.
If a length difference is expected and should simply mean “not the same”, compare the lengths yourself before calling is_same:
import jijmodeling as jm
p = jm.Problem("example")
# Raises E-TE0615: the second iterable has one more element
# jm.is_same([p], [p, p])
lhs, rhs = [p], [p, p]
same = len(lhs) == len(rhs) and jm.is_same(lhs, rhs) # False, no error