Converts a partial or unknown calibration object into a valid spec.
The Rust CalibrationSpec accepts only finite JSON numbers and rejects the whole
config when a spec is malformed. This function repairs such input instead, keeping
as much of what was entered as possible, so that saving from the dashboard writes a
spec Rust can read. Valid specs come out unchanged. Rules, by type:
Missing input or a non-string type: identity.
linear: a and b are kept if they are finite numbers or numeric strings
(stored back as numbers), otherwise a becomes 1 and b becomes 0.
polynomial: coefficients that are finite numbers or numeric strings are kept as
numbers and the rest dropped. An empty list stays empty and, as in Rust, evaluates
to 0. A missing or non-array coeffs becomes [0, 1], the identity polynomial.
Any other type: identity.
A non-blank string id or unit is carried over (trimmed) in every case except the
first; blank or non-string values are left out, so the result has no undefined
fields. Returns a new object and does not modify raw.
Converts a partial or unknown calibration object into a valid spec.
The Rust
CalibrationSpecaccepts only finite JSON numbers and rejects the whole config when a spec is malformed. This function repairs such input instead, keeping as much of what was entered as possible, so that saving from the dashboard writes a spec Rust can read. Valid specs come out unchanged. Rules, bytype:type: identity.linear:aandbare kept if they are finite numbers or numeric strings (stored back as numbers), otherwiseabecomes 1 andbbecomes 0.polynomial: coefficients that are finite numbers or numeric strings are kept as numbers and the rest dropped. An empty list stays empty and, as in Rust, evaluates to 0. A missing or non-arraycoeffsbecomes[0, 1], the identity polynomial.type: identity.A non-blank string
idorunitis carried over (trimmed) in every case except the first; blank or non-string values are left out, so the result has noundefinedfields. Returns a new object and does not modifyraw.