Skip to content

Scale/offset silently truncate when their length does not match the value #8450

Description

ParameterBase converts between a value and its raw value by zipping the value with an iterable scale/offset:

tuple(val * sub_scale for val, sub_scale in zip(raw_value, scale))

in _scale_raw_value, _offset_raw_value, _unoffset_value and _unscale_value in src/qcodes/parameters/parameter_base.py.

Since zip is not strict, a length mismatch is silently truncated. Setting a parameter with scale = [2, 4] to [10, 20, 30] silently drops the third element rather than telling the user that the scale does not match the value.

We should decide whether to use zip(..., strict=True) (or an explicit length check raising a clear ValueError) so that a mismatch is reported instead of silently producing a shorter value. This is a behaviour change for anyone relying on the truncation, so it needs a breaking-change newsfragment.

Follow up from #8449.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions