Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## [Unreleased]

* Step-type string literals use the `cellpycore` vocabulary (#543, native-
headers Phase-0 prerequisite): `CellpyCell.list_of_step_types` is now
`list(config.STEP_TYPES)` (was a hand-maintained duplicate of the 13
step-type names), and the step-table `type` comparisons in `utils/ocv_rlx.py`
/ `utils/helpers.py` use `StepType.CHARGE.value` / `.DISCHARGE.value` instead
of bare `"charge"` / `"discharge"` literals. Behavior-identical.

* Header column literals in `utils/helpers.py` and `filters/summary.py` use
header-object attributes (#538, native-headers Phase-0 prerequisite): the
base-name string-keyed `hdr_summary["charge_capacity"]`-style lookups become
Expand Down
19 changes: 4 additions & 15 deletions cellpy/readers/cellreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
# still expects. cellpy-core's __init__ is intentionally empty, so import submodules.
from cellpycore import units as core_units
from cellpycore.cell_core import OldCellpyCellCore
from cellpycore.config import STEP_TYPES

from cellpy.readers.cellpy_file import dtype as cellpy_file_dtype
from cellpy.readers.cellpy_file import fids as cellpy_file_fids
Expand Down Expand Up @@ -297,21 +298,9 @@ def __init__(

self.capacity_modifiers = ["reset"]

self.list_of_step_types = [
"charge",
"discharge",
"cv_charge",
"cv_discharge",
"taper_charge",
"taper_discharge",
"charge_cv",
"discharge_cv",
"ocvrlx_up",
"ocvrlx_down",
"ir",
"rest",
"not_known",
]
# single source of the step-type vocabulary (cellpycore #543);
# was a hand-maintained duplicate of config.STEP_TYPES.
self.list_of_step_types = list(STEP_TYPES)
# - options
self.force_step_table_creation = config.reader.force_step_table_creation
self.force_all = config.reader.force_all
Expand Down
4 changes: 3 additions & 1 deletion cellpy/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import pandas as pd
from scipy import stats

from cellpycore.config import StepType

import cellpy
import cellpy.config as config
from cellpy import prms
Expand Down Expand Up @@ -1456,7 +1458,7 @@ def select_summary_based_on_rate(
filtered summary (Pandas.DataFrame).
"""
if on is None:
on = ["charge"]
on = [StepType.CHARGE.value]
else:
if not isinstance(on, (list, tuple)):
on = [on]
Expand Down
10 changes: 6 additions & 4 deletions cellpy/utils/ocv_rlx.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import numpy as np
import pandas as pd

from cellpycore.config import StepType

from cellpy import cellreader
from cellpy.parameters.internal_settings import get_headers_normal, get_headers_step_table

Expand Down Expand Up @@ -371,21 +373,21 @@ def find_zero(self, cycle, direction):
if direction == "up":
end_voltage = step_table[
(step_table[hdr_steps.cycle] == cycle)
& (step_table[hdr_steps.type].isin(["discharge"]))
& (step_table[hdr_steps.type].isin([StepType.DISCHARGE.value]))
][hdr.voltage + "_last"].values[0]

end_current = step_table[
(step_table[hdr_steps.cycle] == cycle)
& (step_table[hdr_steps.type].isin(["discharge"]))
& (step_table[hdr_steps.type].isin([StepType.DISCHARGE.value]))
][hdr.current + "_last"].values[0]

elif direction == "down":
end_voltage = step_table[
(step_table[hdr_steps.cycle] == cycle) & (step_table[hdr_steps.type].isin(["charge"]))
(step_table[hdr_steps.cycle] == cycle) & (step_table[hdr_steps.type].isin([StepType.CHARGE.value]))
][hdr.voltage + "_last"].values[0]

end_current = step_table[
(step_table[hdr_steps.cycle] == cycle) & (step_table[hdr_steps.type].isin(["charge"]))
(step_table[hdr_steps.cycle] == cycle) & (step_table[hdr_steps.type].isin([StepType.CHARGE.value]))
][hdr.current + "_last"].values[0]

return end_current, end_voltage
Expand Down
Loading