From ff50e22fe1d8843e993ad9a136804534175f9b1d Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Mon, 23 Sep 2024 15:10:00 -0400 Subject: [PATCH] Add tests --- glue/viewers/profile/tests/test_state.py | 34 +++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/glue/viewers/profile/tests/test_state.py b/glue/viewers/profile/tests/test_state.py index c574558db..843b021f9 100644 --- a/glue/viewers/profile/tests/test_state.py +++ b/glue/viewers/profile/tests/test_state.py @@ -149,7 +149,7 @@ def test_limits(self): assert self.viewer_state.x_min == -0.5 assert self.viewer_state.x_max == 2.5 - + def test_visible(self): self.layer_state.visible = False @@ -161,3 +161,35 @@ def test_visible(self): x, y = self.layer_state.profile assert_allclose(x, [0, 2, 4]) assert_allclose(y, [3.5, 11.5, 19.5]) + + +def test_limits_profile_y_zero(): + data = Data(label='d1') + data.coords = SimpleCoordinates() + data['x'] = np.zeros(24).reshape((3, 4, 2)).astype(float) + + data_collection = DataCollection([data]) + + viewer_state = ProfileViewerState() + layer_state = ProfileLayerState(viewer_state=viewer_state, layer=data) + viewer_state.layers.append(layer_state) + viewer_state.function = 'mean' + + assert viewer_state.y_min == -1e-30 + assert viewer_state.y_max == 1e-30 + + +def test_limits_profile_y_one(): + data = Data(label='d1') + data.coords = SimpleCoordinates() + data['x'] = np.ones(24).reshape((3, 4, 2)).astype(float) + + data_collection = DataCollection([data]) + + viewer_state = ProfileViewerState() + layer_state = ProfileLayerState(viewer_state=viewer_state, layer=data) + viewer_state.layers.append(layer_state) + viewer_state.function = 'mean' + + assert viewer_state.y_min == -0.1 + assert viewer_state.y_max == 0.1