Skip to content

Commit

Permalink
Added regression test for bug that caused image viewer to turn green …
Browse files Browse the repository at this point in the history
…when an incompatible subset was present
  • Loading branch information
astrofrog committed Oct 23, 2023
1 parent 0b1a3fb commit c1eae87
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions glue_jupyter/bqplot/image/tests/test_visual.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import numpy as np

from glue_jupyter import jglue
from glue_jupyter.tests.helpers import visual_widget_test


@visual_widget_test
def test_visual_incompatible_subset(
tmp_path,
page_session,
solara_test,
):

# Regression test for a bug that caused incompatible subsets
# to make the whole image green.

np.random.seed(12345)
im = np.random.random((64, 64))
x = np.random.normal(3, 1, 100)
y = np.random.normal(2, 1.5, 100)

app = jglue()
data1 = app.add_data(image={"image": im})[0]
data2 = app.add_data(catalog={"x": x, "y": y})[0]
scatter = app.imshow(data=data1, show=False)
state1 = data1.pixel_component_ids[1] > 32
app.data_collection.new_subset_group('image[x] > 32', state1)
state2 = data2.id['x'] > 1
app.data_collection.new_subset_group('x > 1', state2)
figure = scatter.figure_widget
figure.layout = {"width": "400px", "height": "250px"}
return figure
1 change: 1 addition & 0 deletions glue_jupyter/tests/images/py311-test-visual.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"glue_jupyter.bqplot.scatter.tests.test_visual.test_visual_scatter2d[chromium]": "edd4e65c87369bc6e403f45e87d914223bc13f42c2f90a55535614923e233c00",
"glue_jupyter.bqplot.scatter.tests.test_visual.test_visual_scatter2d_density[chromium]": "60f38b822f89603874cd508e0c320db92185129631dd89a58624dd667eb8a5a7"
"glue_jupyter.bqplot.scatter.tests.test_visual.test_visual_incompatible_subset[chromium]": "60f38b822f89603874cd508e0c320db92185129631dd89a58624dd667eb8a5a7"
}

0 comments on commit c1eae87

Please sign in to comment.