Part of Stage 1 — behavior-preserving construction (see the Stage-1 tracking issue). Stage 0: jepegit/cellpy#439. Plan documents live in the shared workspace: cellpy-workspace/architecture-plan/ (the architecture-plan repo; formerly architecture-plan/) (alongside the cellpy and cellpy-core repos). Everything in Stage 1 lands on master with the full suite green; nothing flips user-visible behavior.
Goal
Three additive helpers in cellpycore.units (behind the existing units extra):
convert_value(value, physical_property, from_units=None, to_units=None) -> float —
port of cellpy's to_cellpy_unit generalized (accepts number / pint-quantity string /
(value, unit) tuple; defaults from raw→cellpy units).
calculate_scaler(from_unit, to_unit) -> float — port of unit_scaler_from_raw
(Q(1, a).to(b).m).
validate_units(units) -> CellpyUnits — every label pint-parsable, warn on unknown
keys; the loader-boundary validator (note the "C" Celsius-vs-Coulomb pitfall —
decide degC handling here).
Why
cellpy Stage 1.6 deletes its duplicated converter bodies and needs these to wrap;
the loader port later calls validate_units on every configuration. Additions cross the
repos core-first (release + re-pin) per the merge-order rule.
Links (workspace)
architecture-plan/unit-handling-cellpy2-plan.md (Phase 2–3, §3 gap table, §7 risk 5)
architecture-plan/cellpy2-release-and-branching-plan.md (§3 merge order)
Acceptance
- Unit tests incl. quantity-string and tuple inputs, bad-label failures, temperature
handling documented; pint-optional guard still green (helpers raise only when called).
- Tagged release cut so cellpy can re-pin (release-procedure.md).
Goal
Three additive helpers in
cellpycore.units(behind the existingunitsextra):convert_value(value, physical_property, from_units=None, to_units=None) -> float—port of cellpy's
to_cellpy_unitgeneralized (accepts number / pint-quantity string /(value, unit)tuple; defaults from raw→cellpy units).calculate_scaler(from_unit, to_unit) -> float— port ofunit_scaler_from_raw(
Q(1, a).to(b).m).validate_units(units) -> CellpyUnits— every label pint-parsable, warn on unknownkeys; the loader-boundary validator (note the
"C"Celsius-vs-Coulomb pitfall —decide
degChandling here).Why
cellpy Stage 1.6 deletes its duplicated converter bodies and needs these to wrap;
the loader port later calls
validate_unitson every configuration. Additions cross therepos core-first (release + re-pin) per the merge-order rule.
Links (workspace)
architecture-plan/unit-handling-cellpy2-plan.md(Phase 2–3, §3 gap table, §7 risk 5)architecture-plan/cellpy2-release-and-branching-plan.md(§3 merge order)Acceptance
handling documented; pint-optional guard still green (helpers raise only when called).