Skip to content

Commit

Permalink
Tests for 'bqplot:truecircle' and 'bqplot:ellipse'
Browse files Browse the repository at this point in the history
  • Loading branch information
dhomeier committed Jul 18, 2023
1 parent 186ef0e commit 4c69cd6
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion glue_jupyter/bqplot/tests/test_bqplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4c69cd6

Please sign in to comment.