Skip to content

DI restructuring of CellpyCell: injectable core + instrument factory (#520)#528

Merged
jepegit merged 4 commits into
feat/511-native-schema-opt-infrom
refactor/520-di-cellpycell
Jul 17, 2026
Merged

DI restructuring of CellpyCell: injectable core + instrument factory (#520)#528
jepegit merged 4 commits into
feat/511-native-schema-opt-infrom
refactor/520-di-cellpycell

Conversation

@jepegit

@jepegit jepegit commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

The architectural tail of V2-09 (closes #520), design-first as the issue requires: the ADR in .issueflows/04-designs-and-guides/cellpycell-di-restructuring.md decides what CellpyCell.__init__ owns vs receives.

Stacked on #527 (→ #526#525#524) — merge in order and retarget.

Test plan

  • test_slim.py (core-seam acceptance): 6 → 8 tests, green — including the two new DI pins (injected core drives the pipeline; injected factory is used and never rebuilt)
  • Full suite: 659 passed, 0 failed
  • ruff clean

🤖 Generated with Claude Code

jepegit and others added 3 commits July 17, 2026 15:28
…#518)

Verbatim move following the #509 capacity_curves pattern: instance-first
functions, thin delegates on CellpyCell keep the public API and subclass
dispatch. to_bdf was already thin and stays. The near-dead test-pinned
_cap_mod_summary/_cap_mod_normal move along; their removal is deferred
to the DI pass (#520). Dropped a stray print(externals) debug line from
to_excel; removed the now-unused csv/itertools imports from cellreader.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Verbatim move following the #509 capacity_curves pattern: instance-first
functions, thin delegates on CellpyCell keep the public API. The
CellpyCell.vacant classmethod is called instance-bound (identical for
CellpyCell, dispatches for subclasses). Coverage of the helpers was
thin (only split/drop_from/drop_to pinned); added pins for from_cycle,
to_cycle, drop_edges (+error cases), split_many with a list, and
with_cycles.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…520)

Design-first per the issue: ADR in
.issueflows/04-designs-and-guides/cellpycell-di-restructuring.md decides
what __init__ owns vs receives. The two behavioural collaborators become
constructor-injectable with unchanged defaults:

- core=: injected core seam wins over the native_schema-flag default
- instrument_factory=: injected loader registry;
  register_instrument_readers() now only builds the default when none is
  set (idempotent-with-injection instead of silently rebuilding)

Config snapshot / units / headers stay owned (plain data, already
parameterizable); the extracted modules stay wired as instance-first
functions + thin delegates. Two DI pins added to test_slim.py.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cursor

cursor Bot commented Jul 17, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

Base automatically changed from refactor/519-extract-slicing to feat/511-native-schema-opt-in July 17, 2026 13:52
@jepegit
jepegit merged commit 9335718 into feat/511-native-schema-opt-in Jul 17, 2026
@jepegit
jepegit deleted the refactor/520-di-cellpycell branch July 17, 2026 13:53
jepegit added a commit that referenced this pull request Jul 17, 2026
)

* Fix cellpycore 0.2.2 sync fallout: merger summary test_id + stale tests

Core #136 bridges test_id through the legacy steps/summary output, which
left four non-essential tests failing on master and exposed a merger bug:
campaign_fold concatenated the right-hand summary without remapping its
test_id, so a merged (pre-recompute) summary carried test_id=0 on every
row and would round-trip wrongly through v9.

- merger: remap the right summary's test_id via the merge id-map
  (mirrors the raw handling)
- cellreader: drop the #507 re-stamp workaround in make_step_table
  (core 0.2.2 delivers test_id directly)
- tests: update the .h5 -> .cellpy default-extension expectations and the
  single-test no-test_id assertion; add a regression test for the
  merger remap

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Native schema opt-in: CellpyCell(native_schema=True) (#511, V2-11)

Feature-flagged path where frames stay in native cellpy-core column
names and the polars engine runs directly - no legacy rename sandwich.
The legacy bridge stays the default; goldens unchanged.

- new NativeCellpyCellCore adapter (pandas <-> polars seam, no renames)
  accepting the same call signatures cellreader uses against the bridge
- one-time translate at the I/O boundary in from_raw / load
- guards: v8 HDF5 save and campaign merge raise on native-schema cells
- make_summary skips the legacy column sort on the native path
- 8 new tests incl. native-vs-legacy value parity through the mapping
  and a native v9 round-trip
- epic status table updated (Phases 1-4 were done but still marked open)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Extract exporter family from cellreader into cellpy.exporters.tabular (#518) (#526)

Verbatim move following the #509 capacity_curves pattern: instance-first
functions, thin delegates on CellpyCell keep the public API and subclass
dispatch. to_bdf was already thin and stays. The near-dead test-pinned
_cap_mod_summary/_cap_mod_normal move along; their removal is deferred
to the DI pass (#520). Dropped a stray print(externals) debug line from
to_excel; removed the now-unused csv/itertools imports from cellreader.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* Extract split/drop-cycle helpers into cellpy.readers.slicing (#519) (#527)

* Extract exporter family from cellreader into cellpy.exporters.tabular (#518)

Verbatim move following the #509 capacity_curves pattern: instance-first
functions, thin delegates on CellpyCell keep the public API and subclass
dispatch. to_bdf was already thin and stays. The near-dead test-pinned
_cap_mod_summary/_cap_mod_normal move along; their removal is deferred
to the DI pass (#520). Dropped a stray print(externals) debug line from
to_excel; removed the now-unused csv/itertools imports from cellreader.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Extract split/drop-cycle helpers into cellpy.readers.slicing (#519)

Verbatim move following the #509 capacity_curves pattern: instance-first
functions, thin delegates on CellpyCell keep the public API. The
CellpyCell.vacant classmethod is called instance-bound (identical for
CellpyCell, dispatches for subclasses). Coverage of the helpers was
thin (only split/drop_from/drop_to pinned); added pins for from_cycle,
to_cycle, drop_edges (+error cases), split_many with a list, and
with_cycles.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

* DI restructuring of CellpyCell: injectable core + instrument factory (#520) (#528)

* Extract exporter family from cellreader into cellpy.exporters.tabular (#518)

Verbatim move following the #509 capacity_curves pattern: instance-first
functions, thin delegates on CellpyCell keep the public API and subclass
dispatch. to_bdf was already thin and stays. The near-dead test-pinned
_cap_mod_summary/_cap_mod_normal move along; their removal is deferred
to the DI pass (#520). Dropped a stray print(externals) debug line from
to_excel; removed the now-unused csv/itertools imports from cellreader.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Extract split/drop-cycle helpers into cellpy.readers.slicing (#519)

Verbatim move following the #509 capacity_curves pattern: instance-first
functions, thin delegates on CellpyCell keep the public API. The
CellpyCell.vacant classmethod is called instance-bound (identical for
CellpyCell, dispatches for subclasses). Coverage of the helpers was
thin (only split/drop_from/drop_to pinned); added pins for from_cycle,
to_cycle, drop_edges (+error cases), split_many with a list, and
with_cycles.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* DI restructuring of CellpyCell: injectable core + instrument factory (#520)

Design-first per the issue: ADR in
.issueflows/04-designs-and-guides/cellpycell-di-restructuring.md decides
what __init__ owns vs receives. The two behavioural collaborators become
constructor-injectable with unchanged defaults:

- core=: injected core seam wins over the native_schema-flag default
- instrument_factory=: injected loader registry;
  register_instrument_readers() now only builds the default when none is
  set (idempotent-with-injection instead of silently rebuilding)

Config snapshot / units / headers stay owned (plain data, already
parameterizable); the extracted modules stay wired as instance-first
functions + thin delegates. Two DI pins added to test_slim.py.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant