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

Add visual test for ScatterRegionLayerArtist #2461

Merged
merged 4 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion glue/tests/visual/py311-test-visual.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"glue.viewers.histogram.tests.test_viewer.test_simple_viewer": "cb08123fbad135ab614bb7ec13475fcc83321057d884fe80c3a32970b2d14762",
"glue.viewers.image.tests.test_viewer.test_simple_viewer": "72abd60b484d14f721254f027bb0ab9b36245d5db77eb87693f4dd9998fd28be",
"glue.viewers.profile.tests.test_viewer.test_simple_viewer": "f68a21be5080fec513388b2d2b220512e7b0df5498e2489da54e58708de435b3",
"glue.viewers.scatter.tests.test_viewer.test_simple_viewer": "1020a7bd3abe40510b9e03047c3b423b75c3c64ac18e6dcd6257173cec1ed53f"
"glue.viewers.scatter.tests.test_viewer.test_simple_viewer": "1020a7bd3abe40510b9e03047c3b423b75c3c64ac18e6dcd6257173cec1ed53f",
"glue.viewers.image.tests.test_viewer.test_region_layer": "b54088d1f31562d309d35c5e90c0a382c7ba4c16cc0db8134e9532f71f047076"
}
36 changes: 36 additions & 0 deletions glue/viewers/image/tests/test_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
from glue.viewers.image.viewer import SimpleImageViewer
from glue.core.application_base import Application
from glue.core.data import Data
from glue.core.link_helpers import LinkSame
from glue.core.data_region import RegionData

from shapely.geometry import Polygon, MultiPolygon


@visual_test
Expand All @@ -25,3 +29,35 @@
app.data_collection.new_subset_group(label='subset1', subset_state=data1.pixel_component_ids[1] > 1.2)

return viewer.figure


@visual_test
def test_region_layer():
poly_1 = Polygon([(20, 20), (60, 20), (60, 40), (20, 40)])
poly_2 = Polygon([(60, 50), (60, 70), (80, 70), (80, 50)])
poly_3 = Polygon([(10, 10), (15, 10), (15, 15), (10, 15)])
poly_4 = Polygon([(10, 20), (15, 20), (15, 30), (10, 30), (12, 25)])

Check warning on line 39 in glue/viewers/image/tests/test_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue/viewers/image/tests/test_viewer.py#L36-L39

Added lines #L36 - L39 were not covered by tests

polygons = MultiPolygon([poly_3, poly_4])

Check warning on line 41 in glue/viewers/image/tests/test_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue/viewers/image/tests/test_viewer.py#L41

Added line #L41 was not covered by tests

geoms = np.array([poly_1, poly_2, polygons])
values = np.array([1, 2, 3])
region_data = RegionData(regions=geoms, values=values)

Check warning on line 45 in glue/viewers/image/tests/test_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue/viewers/image/tests/test_viewer.py#L43-L45

Added lines #L43 - L45 were not covered by tests

image_data = Data(x=np.arange(10000).reshape((100, 100)), label='data1')
app = Application()
app.data_collection.append(image_data)
app.data_collection.append(region_data)

Check warning on line 50 in glue/viewers/image/tests/test_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue/viewers/image/tests/test_viewer.py#L47-L50

Added lines #L47 - L50 were not covered by tests

link1 = LinkSame(region_data.center_x_id, image_data.pixel_component_ids[0])
link2 = LinkSame(region_data.center_y_id, image_data.pixel_component_ids[1])
app.data_collection.add_link(link1)
app.data_collection.add_link(link2)

Check warning on line 55 in glue/viewers/image/tests/test_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue/viewers/image/tests/test_viewer.py#L52-L55

Added lines #L52 - L55 were not covered by tests

viewer = app.new_data_viewer(SimpleImageViewer)
viewer.add_data(image_data)
viewer.add_data(region_data)

Check warning on line 59 in glue/viewers/image/tests/test_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue/viewers/image/tests/test_viewer.py#L57-L59

Added lines #L57 - L59 were not covered by tests

app.data_collection.new_subset_group(label='subset1', subset_state=region_data.id['values'] > 2)

Check warning on line 61 in glue/viewers/image/tests/test_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue/viewers/image/tests/test_viewer.py#L61

Added line #L61 was not covered by tests

return viewer.figure

Check warning on line 63 in glue/viewers/image/tests/test_viewer.py

View check run for this annotation

Codecov / codecov/patch

glue/viewers/image/tests/test_viewer.py#L63

Added line #L63 was not covered by tests