@@ -514,6 +514,39 @@ def test_cuts(self, data):
514514 assert isinstance (self .image .get_cuts (), ManualInterval )
515515 assert self .image .get_cuts ().get_limits (data ) == (10 , 100 )
516516
517+ def test_stretch_cuts_labels (self , data ):
518+ # Check that stretch and cuts can be set with labels
519+ self .image .load_image (data , image_label = 'test' )
520+
521+ # Set stretch and cuts with labels
522+ self .image .set_stretch (LogStretch (), image_label = 'test' )
523+ self .image .set_cuts ((10 , 100 ), image_label = 'test' )
524+
525+ # Get stretch and cuts with labels
526+ stretch = self .image .get_stretch (image_label = 'test' )
527+ cuts = self .image .get_cuts (image_label = 'test' )
528+
529+ assert isinstance (stretch , LogStretch )
530+ assert isinstance (cuts , ManualInterval )
531+ assert cuts .get_limits (data ) == (10 , 100 )
532+
533+ def test_stretch_cuts_errors (self , data ):
534+ # Check that errors are raised when trying to get or set stretch or cuts
535+ # for an image label that does not exist.
536+ self .image .load_image (data , image_label = 'test' )
537+
538+ with pytest .raises (ValueError , match = '[Ii]mage label.*not found' ):
539+ self .image .get_stretch (image_label = 'not a valid label' )
540+
541+ with pytest .raises (ValueError , match = '[Ii]mage label.*not found' ):
542+ self .image .get_cuts (image_label = 'not a valid label' )
543+
544+ with pytest .raises (ValueError , match = '[Ii]mage label.*not found' ):
545+ self .image .set_stretch (LogStretch (), image_label = 'not a valid label' )
546+
547+ with pytest .raises (ValueError , match = '[Ii]mage label.*not found' ):
548+ self .image .set_cuts ((10 , 100 ), image_label = 'not a valid label' )
549+
517550 @pytest .mark .skip (reason = "Not clear whether colormap is part of the API" )
518551 def test_colormap (self ):
519552 cmap_desired = 'gray'
0 commit comments