Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
565fa75
docs[next]: ADR 0028, dimensions as nominal types
egparedes Sep 18, 2026
823c0dd
feat[next]: add injective tag mangling for generated identifiers
egparedes Sep 18, 2026
7ea399a
wip[next]: dimension classes, resolve() and Staggered[D] in common
egparedes Sep 18, 2026
183488f
wip[next]: migrate the tree to dimension classes; unit tests green
egparedes Sep 21, 2026
05f14f1
docs[next]: drop the implementation plan from the PR
egparedes Sep 21, 2026
03cb2f2
wip[next]: offset-name mangling and DaCe/gtfn fixes; all unit tests g…
egparedes Sep 21, 2026
5e9e542
wip[next]: fingerprint staggered dims; IR text accepts tags; last gtf…
egparedes Sep 21, 2026
2c68d48
wip[next]: notebooks under nominal identity; docs, examples and typing
egparedes Sep 21, 2026
263af8f
wip[next]: migrate src doctests to dimension classes
egparedes Sep 21, 2026
3109d54
test[next]: migrate typing_tests to class-based dimensions
egparedes Sep 21, 2026
ce59507
style[next]: ruff format lines shortened by the tag migration
egparedes Sep 21, 2026
0e55c87
fix[next]: review fixes for dimension classes
egparedes Sep 23, 2026
996a34a
refactor[next]: ConstList replaces _CONST_DIM; AxisLiteral drops kind
egparedes Sep 22, 2026
83c362f
fix[next]: printing IR does not import modules
egparedes Sep 22, 2026
3371a94
test[next]: register doctest dimensions where their tags point
egparedes Sep 22, 2026
dc53f1a
fix[next]: review fixes for ConstList and AxisLiteral
egparedes Sep 23, 2026
c8a69f0
docs[next]: renumber the dimensions-as-nominal-types ADR to 0029
egparedes Oct 1, 2026
47b276b
feat[next]: Cartesian axis levels below DimensionIndex; bound Stagger…
egparedes Oct 1, 2026
ea75ee7
fix[next]: fingerprint a dimension's kind
egparedes Oct 1, 2026
a1cf830
docs[next]: mdformat the Cartesian axis table of ADR 0029
egparedes Oct 1, 2026
52ca205
feat[next]: DimensionRef, a value describing a dimension class
egparedes Oct 29, 2026
a6ac82b
refactor[next]: type specifications and the IR carry DimensionRef
egparedes Oct 29, 2026
3a2a0ea
feat[next]: compare dimensions by class identity at the Python edge
egparedes Oct 29, 2026
26b33dc
feat[next]: accept dimensions as keys of dimension-keyed configuration
egparedes Oct 29, 2026
72a0d46
fix[next]: roundtrip binds the calling program's own dimension classes
egparedes Oct 29, 2026
b80b629
docs[next]: ADR 0029 -- classes at the Python edge, DimensionRef below
egparedes Oct 29, 2026
3f2c073
feat[next]: reject two different DimensionRefs sharing a tag in a pro…
egparedes Oct 29, 2026
34776de
Merge branch 'main' into connectivities-as-types-2-dimension-classes
egparedes Oct 29, 2026
a525844
refactor[next]: move ConstList to iterator.builtins
egparedes Oct 29, 2026
0792135
refactor[next]: NamedRange.unit_range becomes value
egparedes Oct 29, 2026
4d1820b
refactor[next]: rename NamedRange to DimensionRange
egparedes Oct 29, 2026
b7b5e2f
feat[next]: points and ranges on a dimension
egparedes Oct 29, 2026
23ba65f
refactor[next]: move tag mangling and resolution to dimension_tags
egparedes Oct 29, 2026
ace9d20
fix[next]: diagnostics name dimensions by their display name
egparedes Oct 29, 2026
7138853
test[next]: fewer dimensions in the nd_array_field tests
egparedes Oct 29, 2026
c640e91
docs[next]: drop history from comments and docstrings
egparedes Oct 29, 2026
b7f0a88
docs[next]: ADR 0029 -- trim mangling, note axes vs. mesh locations
egparedes Oct 29, 2026
66c1147
test[next]: reuse the shared test dimensions
egparedes Oct 29, 2026
8bc744d
test[next]: drop imports left unused by the shared test dimensions
egparedes Oct 29, 2026
1255a62
fix[next]: review fixes for dimension selections and slices
egparedes Oct 29, 2026
be741dc
Merge branch 'main' into connectivities-as-types-2-dimension-classes
egparedes Dec 1, 2026
682836d
test[next]: compile tasks ship 'task.compilable' after the merge of main
egparedes Dec 1, 2026
5580a66
docs[next]: drop stale import-by-tag notes from doctests
egparedes Oct 29, 2026
d7afac6
refactor[next]: split parametrized tags through a public helper in co…
egparedes Oct 29, 2026
dc8285b
feat[next]: short dimension names in the printed iterator IR
egparedes Oct 29, 2026
52f5fc8
fix[next]: print no dimension header in str() of IR nodes
egparedes Oct 29, 2026
2fef0b2
fix[next]: parse dimension names with non-ASCII identifier characters
egparedes Oct 29, 2026
43509bc
test[next]: an offloaded task ships a Cartesian connectivity as it is
egparedes Dec 1, 2026
fb9dfce
fix[next]: skip 0-d array scalars in the dimension identity check of …
egparedes Dec 1, 2026
3103b7f
test[next]: a missing neighbor offset is reported by its local dimens…
egparedes Dec 1, 2026
6a99b90
fix[next]: dimensions declared in a script keep their identity in spa…
egparedes Dec 2, 2026
fdce96c
docs[next]: renumber the dimensions ADR to 0030
egparedes Dec 2, 2026
07eff40
docs[next]: correct the dimensions ADR against the code and define a …
egparedes Dec 2, 2026
2e1fc88
docs[next]: rewrap the edited ADR paragraphs
egparedes Dec 2, 2026
6f418f9
docs[next]: keep the ADR 0030 link of ADR 0024 on one line
egparedes Dec 2, 2026
85cbd19
docs[next]: tighten the Cartesian axis definition and apply the secon…
egparedes Dec 2, 2026
ef11aae
docs[next]: rewrap a docstring line
egparedes Dec 2, 2026
1631fa2
docs[next]: accept the dimensions ADR and shorten the Cartesian axis …
egparedes Dec 2, 2026
fa8703c
Merge branch 'main' into connectivities-as-types-2-dimension-classes
egparedes Dec 2, 2026
d0195e7
docs[next]: shorten the CartesianAxisIndex docstring
egparedes Dec 2, 2026
3692e04
fix[next]: address the Copilot review: dimension fingerprints, stagge…
egparedes Dec 2, 2026
c46eef1
Merge branch 'main' up to 7737c0c0e into connectivities-as-types-2-di…
egparedes Dec 3, 2026
ad2b9ac
Merge branch 'main' (common package split, #3072) into connectivities…
egparedes Dec 3, 2026
72eb4b2
refactor[next]: check dimension refs when loading a roundtrip artifac…
egparedes Dec 3, 2026
3340ada
docs[next]: do not mention the PR stack in a comment
egparedes Dec 3, 2026
ebc070c
refactor[next]: make the dimension tag key helper private and drop it…
egparedes Dec 3, 2026
3cbc08f
docs[next]: shorten the dimensions ADR and clarify comments, as reviewed
egparedes Dec 3, 2026
138b656
refactor[next]: remove the DimensionRange.unit_range alias
egparedes Dec 3, 2026
6f559da
test[next]: drop the removed unit_range alias from the typing tests
egparedes Dec 3, 2026
894cb02
docs[next]: shorten the docstrings and comments of the dimension modules
egparedes Dec 3, 2026
86628d5
refactor[next]: remove bind_dimension_classes
egparedes Dec 3, 2026
464049d
refactor[next]: spell infinity in Infinity.__str__
egparedes Dec 3, 2026
2fd7dc5
refactor[next]: always raise on a comparison of a dimension ref with …
egparedes Dec 3, 2026
8a7fabb
refactor[next]: replace DimensionCategory with DimensionRef.is_cartes…
egparedes Dec 3, 2026
c428b2d
refactor[next]: run roundtrip programs without importing dimension cl…
egparedes Dec 3, 2026
700c0da
docs[next]: update the dimensions ADR for roundtrip without imports
egparedes Dec 3, 2026
a1c7c63
refactor[next]: move the tag mangling into common.dimensions
egparedes Dec 3, 2026
f62e65b
fix[next]: reject a local Cartesian axis when it is declared
egparedes Dec 3, 2026
e7cdbea
docs[next]: shorten the dimensions ADR and drop implementation details
egparedes Dec 3, 2026
992e7c7
refactor[next]: clarify common.dimensions and move single-use helpers…
egparedes Dec 3, 2026
d93891d
refactor[next]: drop from_codegen_name and pass connectivity keys to …
egparedes Dec 3, 2026
d1a68b6
docs[next]: print domains in doctests instead of their full-tag repr
egparedes Dec 3, 2026
67a115b
Merge remote-tracking branch 'origin/main' into connectivities-as-typ…
egparedes Dec 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions docs/development/ADRs/next/0024-Compilation-Runners.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tags: []
- **Status**: valid
- **Authors**: Hannes Vogt (@havogt)
- **Created**: 2026-07-08
- **Updated**: 2026-10-27
- **Updated**: 2026-12-02

In the context of ahead-of-time compilation of many program variants
(`CompiledProgramsPool`), facing a thread pool that can neither hide the
Expand Down Expand Up @@ -94,10 +94,11 @@ otherwise raised when the affected program variant is first called.

### Graceful degradation

Backends that customize `Backend.compile` (which cannot be decomposed) or
whose executor is not picklable are compiled in the calling thread, with a
warning stating the reason. A non-conforming backend keeps working — it just
does not offload.
Backends that customize `Backend.compile` (which cannot be decomposed) or whose executor
is not picklable are compiled in the calling thread, with a warning stating the reason.
So is a task that references a class declared in an interactive `__main__`
([ADR 0030](0030-Dimensions_As_Nominal_Types.md)). A non-conforming backend keeps working — it
just does not offload.

## Alternatives considered

Expand Down
49 changes: 30 additions & 19 deletions docs/development/ADRs/next/0026-Staggered_Dimensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ tags: []
- **Status**: valid
- **Authors**: Till Ehrengruber (@tehrengruber)
- **Created**: 2026-07-08
- **Updated**: 2026-07-09
- **Updated**: 2026-12-02

> The *encoding* of this record is superseded by
> [ADR 0030](0030-Dimensions_As_Nominal_Types.md): a staggered dimension is the
> real, interned class `Staggered[D]`, not a name prefix. The semantics below --
> half-integer positions, the shift convention, and the gtfn treatment -- are
> unchanged.

A **staggered dimension** is a dimension sitting at the **half-integer**
positions of a base dimension. For example, in a cell-centered 2D Cartesian grid
Expand Down Expand Up @@ -58,22 +64,26 @@ index arithmetic is encoded in `common.connectivity_for_cartesian_shift`.

## Encoding

A staggered dimension is encoded as its base dimension's name with the internal
`_Staggered` prefix (`common._STAGGERED_PREFIX`), rather than as a new attribute
on `Dimension`. The helpers `is_staggered`, `flip_staggered` and
`as_non_staggered` operate purely on that prefix.

Dimensions are identified by their **name** and appear throughout the toolchain
in more than one form: as a `common.Dimension` instance, but also as an
`itir.AxisLiteral` (and as plain strings in generated backend code). Adding a
"staggered" flag to `Dimension` would have required threading it through every one
of these representations and every place that constructs, compares, or lowers a
dimension — a large, invasive change touching the frontend, the IR, and all
backends. Carrying the marker in the name instead means the frontend and IR pass
it through unchanged, without any of those formats having to learn about
staggering. The leading underscore marks the prefix as internal — user code goes
through the `is_staggered` / `flip_staggered` / `as_non_staggered` helpers
(exported from `gt4py.next`) rather than manipulating the name directly.
A staggered dimension was encoded as its base dimension's name with the internal
`_Staggered` prefix, rather than as a new attribute on `Dimension`. Since
[ADR 0030](0030-Dimensions_As_Nominal_Types.md) it is the class
`common.Staggered[D]`, whose identity is the class itself; the helpers
`is_staggered`, `flip_staggered` and `as_non_staggered` are unchanged in meaning
and now read the class's `base`. Only a declared
`CartesianAxisIndex` can be staggered, which makes a doubly staggered dimension
and a staggered mesh location type errors.

The rationale of the superseded encoding: dimensions were identified by their **name**
and appeared throughout the toolchain in more than one form: as a `common.Dimension`
instance, but also as an `itir.AxisLiteral` (and as plain strings in generated backend
code). Adding a "staggered" flag to `Dimension` would have required threading it through
every one of these representations and every place that constructs, compares, or lowers
a dimension — a large, invasive change touching the frontend, the IR, and all backends.
Carrying the marker in the name instead meant the frontend and IR passed it through
unchanged, without any of those formats having to learn about staggering. The leading
underscore marked the prefix as internal — user code went through the `is_staggered` /
`flip_staggered` / `as_non_staggered` helpers (exported from `gt4py.next`) rather than
manipulating the name directly.

## Dimension Constraints

Expand All @@ -87,8 +97,9 @@ by the `as_non_staggered` name.

In gtfn a staggered dimension is emitted as a C++ `using` alias of its base
dimension's tag (`_add_staggered_aliases` in `itir_to_gtfn_ir.py`): e.g.
`_StaggeredIDim_t` becomes an alias of `IDim_t`, and `visit_AxisLiteral`
correspondingly emits the base dimension name.
the staggered tag's mangled name becomes an alias of the base tag's mangled type
(`<mangled base tag>_t`). Axis literals keep the staggered name, which the alias makes the
same type.

The reason is that gtfn lowers a shift to an integer offset along a SID axis, and
a half-integer shift produces exactly such an offset (see
Expand Down
207 changes: 207 additions & 0 deletions docs/development/ADRs/next/0030-Dimensions_As_Nominal_Types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
---
tags: []
---

# Dimensions as Nominal Types

- **Status**: accepted
- **Authors**: Enrique González Paredes (@egparedes)
- **Created**: 2026-09-18
- **Updated**: 2026-12-03

A concrete dimension becomes a **class**, and an index along it an **instance** of
that class — the shape `enum.Enum` uses, where the class is the collection and
the instances are its members:

```python
class IDim(gtx.CartesianAxisIndex): ...


class KDim(gtx.CartesianAxisIndex, kind=gtx.DimensionKind.VERTICAL): ...


class Cell(gtx.DimensionIndex): ... # a mesh location: not a Cartesian axis


IDim # the dimension -- annotated `gtx.Dimension`
IDim(0) # an index into it -- annotated `IDim`
```

so `gtx.Field[gtx.Dims[IDim], gtx.float64]` is valid for any PEP 484 checker with
no GT4Py mypy plugin.

A dimension's **identity is the Python type** in user code, embedded execution and
program calls, and its `tag` — the string that crosses into the
IR and the generated code — is its **qualified Python name**, `f"{cls.__module__}:{cls.__qualname__}"` (a staggered dimension embeds its
base's full tag). Below the frontend a dimension is a `DimensionRef` value naming that
class (see *Two levels* below). Dimensions on a Cartesian axis, with index arithmetic
and a staggered partner, subclass `CartesianAxisIndex`; mesh locations subclass
`DimensionIndex` directly.

## Context

`Dimension` was a frozen dataclass whose instances are values, not types. Two
consequences drove this change.

**Dimensions were not usable as types.** `Field[[IDim], float64]` needed a
dedicated mypy plugin that substituted at most four distinct placeholders per run,
made `TypeVar`s over dimensions impossible, and served only mypy — no other checker.
See #2503.

**Names are load-bearing in too many places.** A neighbor connectivity is
currently spread over four independently authored strings that must agree by
string equality and are never checked against each other at declaration time: the
`FieldOffset` tag, the Python variable it is bound to, the local `Dimension`'s
name, and the `offset_provider` key. Whichever one reaches
`common.get_offset` depends on the execution path and the operation. Making a
dimension's identity its Python type is the prerequisite for collapsing those
names into one declaration (a follow-up ADR covers the connectivity half).

## Decision

### Identity is the Python type; the tag is the qualified name

Two dimension classes are the same dimension if and only if they are the same
class. The static view (checkers see nominal types) and the runtime view
(equality is `is`) agree by construction, and the tag, unique among importable
classes, is also a valid IR spelling.

The alternative — `(name, kind)` value equality plus an interning registry, so
that independently declared same-named dimensions stay interchangeable — was
considered and rejected. It decouples the Python type's identity from the IR's,
and needs a name-keyed registry. It also cannot give a dimension nested inside another
declaration a unique name without further convention, which the connectivity
work requires.

One concrete example: take two distinct classes, both named `I`. Under `(name, kind)`
equality they compare equal, so `typing` caches `Field[Dims[I]]` once and returns that
same object for the other class. A type checker sees two types where the runtime sees
one. Under type identity they are two types in both views.

### Two levels: classes in user code, `DimensionRef` values in the toolchain

Classes stay the identity in user code, in embedded execution and wherever a call
enters GT4Py. Type specifications, the IR and the backends instead carry a
`DimensionRef`: an immutable, interned value with the class's module, qualname,
`kind`, whether it is a Cartesian axis and, for a staggered dimension, its base. The
conversion happens once per class, where classes enter the toolchain (type translation
of annotations and arguments, offset providers, scan axes).

Below the frontend, two refs are equal if all their fields are: the same qualified
name, `kind`, Cartesian axis flag and staggered base is the same dimension. The IR is therefore
self-contained and a compile task ships no user classes, except, for now, the
connectivities of the offset provider, which still hold dimension classes.

Because a re-run notebook cell gives an *equal* ref for a *new* class, program calls
still compare by class, in the same `__debug__`-only argument check as the type
check: when a program, or a field operator called as one, receives a field,
named-collection element or connectivity built on a different class of the same
name as a dimension its annotations, scan axis or `FieldOffset`s declare, the call
is rejected, embedded or compiled.

### Consequences of the tag being a qualified name

1. **Nothing is imported from a tag.** The roundtrip backend, which runs the generated
program embedded, on classes, takes them from the fields and connectivities of each
call. It synthesizes a class from the ref only for a dimension that none of them
has: such a dimension exists only inside the program.

2. **Dimensions must be importable to be pickled**, i.e. declared at module level.
`__init_subclass__` rejects a `<locals>` qualname as an early heuristic; it is
neither necessary nor sufficient (`type("Dyn", ...)` inside a function passes,
a class deleted after creation passes), so the authoritative check remains
pickle's own `save_global`.

A spawn worker cannot re-import an **interactive `__main__`** (a notebook, the
REPL, `python -c`), so a compile job that holds a class declared there is compiled
in the calling thread, with a warning. Scripts keep parallel compilation.

3. **No registry.** Module-level classes pickle by reference.

4. **Cache fingerprints depend on module paths.** A dimension is fingerprinted by
qualified name, `kind` and Cartesian axis flag (a staggered one through its base), so
moving a declaration to another module invalidates compiled artifacts. Re-running a
notebook cell that declares the same dimension reuses them, unless one of these changed.

5. **Generated identifiers need injective mangling.** A tag is not a valid C++,
DaCe or `eve` identifier, so backends escape it, without mapping two tags to
one identifier.

Comment on lines +126 to +129

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the reversible thing still needed? If not, there is no requirement to share this. They might still share, but it can be removed as implementation detail from this adr.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only injectivity is a requirement, and the ADR now says only that (e7cdbea). For the code, see my reply on from_codegen_name in dimensions.py.

🤖 Written by an agent on my behalf.

6. **Staggered dimensions become a real parametrized type.** ADR 0026's

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much of point 6 is implementation detail not needed at ADR level?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cut to the decision in e7cdbea: Staggered[K] is a real interned class, not a subclass of K, with tag <owner tag>[<base tag>].

🤖 Written by an agent on my behalf.

`_Staggered` *name prefix* cannot survive type identity: `Dimension(f"_Staggered{name}")`
names no importable type, and the prefix cannot recover the base dimension's
module. `Staggered[D]` replaces it and supersedes that part of ADR 0026.

`Staggered[KDim]` is a **real class**, built and interned on first use (a PEP 695
generic would give a `typing` alias, not a class). It is a *different* dimension, so
it does not subclass `KDim` and only inherits its `kind`. It keeps its base, and its
tag is `<owner tag>[<base tag>]`, so its ref is rebuilt from the tag without importing
anything. The intern table is keyed by the base class, like `typing`'s subscription
cache, not by a user-authored name.

### Cartesian axes are a level of the hierarchy

A **Cartesian axis** is an oriented integer line, i.e. a two-way infinite path graph: a
0-cell at each integer and a 1-cell between consecutive ones. Integer shifts (`D + n`)
preserve these two *cell classes* and half-integer shifts swap them (ADR 0026); a
`CartesianAxisIndex` names one class and `Staggered[...]` the other. A `Domain` selects a
range of it; periodic grids are not modelled. Mesh locations have no such translation:
their neighbours come from connectivity tables. Loosely, a declared dimension is itself
called "a Cartesian axis". Two levels below the root encode this:

```
DimensionIndex # the root; every `type[DimensionIndex]` keeps its meaning
├── AnyCartesianAxisIndex # either cell class of a Cartesian axis
│ ├── CartesianAxisIndex # a declared cell class: what users subclass
│ └── Staggered[D: CartesianAxisIndex] # its derived partner
└── (direct subclasses) # mesh locations, and index spaces without geometry
```

Both levels sit *below* `DimensionIndex`, so `Staggered[K]` stays a `DimensionIndex`
and no annotation or `issubclass` guard in the tree widens. The bound is on the
*declared* level, and `Staggered[K]` is only an `AnyCartesianAxisIndex`, so:

| Rejected | Statically (mypy, pyright) | At runtime |
| ----------------------------------------------- | -------------------------- | --------------------------------------------- |
| `Staggered[Staggered[K]]` | `[type-var]` | `TypeError` |
| `Staggered[Cell]`, staggering a local dimension | `[type-var]` | `TypeError` |
| `Cell + 1`, `Cell - 1` | `[operator]` | `TypeError`; a `DSLError` in a field operator |

**Open question:** The hierarchy says what a dimension is, not how dimensions relate to
each other: the Cartesian axes `I` and `J` are
orthogonal factors of a product grid, each its own horizontal direction, while the
mesh locations `Cell`, `Edge` and `Vertex` of a typical model are different entity
sets on *one* shared horizontal space. Expressing that relation belongs with a future
entity level (e.g. a `LocationIndex`) and is left to a later ADR.

### `Dimension` is annotation-only

`common.Dimension` becomes an alias for `type[DimensionIndex]`.

### Naming

A dimension's name is `.tag` (typed `common.Tag`) and `.value` keeps its meaning as the
index position, on the *instance*.

### Display uses the unqualified name

The `tag` is qualified, but it is *identity and IR spelling*, not a display name.
User-facing diagnostics use `cls.__qualname__` by default, so a field reads like
`Field[[IDim], float64]`.

### Equality between dimensions is identity

`I == J` is `True` only for the same class. With an integer, `I == 5` builds a `Domain`
instead, for `concat_where`.

## Alternatives considered

- **`(name, kind)` value equality with an interning registry.** See Decision.

## References

- Resolves, without a plugin, the static-typing gap reported in #2503 (closed).
- Supersedes the `_Staggered` name-prefix mechanism of
[ADR 0026](0026-Staggered_Dimensions.md); the indexing convention there is
unchanged.
- Consequence for the build cache of [ADR 0023](0023-Fingerprinting.md).
1 change: 1 addition & 0 deletions docs/development/ADRs/next/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Writing a new ADR is simple:
- [0021 - Argument Descriptors](0021-Argument-Descriptors.md)
- [0023 - Fingerprinting](0023-Fingerprinting.md)
- [0026 - Staggered Dimensions](0026-Staggered_Dimensions.md)
- [0030 - Dimensions as Nominal Types](0030-Dimensions_As_Nominal_Types.md)

### Frontend and Parsing #frontend

Expand Down
4 changes: 2 additions & 2 deletions docs/user/next/dsl/field-operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import numpy as np

import gt4py.next as gtx

I = gtx.Dimension("I")
J = gtx.Dimension("J")
class I(gtx.CartesianAxisIndex): ...
class J(gtx.CartesianAxisIndex): ...
```

The examples use these fields:
Expand Down
18 changes: 9 additions & 9 deletions docs/user/next/dsl/premap.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import gt4py.next as gtx
`i + 1`:

```{code-cell} ipython3
I = gtx.Dimension("I")
class I(gtx.CartesianAxisIndex): ...
IField = gtx.Field[gtx.Dims[I], gtx.float64]
a = gtx.as_field({I: 6}, np.array([0.0, 1.0, 4.0, 9.0, 16.0, 25.0]))
Expand Down Expand Up @@ -172,13 +172,13 @@ dimensions, the offsets `E2C` (the cells of every edge) and `C2E` (the edges of
every cell), and the connectivity tables behind them.

```{code-cell} ipython3
Cell = gtx.Dimension("Cell")
Edge = gtx.Dimension("Edge")
E2CDim = gtx.Dimension("E2C", kind=gtx.DimensionKind.LOCAL)
C2EDim = gtx.Dimension("C2E", kind=gtx.DimensionKind.LOCAL)
class Cell(gtx.DimensionIndex): ...
class Edge(gtx.DimensionIndex): ...
class E2CDim(gtx.DimensionIndex, kind=gtx.DimensionKind.LOCAL): ...
class C2EDim(gtx.DimensionIndex, kind=gtx.DimensionKind.LOCAL): ...
E2C = gtx.FieldOffset("E2C", source=Cell, target=(Edge, E2CDim))
C2E = gtx.FieldOffset("C2E", source=Edge, target=(Cell, C2EDim))
E2C = gtx.FieldOffset(E2CDim.tag, source=Cell, target=(Edge, E2CDim))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot we just use the dimension itself here instead of .tag? Or is that cleanup a follow up?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A follow-up. Here FieldOffset still takes the offset-provider key, a string. Passing the declaration itself is part of the connectivity change.

🤖 Written by an agent on my behalf.

C2E = gtx.FieldOffset(C2EDim.tag, source=Edge, target=(Cell, C2EDim))
edge_to_cell_table = np.array(
[[0, -1], [2, -1], [2, -1], [3, -1], [4, -1], [5, -1],
Expand All @@ -189,8 +189,8 @@ cell_to_edge_table = np.array(
)
offset_provider = {
"E2C": gtx.as_connectivity([Edge, E2CDim], codomain=Cell, data=edge_to_cell_table),
"C2E": gtx.as_connectivity([Cell, C2EDim], codomain=Edge, data=cell_to_edge_table),
E2CDim.tag: gtx.as_connectivity([Edge, E2CDim], codomain=Cell, data=edge_to_cell_table),
C2EDim.tag: gtx.as_connectivity([Cell, C2EDim], codomain=Edge, data=cell_to_edge_table),
}
CellField = gtx.Field[gtx.Dims[Cell], gtx.float64]
Expand Down
4 changes: 2 additions & 2 deletions docs/user/next/dsl/programs.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ import numpy as np

import gt4py.next as gtx

I = gtx.Dimension("I")
J = gtx.Dimension("J")
class I(gtx.CartesianAxisIndex): ...
class J(gtx.CartesianAxisIndex): ...

IJField = gtx.Field[gtx.Dims[I, J], gtx.float64]

Expand Down
4 changes: 2 additions & 2 deletions docs/user/next/dsl/scan-operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import numpy as np

import gt4py.next as gtx

I = gtx.Dimension("I")
K = gtx.Dimension("K", kind=gtx.DimensionKind.VERTICAL)
class I(gtx.CartesianAxisIndex): ...
class K(gtx.CartesianAxisIndex, kind=gtx.DimensionKind.VERTICAL): ...

KField = gtx.Field[gtx.Dims[K], gtx.float64]
IKField = gtx.Field[gtx.Dims[I, K], gtx.float64]
Expand Down
Loading