Skip to content

Add Plot2D.reset_tile_band, to re-derive the tile band when the dataset changes - #89

Merged
CSSFrancis merged 3 commits into
mainfrom
feat/public-disable-tile
Dec 3, 2026
Merged

CSSFrancis merged 3 commits into
mainfrom
feat/public-disable-tile

Conversation

@CSSFrancis

Copy link
Copy Markdown
Owner

Summary

Tile mode encodes pixels to 8 bits over a band (raw_min/raw_max) that it fixes from the first frame and then holds, so a contrast change is only a LUT re-window. Every later frame on a tiled plot keeps that band, smaller frames included.

That's right while the frames come from one source, and wrong when a host switches the plot to a different dataset. In SpyDE, binning the detector 4 × 4 gives 16 times the counts:

  • every pixel clipped to the top code;
  • the display window set for the binned frames then drew them black.

A coworker reported this as "binning the data still turns the signal black". The SpyDE fix (directelectron/spyde#270) currently reaches into the private _disable_tile() to escape the held band.

Plot2D.reset_tile_band() clears the band.

  • The next set_data or update_tile_source derives it from the new frame, through the existing _ensure_tile_band.
  • Tile mode, the zoom and the detail tile are kept.
  • It's a no-op off tile mode.
  • It complements set_tile_band (pin a known range) with "forget the range, take the next frame's".

Tests

TestResetTileBand in test_tiled_imshow.py:

  • without a reset, a 16× brighter frame keeps the old band (pins the behaviour this addresses);
  • after a reset, the next frame brings its own band, for a same-size frame (2048²) and a smaller one (512²);
  • the pixels are re-encoded, and tile mode stays on;
  • off tile mode it is a no-op.

test_tiled_imshow.py, test_display_window.py, test_detail_tile.py and test_tile_backend.py: 125 passed.

…et changes

Tile mode encodes pixels to 8 bits over a band fixed from the first frame
and then held, so a contrast change is a LUT re-window. Every later frame
on a tiled plot keeps that band, a smaller one too. When a host switches
the plot to a different dataset that is wrong: SpyDE's detector binned
4 x 4 has 16 times the counts, every pixel clipped to the top code, and
the display window set for the binned frames drew them black.

reset_tile_band() clears the band; the next set_data or
update_tile_source derives it from the new frame through the existing
_ensure_tile_band. Tile mode, the zoom and the detail tile are kept. A
no-op off tile mode. SpyDE can then stop calling _disable_tile().
CSSFrancis added a commit to directelectron/spyde that referenced this pull request Dec 3, 2026
CSSFrancis/anyplotlib#89 adds Plot2D.reset_tile_band, which clears the held band and keeps tile mode, the zoom and the detail tile. The plot uses it on a node switch, and leaves tile mode (the private _disable_tile) only with an anyplotlib that predates it. Both pass test_rebin_display_band.py; with #89 the rebin, tile, LOD, viewport and movie tests pass (164) and the app check shows the 2 x 2 and 4 x 4 bins correctly.
…ls Chromium

ubuntu-latest became Ubuntu 26.04, and `playwright install chromium
--with-deps` (Playwright 1.58.0) refuses it: "Playwright does not support
chromium on ubuntu26.04-x64". Every Linux test job and the docs build
failed at that step before a test ran. Pinning the runners that install
Playwright keeps the browser and the screenshot baselines as they are;
lift the pin when a Playwright release supports 26.04.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.08%. Comparing base (a8aec72) to head (2015b40).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #89   +/-   ##
=======================================
  Coverage   92.07%   92.08%           
=======================================
  Files          42       42           
  Lines        5489     5493    +4     
=======================================
+ Hits         5054     5058    +4     
  Misses        435      435           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@CSSFrancis
CSSFrancis merged commit 6902db5 into main Dec 3, 2026
12 checks passed
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