Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added regression test for bug that caused image viewer to turn green when an incompatible subset was present #404

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)

Check warning on line 20 in glue_jupyter/bqplot/image/tests/test_visual.py

Codecov / codecov/patch

glue_jupyter/bqplot/image/tests/test_visual.py#L17-L20

Added lines #L17 - L20 were not covered by tests

app = jglue()
data1 = app.add_data(image={"image": im})[0]
data2 = app.add_data(catalog={"x": x, "y": y})[0]
image = 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 = image.figure_widget
figure.layout = {"width": "400px", "height": "250px"}
return figure

Check warning on line 32 in glue_jupyter/bqplot/image/tests/test_visual.py

Codecov / codecov/patch

glue_jupyter/bqplot/image/tests/test_visual.py#L22-L32

Added lines #L22 - L32 were not covered by tests
3 changes: 3 additions & 0 deletions glue_jupyter/tests/helpers.py
Original file line number Diff line number Diff line change
@@ -49,6 +49,9 @@
viewer = page_session.locator(".test-viewer")
viewer.wait_for()

# Wait for an additional 2 seconds
page_session.wait_for_timeout(2000)

Check warning on line 53 in glue_jupyter/tests/helpers.py

Codecov / codecov/patch

glue_jupyter/tests/helpers.py#L53

Added line #L53 was not covered by tests

screenshot = viewer.screenshot()

return DummyFigure(screenshot)
3 changes: 2 additions & 1 deletion 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_scatter2d_density[chromium]": "60f38b822f89603874cd508e0c320db92185129631dd89a58624dd667eb8a5a7",
"glue_jupyter.bqplot.image.tests.test_visual.test_visual_incompatible_subset[chromium]": "5cb824b79af81ff2fbec1367bf206f11b428076a361745b1fef2e61d912d457d"
}