Skip to content

Bqplot with new api - #191

Merged
mwcraig merged 6 commits into
astropy:mainfrom
mwcraig:bqplot_with_new_api
Jul 11, 2025
Merged

mwcraig merged 6 commits into
astropy:mainfrom
mwcraig:bqplot_with_new_api

Conversation

@mwcraig

@mwcraig mwcraig commented Jul 11, 2025

Copy link
Copy Markdown
Member

I'm hoping to get this merged in an hour or so and release it even though it is not really totally ready and it comments out the ginga import.

@mwcraig
mwcraig requested a review from Copilot July 11, 2025 19:20

Copilot AI 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.

Pull Request Overview

Introduce a new bqplot-based backend for the ImageViewerInterface, add tests, and disable the legacy ginga import.

  • Add full bqplot implementation in astrowidgets/bqplot.py
  • Add basic instantiation and interface tests for the new ImageWidget
  • Update setup.cfg to suppress unavoidable warnings and comment out the ginga import in __init__.py

Reviewed Changes

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

File Description
setup.cfg Ignore specific DeprecationWarning/UserWarning from traitlets
astrowidgets/tests/test_widget_api_bqplot.py Add instantiation and interface tests for ImageWidget
astrowidgets/bqplot.py Implement bqplot backend, plotting, zoom, pan, and save APIs
astrowidgets/init.py Comment out import of the ginga backend
Comments suppressed due to low confidence (1)

astrowidgets/tests/test_widget_api_bqplot.py:1

  • [nitpick] Tests currently cover only instantiation and interface conformance. Consider adding tests for image loading, colormap setting, and marker plotting to ensure core behaviors of the new backend are covered.
import pytest

Comment thread astrowidgets/bqplot.py
Comment thread astrowidgets/bqplot.py
Comment thread astrowidgets/bqplot.py
Comment on lines +300 to +302
# The width is used here but the height could be used instead
# and the result would be the same since the pixels are square.
scale_width = self.scale_widths[1]

Copilot AI Jul 11, 2025

Copy link

Choose a reason for hiding this comment

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

get_current_width uses scale_widths[1], which is the vertical height, not the horizontal width. Use scale_widths[0] to return the horizontal dimension.

Suggested change
# The width is used here but the height could be used instead
# and the result would be the same since the pixels are square.
scale_width = self.scale_widths[1]
# The width is used here and matches the horizontal dimension.
# Using the correct index ensures clarity and consistency with the docstring.
scale_width = self.scale_widths[0]

Copilot uses AI. Check for mistakes.
Comment thread astrowidgets/bqplot.py
Comment on lines +508 to +511
# THIS IS TERRIBLE AND MAKES THINGS SUPER LAGGY!!!! Needs to be
# throttled or something. Look at the ImageGL observe options.
x_scale.observe(update_zoom_level, names='max')

Copilot AI Jul 11, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] This comment is very emphatic and suggests a temporary workaround. Consider implementing proper throttling or a more controlled observer to avoid performance issues and remove the all-caps emphasis.

Suggested change
# THIS IS TERRIBLE AND MAKES THINGS SUPER LAGGY!!!! Needs to be
# throttled or something. Look at the ImageGL observe options.
x_scale.observe(update_zoom_level, names='max')
# Observing changes to the x scale without throttling can cause
# performance issues. Implementing throttling or debouncing is necessary.
x_scale.observe(self._throttled_update_zoom_level(), names='max')
def _throttled_update_zoom_level(self, func, delay=0.1):
"""
Throttle the update_zoom_level function to prevent frequent calls.
"""
last_call_time = [0]
def wrapper(event):
current_time = time.time()
if current_time - last_call_time[0] > delay:
last_call_time[0] = current_time
func(event)
return wrapper

Copilot uses AI. Check for mistakes.
@mwcraig
mwcraig merged commit afb04e8 into astropy:main Jul 11, 2025
@mwcraig
mwcraig deleted the bqplot_with_new_api branch July 11, 2025 20:52
@mwcraig mwcraig mentioned this pull request Jul 18, 2025
mwcraig added a commit to mwcraig/astrowidgets that referenced this pull request Sep 13, 2025
mwcraig added a commit to mwcraig/astrowidgets that referenced this pull request Sep 13, 2025
mwcraig added a commit that referenced this pull request Sep 15, 2025
A few minor changes in response to the copilot review of #191
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