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
2 changes: 1 addition & 1 deletion cellpy/readers/instruments/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ def parse_loader_parameters(self, auto_formatter=None, **kwargs):

if unit_labels := kwargs.get("unit_labels", None):
logging.critical(f"overriding unit_labels: {unit_labels}")
self.config_params.raw_limits.update(unit_labels)
self.config_params.unit_labels.update(unit_labels)

if raw_limits := kwargs.get("raw_limits", None):
logging.critical(f"overriding raw_limits: {raw_limits}")
Expand Down
26 changes: 26 additions & 0 deletions tests/test_loader_two_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,29 @@ def test_the_two_stages_agree_with_the_legacy_frame():
f"{column} differs by {difference} between the two-stage path and "
f"the legacy path"
)


@pytest.mark.essential
def test_unit_labels_override_lands_in_unit_labels_not_raw_limits():
"""A ``unit_labels=`` override must reach ``config_params.unit_labels``.

Regression for a copy-paste slip where the ``unit_labels`` branch of
``parse_loader_parameters`` updated ``raw_limits`` instead. The symptom was
that vendor column-name templates (neware spells its columns
``Current({{ current }})``) could not be overridden this way, while the
unit-label strings silently polluted ``raw_limits``.
"""
loader = _loader("neware_txt", model="one")
raw_limits_before = dict(loader.config_params.raw_limits)

with warnings.catch_warnings():
warnings.simplefilter("ignore")
# sep is given so the branch runs without touching the auto-formatter.
loader.parse_loader_parameters(sep="\t", unit_labels={"current": "A"})

assert loader.config_params.unit_labels["current"] == "A", (
"unit_labels override did not reach config_params.unit_labels"
)
assert dict(loader.config_params.raw_limits) == raw_limits_before, (
"unit_labels override leaked into config_params.raw_limits"
)
Loading