From 4c69cd6680621243c00ba1b9991c28e9a378ba0a Mon Sep 17 00:00:00 2001 From: Derek Homeier Date: Tue, 18 Jul 2023 19:04:49 +0200 Subject: [PATCH] Tests for 'bqplot:truecircle' and 'bqplot:ellipse' --- glue_jupyter/bqplot/tests/test_bqplot.py | 36 +++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/glue_jupyter/bqplot/tests/test_bqplot.py b/glue_jupyter/bqplot/tests/test_bqplot.py index 4e68712c..2d5adee7 100644 --- a/glue_jupyter/bqplot/tests/test_bqplot.py +++ b/glue_jupyter/bqplot/tests/test_bqplot.py @@ -4,7 +4,7 @@ from numpy.testing import assert_allclose from nbconvert.preprocessors import ExecutePreprocessor from glue.core import Data -from glue.core.roi import EllipticalROI +from glue.core.roi import CircularROI, EllipticalROI DATA = os.path.join(os.path.dirname(__file__), 'data') @@ -270,6 +270,40 @@ def test_imshow_circular_brush(app, data_image): assert_allclose(roi.radius_y, 273.25) +def test_imshow_true_circular_brush(app, data_image): + + v = app.imshow(data=data_image) + v.state.aspect = 'auto' + + tool = v.toolbar.tools['bqplot:truecircle'] + tool.activate() + tool.interact.brushing = True + tool.interact.selected = [(1.5, 3.5), (300.5, 550)] + tool.interact.brushing = False + + roi = data_image.subsets[0].subset_state.roi + assert isinstance(roi, CircularROI) + assert_allclose(roi.xc, 151.00) + assert_allclose(roi.yc, 276.75) + assert_allclose(roi.radius, 220.2451) + + +def test_imshow_elliptical_brush(app, data_image): + v = app.imshow(data=data_image) + v.state.aspect = 'auto' + + tool = v.toolbar.tools['bqplot:ellipse'] + tool.activate() + tool.interact.brushing = True + tool.interact.selected = [(1.5, 3.5), (300.5, 550)] + tool.interact.brushing = False + + roi = data_image.subsets[0].subset_state.roi + assert isinstance(roi, EllipticalROI) + assert_allclose(roi.xc, 151.00) + assert_allclose(roi.yc, 276.75) + + def test_imshow_equal_aspect(app, data_image): data = Data(array=np.random.random((100, 5))) app.data_collection.append(data)