E-TE0510 — Unsortable set elements
Error Type |
|
|---|---|
Phase |
validating instance data |
Python exception |
|
Message
The elements of a Python `set` or `frozenset` given for a `DataType.STREAM` cannot be sorted.
Possible fix: pass the elements as a list or tuple in the order you want.
Cause
The instance data for a DataType.STREAM[...] was given as a Python set or frozenset. A stream is iterated in the order of its data, but a Python set has no element order, so JijModeling sorts its elements to get a deterministic order. This error is raised when the elements cannot be compared with each other, for example frozensets given as the elements of a stream of streams, category labels that mix strings and integers, or tuples containing such values.
Fix
Pass the elements as a list or tuple instead. The elements are then used in the order given, including any repeated elements:
import jijmodeling as jm
problem = jm.Problem("example")
N = problem.Natural("N")
a = problem.Placeholder("a", dtype=jm.DataType.STREAM[jm.DataType.STREAM[N]], ndim=1)
data = {"N": 3, "a": [[[0, 1], [2]]]} # lists, not a Python set of frozensets