Skip to content

Commit

Permalink
move test_reset_limits into test_viewer.py
Browse files Browse the repository at this point in the history
  • Loading branch information
dhomeier committed Nov 14, 2023
1 parent 73ab9de commit 422cbe0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 43 deletions.
43 changes: 0 additions & 43 deletions glue/viewers/scatter/tests/test_state.py

This file was deleted.

35 changes: 35 additions & 0 deletions glue/viewers/scatter/tests/test_viewer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import numpy as np
from numpy.testing import assert_allclose

from glue.tests.visual.helpers import visual_test

from glue.viewers.scatter.viewer import SimpleScatterViewer
Expand All @@ -24,3 +27,35 @@ def test_simple_viewer():
app.data_collection.new_subset_group(label='subset1', subset_state=data1.id['x'] > 2)

return viewer.figure


def test_reset_limits():

data1 = Data(x=np.arange(1000), y=np.arange(1000) + 1000, label='data')

app = Application()
app.data_collection.append(data1)

viewer = app.new_data_viewer(SimpleScatterViewer)
viewer.add_data(data1)

viewer.state.reset_limits()

# Note that there is a margin included which is why the limits are not 0 to 999

assert_allclose(viewer.state.x_min, -39.96)
assert_allclose(viewer.state.x_max, 1038.96)

assert_allclose(viewer.state.y_min, 1000 - 39.96)
assert_allclose(viewer.state.y_max, 1000 + 1038.96)

viewer.state.x_limits_percentile = 90
viewer.state.y_limits_percentile = 80

viewer.state.reset_limits()

assert_allclose(viewer.state.x_min, 13.986)
assert_allclose(viewer.state.x_max, 985.014)

assert_allclose(viewer.state.y_min, 1000 + 67.932)
assert_allclose(viewer.state.y_max, 1000 + 931.068)

0 comments on commit 422cbe0

Please sign in to comment.