E-TE0613 — Mismatched argument types for is_same
Error Type |
|
|---|---|
Phase |
calling |
Python exception |
|
Message
`is_same` cannot compare a value of type `{src_type}` with a value of type `{dst_type}`.
Possible fix: pass two JijModeling objects of the same kind, or two iterables of them.
({src_type} and {dst_type} are the Python types of the first and second argument)
Cause
The two arguments to jm.is_same have different Python types, and they cannot be compared either as a pair of JijModeling objects of the same kind or as a pair of iterables.
Typical triggers are comparing two JijModeling objects of different kinds, such as a placeholder against a Problem; comparing a JijModeling object against a value is_same does not support, such as a placeholder against None; or wrapping only one side in a list, as in jm.is_same(problem, [problem]).
Fix
Pass two JijModeling objects of the same kind, or two iterables of them:
import jijmodeling as jm
problem1 = jm.Problem("p")
problem2 = jm.Problem("p")
a = problem1.Placeholder("a", dtype=float)
# Raises E-TE0613: a placeholder cannot be compared with a problem
# jm.is_same(a, problem1)
b = problem2.Placeholder("a", dtype=float)
assert jm.is_same(a, b)
When comparing collections, wrap both sides — compare [p1] with [p2], not p1 with [p2].
If one of the values can be None, guard the call, for example x is not None and jm.is_same(x, y).