Skip to content

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

Draft
FabianHofmann wants to merge 12 commits into
mainfrom
feat/alias-on-main
Draft

FabianHofmann wants to merge 12 commits into
mainfrom
feat/alias-on-main

Conversation

@FabianHofmann

@FabianHofmann FabianHofmann commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Note

The following content was generated by AI.

A dimension may alias another's labels, so an entry can be over one set twice.

# before: a label the data invents per link, and a relation to its ends
dimensions:
  region: { dtype: str }
  trade_link: {}
relations:
  link_ends: { key: trade_link, values: { from_region: region, to_region: region } }
parameters:
  ire_flo: { dims: [trade_link] }

# after: the same labels under a second name
dimensions:
  region: { dtype: str }
  from_region: { alias: region }
parameters:
  ire_flo: { dims: [from_region, region] }
constraints:
  eq_ire:
    dims: [region]
    expression: imp == sum(ire_flo * at(exp, by=from_region[region]), over=from_region)

Prints imp_r = Σ_{r' ∈ R} ire_flo_{r',r} · exp_{r'}: the alias is the primed index over the same set.

Method, gate output, departures from #1020

Generated by Claude Code

`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 implies the relation
`from_region`, keyed by the alias with the value column `region`, read
`from_region[region]`, from each label to itself. It prints as the
primed index of `region` over the same set.

Ported onto main from #1020, where the identity read was a mapping of
#1015. A relation the file declares under the alias's name is refused
with the rewrite that deletes it.

(cherry picked from commit d924d66)
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.

(cherry picked from commit 29973cd)
`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.

(cherry picked from commit 84ba347)
IRE_FLO reads each region and commodity twice. With an alias for each,
the spec states it over the regions and commodities themselves, and the
workaround through an invented trade_link dimension goes.

Ported from #1020; top_ire is keyed by its five columns on main.
The relation an alias implies has a column over the alias and one over
the dimension it aliases, so it counted as a use of both, and an alias
no entry is over drew no never-an-axis advice. An implied relation now
reaches no dimension, and an alias in use reaches the dimension whose
labels it has.
Program.relations names the implied relation beside the declared ones,
and that a tool takes its rows from the labels of the alias.
`where: "from_g[g] == 'a'"` was refused as a column of a dimension,
since a side named after a dimension never reached the relation the
alias implies. A side that reads a column now reads the relation of
that name, as #1020 read its mapping.
@read-the-docs-community

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

Copy link
Copy Markdown

Under an entry over [from_g, g], sum(sum(w, over=g), over=from_g)
printed both dummies as g'': the inner dummy primed past every
dimension's index but not past the dummy of the sum around it. A
dummy now also skips each index an enclosing reduction or lookup
prints. The goldens do not change.
Along an alias of an unordered dimension, shift, sum_back, position,
a type 2 set and a piecewise curve said to declare the alias ordered,
and a label outside one_of said to add it to the alias's one_of. An
alias may carry neither, so both now name the dimension it aliases.
A relation declared under an alias's name is told to be deleted only
where it restates the implied relation; any other collides with the
dimension as usual.

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