Repository navigation
Fix automatic calibration of missing and expanded physical signals - #787
Merged
Merged
Conversation
tompollard
commented
Nov 30, 2026
tompollard
left a comment
Member
Author
There was a problem hiding this comment.
This looks correct and ready to merge. Thanks for fixing #786.
- Missing samples. Dropping
naninest_resbefore taking the minimum increment fixes theIndexError, which came from ananincrement. It also fixes constant channels, which previously failed onmin()of an empty sequence. - Expanded signals. That branch now calls
calc_adc_params(), just like the uniform branch.calc_adc_paramsalready handlese_p_signaland ignoresnanthroughfmin/fmax.
Checked locally:
nanpositions survive a round trip for:- a channel containing its minimum, its maximum and a
nan; - 500 random samples with 5%
nan; - an all-
nanchannel next to a normal one; - a constant channel;
float32input.
- a channel containing its minimum, its maximum and a
- The minimum value is never written as the missing-value marker.
- Rounding error stays within half a step (
0.5 / adc_gain) in every case. - A three-channel expanded record with
samps_per_frame=[2, 1, 1]and one all-nanchannel round-trips withnanpositions intact, andcheck_recordreports no issues. -infgets the same clear error asinf.set_d_featuresis the only caller ofest_res, so nothing else is affected.- The offline suite and ruff pass.
Optional: the tests use atol=0.01. Asserting against half a step (0.5 / adc_gain) would also catch a calibration that gets worse while staying under 0.01.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #786.
Automatic format selection now ignores NaN samples when estimating physical signal resolution. An all-NaN or constant channel gets the lowest estimated resolution, while its missing samples still use the format's digital missing-value marker. Infinite samples give a clear calibration error.
Expanded physical signals now calculate
adc_gainandbaselineafter selecting a format, matching the uniform signal path. This works through bothwrsampandwrite_recordwithout requiring callers to supply calibration fields.Verification