Skip to content

Commit

Permalink
Merge pull request #1 from dhomeier/pllim-fix-yminmax-same
Browse files Browse the repository at this point in the history
Parametrise yminmax-same-tests
  • Loading branch information
pllim authored Sep 23, 2024
2 parents a2f2710 + 10e04ad commit acffd4d
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions glue/viewers/profile/tests/test_state.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from glue.core.data_collection import DataCollection
import numpy as np
import pytest

from numpy.testing import assert_allclose

Expand Down Expand Up @@ -163,10 +164,14 @@ def test_visible(self):
assert_allclose(y, [3.5, 11.5, 19.5])


def test_limits_profile_y_zero():
@pytest.mark.parametrize(('value', 'limits'),
[(0, (-1e-30, 1e-30)),
(1, (0.9, 1.1)),
(-0.1, (-0.11, -0.09))])
def test_limits_profile_y_constant(value, limits):
data = Data(label='d1')
data.coords = SimpleCoordinates()
data['x'] = np.zeros(24).reshape((3, 4, 2)).astype(float)
data['x'] = np.ones(24).reshape((3, 4, 2)).astype(float) * value

data_collection = DataCollection([data])

Expand All @@ -175,21 +180,4 @@ def test_limits_profile_y_zero():
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.9
assert viewer_state.y_max == 1.1
assert_allclose((viewer_state.y_min, viewer_state.y_max), limits)

0 comments on commit acffd4d

Please sign in to comment.