Skip to content

feat: add coord_shift transition type#66

Merged
jc-macdonald merged 1 commit intomainfrom
feature/coord-shift-47
Apr 21, 2026
Merged

feat: add coord_shift transition type#66
jc-macdonald merged 1 commit intomainfrom
feature/coord-shift-47

Conversation

@jc-macdonald
Copy link
Copy Markdown
Collaborator

Closes #47

Summary

Introduces coord_shift entries in the transitions list as a concise way to specify axis-coordinate-shifting transitions across a set of states.

What changed

  • New transition type coord_shift: instead of writing individual from/to transitions for every state and every non-shifted axis combination, a single coord_shift entry expands to all concrete transitions automatically.
  • Expansion logic runs at the same pipeline stage as chain expansion — mutating transitions_raw before template expansion — so the generated transitions are treated identically to any hand-written concrete transition.
  • Validation covers: axis must exist, both coordinates must be valid members of that axis, apply_to must be a non-empty list, rate must be a string, all target states must already exist in the expanded state list.

Example

transitions:
  - coord_shift: {vax: u -> v}
    apply_to: [S, R]
    rate: nu

Expands to:

- {from: S__vax_u, to: S__vax_v, rate: nu}
- {from: R__vax_u, to: R__vax_v, rate: nu}

For states with additional axes, transitions are emitted for each combination of the non-shifted axis coordinates.

Tests

8 new tests:

  • Single-axis expansion (correct pairs, correct count)
  • Multi-axis expansion over non-shifted coordinates
  • Coexistence with regular and templated transitions
  • Validation errors: unknown axis, bad coordinate, missing apply_to, missing rate, malformed arrow syntax

Introduce coord_shift entries in the transitions list that expand into
concrete from/to/rate transitions by shifting one axis coordinate for
a set of apply_to states.

Example:
  coord_shift: {vax: u -> v}
  apply_to: [S, R]
  rate: nu

expands to S__vax_u->S__vax_v and R__vax_u->R__vax_v transitions.
Multi-axis states expand over all non-shifted axis coordinates.

Adds _validate_coord_shift_entry, _apply_coord_shifts, and
_expand_coord_shift_for_base helpers with 8 new tests covering
happy paths, multi-axis expansion, and validation errors.
Copy link
Copy Markdown
Member

@pearsonca pearsonca left a comment

Choose a reason for hiding this comment

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

Seems conceptually fine, but: what's the plan for expressing non-categorical shifts?

@jc-macdonald
Copy link
Copy Markdown
Collaborator Author

Seems conceptually fine, but: what's the plan for expressing non-categorical shifts?

for continuous shifts the natural thing is an advection operator - I have an issue for that already on op_engine, ACCIDDA/op_engine#59

@pearsonca
Copy link
Copy Markdown
Member

Seems fine for now - I do think we want to have conceptual consistency in the configuration DSL expression for change in e.g. vaccine status and change in e.g. age, whatever is going on under the hood.

break-break, we'll want some simplified expression for initial conditions by axes as well

@jc-macdonald jc-macdonald marked this pull request as ready for review April 21, 2026 09:53
@jc-macdonald jc-macdonald merged commit a3bf431 into main Apr 21, 2026
5 checks passed
@jc-macdonald jc-macdonald deleted the feature/coord-shift-47 branch April 21, 2026 09:53
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.

Add coord_shift transition type for axis-coordinate transitions

3 participants