Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pllim authored Sep 23, 2024
1 parent a4a87f8 commit ff50e22
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion glue/viewers/profile/tests/test_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit ff50e22

Please sign in to comment.