Skip to content

feat(language): a dimension may alias another's labels - #1020

Draft
FBumann wants to merge 8 commits into
feat/maps-onlyfrom
feat/dimension-alias
Draft

FBumann wants to merge 8 commits into
feat/maps-onlyfrom
feat/dimension-alias

Conversation

@FBumann

@FBumann FBumann commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Note

The following content was generated by AI.

What this changes

A dimension may be an alias of another: the same labels under a second name, so an entry is over one set twice. Closes #969 gap 1. The three sparse-set drafts, A (#1016), B (#1018) and C (#1017, whose role form it replaces), stack on it; they are closed as evidence for #1019.

# before: refused, an entry names region twice; or an invented label per pair
parameters:
  ire_flo: { dims: [region, region] }

# after
dimensions:
  region: {}
  from_region: { alias: region }   # labels, dtype, order of region
parameters:
  ire_flo: { dims: [from_region, region] }   # data: from_region | region | value
constraints:
  eq_ire:
    dims: [region]
    expression: imp == sum(ire_flo * at(exp, by=from_region[region]), over=from_region)
$$\mathit{imp}_{r} = \sum_{r' \in \mathcal{R}} \mathrm{ire\_flo}_{r',r} \cdot \mathit{exp}_{r'} \qquad \forall\, r \in \mathcal{R}$$

TIMES (examples/times/trade.yaml): the invented trade_link and the workaround callout of #1021 are gone.

# before (#1015)
dimensions: { trade_link: { description: "…, a label the data invents" } }
maps: { trade_link: { from_region: { dim: region }, … } }
relations: { top_ire: { dims: [trade_link, process], missing: absent } }
parameters: { ire_flo: { dims: [trade_link, process], where: top_ire } }
# after
dimensions: { from_region: { alias: region }, from_commodity: { alias: commodity } }
relations: { top_ire: { dims: [from_region, from_commodity, region, commodity, process], missing: absent } }
parameters: { ire_flo: { dims: [from_region, from_commodity, region, commodity, process], where: top_ire } }

Why

Method, gate output, choices, not done
  • DimensionSpec.alias, Dimension.alias on the program; the program repeats the target's dtype, one_of, ordered
  • the identity map <alias>[<target>] is implied in subject_tables; the data supplies no table for an alias
  • typeset: index of the target primed (r', a second alias r''), same set symbol; legend row "an alias of region"; the identity read prints as the primed index, not as a function; markdown, LaTeX, Typst
  • a sum over a dimension inside an entry over its alias printed w_{g',g'}; fixed in 29973cd, the dummy primes past every index another dimension prints with; failing test first, golden case exchanged added (84ba347)
  • refused at load, each with the rewrite: dtype:/one_of:/ordered: beside alias:; an undeclared target; itself; an alias of an alias; the implied map declared again (tests/test_alias.py)
  • golden model: from_bus, flow_angle, exchanged; notation.md regenerated
  • feat(language)!: maps give labels, relations give rows #1015 merged in (9bc9fe7, 96c1002): the TIMES trade example and its page rewritten with aliases, TOP_IRE with its process; its symbol table drops trade_link
  • choices: key alias:; reading through it stays an explicit at(…, by=from_region[region]); an alias never narrows the labels (a subset is its own dimension with a map, as TIMES' vintage against period)
  • not done: datarecord storing an alias (energy-models/datarecord)
  • gate at 96c1002: pixi run ci: lint, test (4244 passed, 1 skipped), docs-build pass; compile-tex fails here, its TeX bundle cannot be downloaded in this sandbox
  • draft

🤖 Generated with Claude Code

https://claude.ai/code/session_018B3nA1xxh6NMJN6mrYY34Q

`from_region: { alias: region }` has the labels, dtype and order of
`region` under a second name, so an entry can be over one set twice, as
TIMES' IRE_FLO is over two regions. The alias has the map
`from_region[region]` from each label to itself, and prints as the
primed index of `region` over the same set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018B3nA1xxh6NMJN6mrYY34Q
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018B3nA1xxh6NMJN6mrYY34Q
@read-the-docs-community

read-the-docs-community Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

A reduction over a dimension primed its dummy once per enclosing use,
so inside an entry over an alias of that dimension it took the alias's
own index and printed `w_{g',g'}`. The dummy now primes past every index
another dimension prints with.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018B3nA1xxh6NMJN6mrYY34Q
`exchanged` sums over `bus` inside a sum over its alias `from_bus`, so
the golden model reaches the line that primes a dummy past the alias.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018B3nA1xxh6NMJN6mrYY34Q
The TIMES trade example states IRE_FLO with an alias for the region and
the commodity, over the links that top_ire lists: no invented trade_link
label, no workaround callout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018B3nA1xxh6NMJN6mrYY34Q
…ion-alias

# Conflicts:
#	docs/examples/times/trade.md
#	examples/symbols/trade.yaml
#	examples/times/trade.yaml

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants