Skip to content

Commit ef606e7

Browse files
committed
Ensure "c::transport+base" items are str
Avoid TypeError in broadcast_wildcard() with mixed str and sdmx.model.common.Code.
1 parent 5920ccd commit ef606e7

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

message_ix_models/model/transport/build.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,12 @@ def add_structure(c: Computer) -> None:
398398
# - Multiple static and dynamic tasks generated in loops etc.
399399
tasks: list[tuple] = list(STRUCTURE_STATIC) + [
400400
("c::transport", quote(spec.add.set["commodity"])),
401-
("c::transport+base", quote(spec.add.set["commodity"] + info.set["commodity"])),
401+
# Convert to str to avoid TypeError in broadcast_wildcard → sorted()
402+
# TODO Remove once sdmx.model.common.Code is sortable with str
403+
(
404+
"c::transport+base",
405+
quote(list(map(str, spec.add.set["commodity"] + info.set["commodity"]))),
406+
),
402407
("cg", quote(spec.add.set["consumer_group"])),
403408
("indexers:cg", spec.add.set["consumer_group indexers"]),
404409
("nodes", quote(info.set["node"])),

message_ix_models/report/operator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def broadcast_wildcard(
5959
"""Broadcast over coordinates `coords` along respective dimension(s) `dim`.
6060
6161
`dim` may identify a single dimension or a sequence of dimensions; `coords` must
62-
be given for each dimension
62+
be given for each dimension.
6363
6464
For each respective items from `dim` and `coords`, any missing coordinates along the
6565
dimension are populated using the values of `qty` keyed with the 'wildcard' label

0 commit comments

Comments
 (0)