Repository navigation
fix(graph): spread the subsample slices over the whole series - #3810
Merged
nicolargo merged 1 commit intoOct 23, 2026
Merged
Conversation
time_series_subsample() and subsample() cut the data into slices of round(len / sampling) points. When the rounding goes up, the last slices are empty and the call raises IndexError (or StatisticsError); when it goes down, the newest points are left out. Compute each slice bound as s * len // sampling instead, so every slice holds at least one point and the whole series is used.
Owner
|
Thanks @Enesuygurs Merged into develop. |
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.
Description
The graph export averages each series down to the chart width with
time_series_subsample(points, self.width). The helper cut the data into slices ofround(len(data) / sampling)points and tooksamplingof them. That only covers the whole series when the division is exact:t[...][0]raisesIndexError(andmean([])raisesStatisticsErrorinsubsample()).With the defaults (
[global] history_size=1200,[graph] width=800), both happen. From 801 to 1199 points, the charts end at the 800th sample. Once the history is full,round(1200 / 800) == 2and slice 600 isdata[1200:1202]. From then on, every export cycle logs:and no SVG is written again, for any plugin. The TUI's
gkey fails the same way.The slice bounds are now
s * len(data) // sampling. Every slice holds at least one point, and together the slices cover the whole series.time_series_subsample()still keeps the first timestamp and the mean value of each slice, andsubsample()gets the same change.Testing:
test_017_time_series_subsampleand two more checks intest_016_subsample(tests/test_core.py). They fail twice ondevelop; with the fix, all 8 tests in the file pass.Resume