E-TE0614 — Incomparable elements in is_same iterables
Error Type |
|
|---|---|
Phase |
calling |
Python exception |
|
Message
The elements at position `{index}` (counting from 0) of the iterables passed to `is_same` cannot be compared (types `{src_type}` and `{dst_type}`).
Possible fix: make both iterables contain JijModeling objects of matching kinds at each position.
({index} is the zero-based position in the iteration order; {src_type} and {dst_type} are the Python types of the two elements at that position)
Cause
Both arguments to jm.is_same were consumed as iterables and compared element by element, and the pair of elements at the reported position is not a pair of JijModeling objects of the same kind.
All element pairs before the reported position compared as the same; a pair that merely differs makes is_same return False instead of raising.
For example, jm.is_same([problem], [placeholder]) fails at position 0, and so does any pair of iterables containing a value is_same does not support, such as None.
Note that lists, tuples, and dicts of plain expression-like values (numbers, strings, placeholders, decision variables, expressions) are compared in one piece and simply return False on any difference; the element-by-element comparison — and therefore this error — arises when the arguments cannot be read as single collection expressions, for example iterables containing Problem or Constraint objects, or generators.
Fix
Make both iterables contain JijModeling objects of matching kinds at each position, and order them consistently so that matching elements line up.
Filter out or replace unsupported values such as None before the call:
import jijmodeling as jm
problem = jm.Problem("example")
# Raises E-TE0614 at position 1: `None` cannot be compared by `is_same`
# jm.is_same([problem, None], [problem, None])
assert jm.is_same([problem], [problem])