Skip to content

Commit ec18ed7

Browse files
committed
Modify stretch/cuts tests to use image labels
1 parent 1851b70 commit ec18ed7

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/astro_image_display_api/widget_api_test.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,39 @@ def test_cuts(self, data):
670670
assert isinstance(self.image.get_cuts(), ManualInterval)
671671
assert self.image.get_cuts().get_limits(data) == (10, 100)
672672

673+
def test_stretch_cuts_labels(self, data):
674+
# Check that stretch and cuts can be set with labels
675+
self.image.load_image(data, image_label='test')
676+
677+
# Set stretch and cuts with labels
678+
self.image.set_stretch(LogStretch(), image_label='test')
679+
self.image.set_cuts((10, 100), image_label='test')
680+
681+
# Get stretch and cuts with labels
682+
stretch = self.image.get_stretch(image_label='test')
683+
cuts = self.image.get_cuts(image_label='test')
684+
685+
assert isinstance(stretch, LogStretch)
686+
assert isinstance(cuts, ManualInterval)
687+
assert cuts.get_limits(data) == (10, 100)
688+
689+
def test_stretch_cuts_errors(self, data):
690+
# Check that errors are raised when trying to get or set stretch or cuts
691+
# for an image label that does not exist.
692+
self.image.load_image(data, image_label='test')
693+
694+
with pytest.raises(ValueError, match='[Ii]mage label.*not found'):
695+
self.image.get_stretch(image_label='not a valid label')
696+
697+
with pytest.raises(ValueError, match='[Ii]mage label.*not found'):
698+
self.image.get_cuts(image_label='not a valid label')
699+
700+
with pytest.raises(ValueError, match='[Ii]mage label.*not found'):
701+
self.image.set_stretch(LogStretch(), image_label='not a valid label')
702+
703+
with pytest.raises(ValueError, match='[Ii]mage label.*not found'):
704+
self.image.set_cuts((10, 100), image_label='not a valid label')
705+
673706
@pytest.mark.skip(reason="Not clear whether colormap is part of the API")
674707
def test_colormap(self):
675708
cmap_desired = 'gray'

0 commit comments

Comments
 (0)