Skip to content

Fix bqplot some glitches in the bqplot implementation with the new API#202

Merged
mwcraig merged 5 commits into
astropy:mainfrom
mwcraig:fix-bqplot-import
Jul 3, 2026
Merged

Fix bqplot some glitches in the bqplot implementation with the new API#202
mwcraig merged 5 commits into
astropy:mainfrom
mwcraig:fix-bqplot-import

Conversation

@mwcraig

@mwcraig mwcraig commented Jun 27, 2026

Copy link
Copy Markdown
Member

There were a couple places where the bqplot widget gave some unexpected results:

  • Changing the stretch or cuts reset the viewport.
  • The viewport returned value get_viewport didn't reflect pans done in the browser.

mwcraig added 2 commits June 21, 2026 10:01
The bqplot GUI-change observer only watched the x scale's width and
synced fov, so interactive panning (which moves the scales without
changing their width) never updated the stored viewport center. A
vertical pan was missed entirely since only the x scale was observed.

Generalize the observer to read the live center and width and sync both
into the stored viewport, and observe the max of both the x and y scales
so horizontal pan, vertical pan, and zoom are all captured.

Co-written with Claude Opus 4.8
Claude-Session: https://claude.ai/code/session_014WXzFppCtXGddJv6rVgy68
@mwcraig mwcraig force-pushed the fix-bqplot-import branch from 995722e to 0a03017 Compare June 27, 2026 15:20
mwcraig added 2 commits June 27, 2026 10:33
set_cuts and set_stretch routed through _send_data, which defaults to
reset_view=True and so called reset_scale_to_fit_image -- refitting the
whole image to the display every time the cuts or stretch changed.
Adjusting the color mapping should not move the viewport.

Pass reset_view=False from both methods so only the color mapping
changes. load_image still uses the reset_view=True default so a freshly
loaded image is fit to the display.

Co-written with Claude Opus 4.8
Claude-Session: https://claude.ai/code/session_014WXzFppCtXGddJv6rVgy68

Bump minimum AIDA version

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses bqplot backend viewport inconsistencies with the newer astro-image-display-api, ensuring that color-mapping changes (stretch/cuts) don’t inadvertently reset pan/zoom, and that get_viewport() reflects interactive panning done in the browser.

Changes:

  • Track interactive pan/zoom by observing bqplot scale changes and syncing the stored viewport accordingly.
  • Prevent viewport reset when applying stretch or cuts by avoiding reset_view during data re-send.
  • Update the bqplot API test import path and add a regression test for interactive pan; add a new bqplot widget example notebook.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
setup.cfg Bumps minimum astro-image-display-api version to support the new API surface used by tests/docs.
astrowidgets/bqplot.py Syncs stored viewport with interactive pan/zoom and avoids resetting viewport on stretch/cuts changes.
astrowidgets/tests/test_widget_api_bqplot.py Updates ImageAPITest import and adds an interactive-pan viewport regression test.
example_notebooks/bqplot_widget.ipynb Adds a bqplot widget example notebook demonstrating the updated API usage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread astrowidgets/bqplot.py
Comment thread example_notebooks/bqplot_widget.ipynb Outdated
Comment thread example_notebooks/bqplot_widget.ipynb Outdated
Comment thread astrowidgets/tests/test_widget_api_bqplot.py
…ok typos

Initialize self._updating_viewport in __init__ so the scale observer's
re-entrancy guard is always defined, and fix two typos in the bqplot
example notebook ("witht he" -> "with the", "Maker" -> "Marker").

Co-written with Claude Opus 4.8
@mwcraig mwcraig requested review from eteq and pllim June 29, 2026 17:17
@pllim

pllim commented Jul 2, 2026

Copy link
Copy Markdown
Member

Who is affected by this? Should someone from Jdaviz review? I am not sure if I have opinions on this API.

@mwcraig

mwcraig commented Jul 2, 2026

Copy link
Copy Markdown
Member Author

I don't think anyone except me is affected by this, tbh....as far as I know I am the only user ever of the bqplot implementation. I think the jdaviz folks are writing/have written their own AIDA-compliant viewer in jdaviz. Happy to ping someone though -- usggestion?

@pllim

pllim commented Jul 2, 2026

Copy link
Copy Markdown
Member

In that case... merge when you want?

@mwcraig mwcraig merged commit 0450ce0 into astropy:main Jul 3, 2026
6 checks passed
@mwcraig mwcraig deleted the fix-bqplot-import branch July 3, 2026 13:28
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.

3 participants