Skip to content

fix: trim error bars with rolling plot points - #2223

Open
ayushmaan-16 wants to merge 1 commit into
fossasia:devfrom
ayushmaan-16:fix/rolling-plot-error-bars
Open

ayushmaan-16 wants to merge 1 commit into
fossasia:devfrom
ayushmaan-16:fix/rolling-plot-error-bars

Conversation

@ayushmaan-16

@ayushmaan-16 ayushmaan-16 commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

Keep error bars aligned with the points retained by opts.max_points.

Previously, the server removed old coordinates but kept their error values. The remaining points could then show error bars from discarded samples, and the unused values stayed in memory.

Add the array and arrayminus paths for error_x, error_y, and error_z to the existing trimming list. This covers scatter, scattergl, and scatter3d.

Motivation and Context

Each retained point should keep its matching error values.

For example, if points 2 and 3 remain from four samples with upper errors [1, 2, 8, 12], their errors should be [8, 12]. Previously, they displayed [1, 2] instead.

This also keeps unused error values from reducing the memory benefit of max_points.

How Has This Been Tested?

  • Added 27 regression cases covering creation, lowering the limit, incremental append patches, disabled limits, and scalar error settings.
  • Confirmed 21 cases fail on upstream and pass with this fix.
  • All 391 targeted unit and integration tests pass, including plot updates, polling parity, and pane broadcasts.
  • Verified that applying the generated JSON patches produces the same pane as the server.
  • Tested a 100,000-point plot capped at 100 points. Each error array now retains 100 values instead of 100,000. Traced retained Python allocations dropped from about 6.4 MB to 15 KB.
  • Rendered the actual before/after server output with the repository's pinned Plotly version and captured a comparison screenshot.
  • Black 23.1.0 and the configured pre-commit checks pass.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code refactor or cleanup (changes to existing code for improved readability or performance)

Checklist:

  • I adapted the version number under py/visdom/VERSION according to Semantic Versioning
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Summary by Sourcery

Trim rolling-plot error-bar arrays alongside expired points.

Bug Fixes:

  • Keep data-based error bars aligned with their points when rolling plots discard older samples, including during plot creation, limit changes, and incremental updates.

Tests:

  • Add regression coverage for rolling error bars across supported trace types, limit changes, append updates, and unchanged scalar error settings.

Summary by CodeRabbit

  • Bug Fixes
    • Error bars now stay aligned with data points when a rolling window trims points, including when the maximum point count is lowered.
    • Per-point error values expire with their corresponding points, while error-bar settings remain unchanged when no points are trimmed.

Include error_x, error_y and error_z arrays and arrayminus values in
max_points trimming so retained scatter points keep their matching errors
and discarded error values are released.

Cover creation, lowering the limit, incremental append patches, disabled
limits and scalar error settings across scatter, scattergl and scatter3d.
@sourcery-ai

sourcery-ai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Implementation

Add error-bar array paths to the existing rolling-point trimming list so error_x, error_y, and error_z values are trimmed with their corresponding points.

  • py/visdom/utils/server_utils.py L771-776

Tests

Add regression coverage for error-bar alignment during creation, limit changes, and append patches, along with unchanged behavior when limits do not expire points or errors are scalar.

  • py/tests/unit/update_broadcast.py L1031-1120

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Point-array trimming now includes error-bar arrays for x, y, and z traces. Tests cover their alignment with retained points and preservation of scalar error settings.

Changes: Error-array rolling-window trimming

Layer / File(s) Summary
Include error arrays in trimming paths
py/visdom/utils/server_utils.py
POINT_ARRAY_PATHS now includes array and arrayminus for the x, y, and z error-bar attributes.
Check error arrays during rolling-window updates
py/tests/unit/update_broadcast.py
Tests cover trimming on pane creation, limit changes, and appends. They also check that arrays remain unchanged when no points expire and that scalar error settings are preserved.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

Possibly related PRs

  • fossasia/visdom#2170: This PR extends the max_points trimming paths introduced for line and scatter plots to include error-bar arrays.

Suggested reviewers: jayantparashar10, manik-khajuria-5

Merge Risk: Minimal · up to 6b271

Rolling-window plots now trim error-bar arrays together with their points. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "fix: trim error bars with rolling plot points" matches the main change. The PR adds the array and arrayminus paths for error_x, error_y, and error_z to the opts.max_points trimming list, so…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix: trim error bars with rolling plot points" matches the main change. The PR adds the array and arrayminus paths for error_x, error_y, and error_z to the opts.max_points trimming list, so error values stay aligned with retained points when a rolling window drops old points. The title is concise and specific, and it names the fix and its scope.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9b785055-abd8-42f8-8bf2-515328fc217e
Commits

Reviewing files that changed from the base of the PR and between e2a46ef and 6b271f0.

Files selected for processing: 2

  • py/tests/unit/update_broadcast.py
  • py/visdom/utils/server_utils.py

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues

Sourcery assessment

Approval pending. 2 findings to address first.

Blocking findings: py/visdom/utils/server_utils.py:773, py/tests/unit/update_broadcast.py:1118


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

("ids",),
("error_x", "array"),
("error_x", "arrayminus"),
("error_y", "array"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Appended points lose their errors

When an incremental append supplies data-based error bars, UpdateHandler.update appends coordinates but not the incoming trace’s error arrays, so trim_plot_points can only trim the old errors; newly appended points have no matching error bars.

Append each incoming error array and arrayminus alongside its corresponding points, and include those additions in the generated patch.

errors = {"type": error_type, "value": 5, "valueminus": 2, "symmetric": False}
trace["error_y"] = copy.deepcopy(errors)
pane = window(window_args(data=[trace], opts={"max_points": 1}))
assert pane["content"]["data"][0]["error_y"] == errors

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Scalar test misses skipped trimming

When the rolling trimmer skips the trace, test_rolling_points_preserve_scalar_error_settings only compares error_y with its input at line 1118, so a trimmer that does nothing leaves the assertion passing even though the points were not rolled.

Also assert that the trace coordinates contain only the retained point.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants