Skip to content

fix: consolidate adapter metadata into self.options (#12)#63

Merged
jc-macdonald merged 3 commits intomainfrom
12-adapter-options-upgrade
Apr 13, 2026
Merged

fix: consolidate adapter metadata into self.options (#12)#63
jc-macdonald merged 3 commits intomainfrom
12-adapter-options-upgrade

Conversation

@jc-macdonald
Copy link
Copy Markdown
Collaborator

Upgrades the flepimop2 provider adapter to expose all metadata through self.options instead of bare instance attributes, per flepimop2 discussion #129 and the ModuleABC.option() API (ACCIDDA/flepimop2#118).

Changes

Adapter (flepimop2-op_system/src/.../op_system/__init__.py)

  • Consolidated 9 bare instance attributes (self.axis_order, self.axis_sizes, self.axis_coords, self.state_shape, self.flatten, self.unflatten, self.mixing_kernels, plus operators and operator_axis) into a single self.options = {...} dict
  • Fixed stepper closure to capture mixing_kernels as a local variable instead of referencing the (now removed) self.mixing_kernels

Tests (flepimop2-op_system/tests/test_system.py)

  • Added 9 new tests validating option access via system.option():
    • test_option_axis_order_bare_spec / test_option_axis_order_with_axes
    • test_option_axis_sizes_bare_spec / test_option_axis_sizes_with_axes
    • test_option_axis_coords_bare_spec / test_option_axis_coords_with_axes
    • test_option_state_shape_bare_spec / test_option_state_shape_with_axes
    • test_option_flatten_unflatten_roundtrip

mypy (flepimop2-op_system/pyproject.toml)

Closes #12

Remove bare instance attributes (axis_order, axis_sizes, axis_coords,
state_shape, flatten, unflatten, mixing_kernels) and expose them
exclusively via self.options dict.

Fix overwrite bug where individual option assignments were clobbered
by a subsequent self.options = {...} reassignment. Capture
mixing_kernels as a local in the stepper closure.
Cover axis_order, axis_sizes, axis_coords, state_shape, flatten, and
unflatten options for both bare SIR specs and specs with explicit axes.
Include flatten/unflatten roundtrip test.
flepimop2 is an implicit namespace package, so mypy cannot locate
py.typed. Add a [[tool.mypy.overrides]] entry to follow imports for
flepimop2.* modules, resolving both the import-untyped and the
missing-override-base errors.
Comment on lines +76 to +78
"axis_order": axes_meta.axis_order,
"axis_sizes": axes_meta.axis_sizes,
"axis_coords": axes_meta.axis_coords,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fine for now, but ideally these get pulled into the axes field on SystemABC

@jc-macdonald jc-macdonald merged commit c3320ee into main Apr 13, 2026
5 checks passed
@jc-macdonald jc-macdonald deleted the 12-adapter-options-upgrade branch April 13, 2026 20:23
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.

op_system flepimop2 adapter upgrade

3 participants