Skip to content

Wire operators and operator_axis options in provider (#8, #54)#62

Merged
jc-macdonald merged 2 commits intomainfrom
feat/8-54-operator-wiring
Apr 13, 2026
Merged

Wire operators and operator_axis options in provider (#8, #54)#62
jc-macdonald merged 2 commits intomainfrom
feat/8-54-operator-wiring

Conversation

@jc-macdonald
Copy link
Copy Markdown
Collaborator

Summary

Expose operator metadata through SystemABC.option() so downstream engines (e.g., op_engine) can discover IMEX operator configuration without re-parsing the spec. Also fixes a bug where whitespace in template equation keys caused false validation errors.

Changes

Bug fix — specs.py whitespace normalisation (01cbe8e)

Equation keys written with spaces inside brackets (e.g., "u[x, y]") failed validation because _expand_state_templates builds canonical keys without spaces ("u[x,y]"). Added _normalize_bracket_key to strip whitespace inside brackets at equation-map entry, using the existing _STATE_TEMPLATE_RE regex. Tested with 2-axis and 3-axis cases.

This helper is intentionally minimal — broader parsing consolidation is tracked in #30 and the Pydantic-ify milestone (#22, #28).

Feature — operator wiring (4a3bef5)

Two new static methods on OpSystemSystem:

  • _extract_operators → returns tuple[MappingProxyType, ...] | None from compiled.meta["operators"]
  • _extract_operator_axis → returns the shared axis name (str) when all operators act on one axis, otherwise None

Wired into model_post_init alongside the existing mixing_kernels:

self.options = {
    "mixing_kernels": mixing_kernels,
    "operators": operators,
    "operator_axis": operator_axis,
}

Operator dicts are stored as MappingProxyType to prevent callers from accidentally mutating spec metadata.

Tests added

  • Equation key spaces accepted (2-axis and 3-axis)
  • Extra whitespace around axis names normalised
  • Operators present/absent via option()
  • Immutability enforcement (MappingProxyType rejects mutation)
  • Single vs. mixed operator axis detection
  • Multi-operator specs surface both operators
  • Operators independent of mixing_kernels

Closes

Related

Equation keys like "u[x, y]" failed validation because template
expansion produces "u[x,y]" (no spaces). Normalize equation key
bracket contents at entry to match template form.

Note: this helper is intentionally minimal — broader parsing
consolidation is tracked in #30 and the Pydantic-ify milestone
(#22, #28).
Extract operator metadata from compiled spec and expose via
SystemABC.option():
- operators: tuple of immutable MappingProxy dicts (or None)
- operator_axis: shared axis name when all operators act on one axis

Operator data is stored as immutable MappingProxyType objects to
prevent callers from accidentally mutating spec metadata.
@jc-macdonald jc-macdonald force-pushed the feat/8-54-operator-wiring branch from 4a3bef5 to 756b3dc Compare April 10, 2026 21:12
@jc-macdonald jc-macdonald self-assigned this Apr 11, 2026
@jc-macdonald jc-macdonald added enhancement New feature or request provider flepimop2 provider/connector package labels Apr 12, 2026
@jc-macdonald jc-macdonald added this to the Provider Integration milestone Apr 12, 2026
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.

LGTM

@jc-macdonald jc-macdonald merged commit b4d3805 into main Apr 13, 2026
5 checks passed
@jc-macdonald jc-macdonald deleted the feat/8-54-operator-wiring branch April 13, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request provider flepimop2 provider/connector package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wire operators and operator_axis options in provider Add op_engine compatible operator wiring

3 participants