feat: renumber cycles for discharge-first full cells (cellpy#359 / Stage 5 S3) - #153
Merged
Merged
Conversation
…ft plan Co-authored-by: Jan Petter Maehlen <jepe@ife.no>
Opt-in post-processing step that renumbers cycle_num so every cycle opens with a chosen StepDirection, re-accumulates the cycle-cumulative raw capacity/energy columns to the new boundaries (shared helper extracted from normalize_capacity_granularity), rebuilds the step table and drops a stale summary. Mirrors jepegit/cellpy#359 (Stage 5 S3). Co-authored-by: Jan Petter Maehlen <jepe@ife.no>
…n (#359) Co-authored-by: Jan Petter Maehlen <jepe@ife.no>
jepegit
marked this pull request as ready for review
October 1, 2026 18:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stage 5 S3 — mirrors jepegit/cellpy#359 (labelled
to core): full cells that start with a lone discharge get a cycler cycle counter that mis-pairs half-cycles ([D C D][C D]…or[D C][D C]…), so coulombic efficiency and curve extraction are wrong.Changes
config.StepDirection(CHARGE/DISCHARGE) — the direction that opens a cycle. Kept separate fromTestMode, which stays binary (polarity only).summarizers.renumber_cycles(data, schema=None, opening=StepDirection.CHARGE, **step_table_kwargs)— opt-in post-processing step, exported top-level:test_id, a new cycle opens where anopeningstep follows the last non-neutral step of the other direction; the first step is never a boundary, so a leading lone discharge stays cycle 1; rest / IR / OCV steps attach to the current cycle;_reaccumulate_cumulative(body extracted fromnormalize_capacity_granularity, which now calls the same helper);make_step_table(**step_table_kwargs)and a stale summary is dropped;ValueErrorforustepstep tables / duplicate(test_id, cycle, step)keys,NoDataFoundwithout raw or steps.standalone-use.mdsection,harmonized-raw.mdcycle_numopen question resolved, design note.issueflows/04-designs-and-guides/cycle-renumbering.md.Tests
tests/test_renumber_cycles.py(14 tests): the three patterns from the issue against a plain-Python oracle, rest/CV attachment, anode mirror (opening=DISCHARGE), 0-based numbering preserved, energy columns, twotest_ids renumbered independently, pandas in/out, summary drop, error paths, and the harmonized anode fixture ([D C]x17 [D]): byte-identical no-op withopening=DISCHARGE, regrouped as[D] + [C D]x17with capacity conserved underopening=CHARGE.Full suite: 303 passed;
ruff check/ruff format --checkclean.Notes
cellpy/cellpy-coremirror issue could not be created from this environment (read-only token); the local tracking number359is provisional.cycle_modevariant mapping toTestMode.NORMAL+renumber_cycles) and the release note are follow-ups in jepegit/cellpy./iflow-close.