<s> import unittest <EOL> import IECore <EOL> import GafferTest <EOL> import GafferImage <EOL> import GafferImageTest <EOL> class ImageAlgoTest ( GafferImageTest . ImageTestCase ) : <EOL> def testLayerName ( self ) : <EOL> for channelName , layerName in [ <EOL> ( "<STR_LIT:R>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT:A>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT:left>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT:right>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ] : <EOL> self . assertEqual ( GafferImage . layerName ( channelName ) , layerName ) <EOL> def testBaseName ( self ) : <EOL> for channelName , baseName in [ <EOL> ( "<STR_LIT:R>" , "<STR_LIT:R>" ) , <EOL> ( "<STR_LIT:A>" , "<STR_LIT:A>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT:R>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> ( "<STR_LIT>" , "<STR_LIT:R>" ) , <EOL> ] : <EOL> self . assertEqual ( GafferImage . baseName ( channelName ) , baseName ) <EOL> def testColorIndex ( self ) : <EOL> for channelName , index in [ <EOL> ( "<STR_LIT:R>" , <NUM_LIT:0> ) , <EOL> ( "<STR_LIT>" , <NUM_LIT:1> ) , <EOL> ( "<STR_LIT:B>" , <NUM_LIT:2> ) , <EOL> ( "<STR_LIT:A>" , <NUM_LIT:3> ) , <EOL> ( "<STR_LIT>" , - <NUM_LIT:1> ) , <EOL> ( "<STR_LIT>" , - <NUM_LIT:1> ) , <EOL> ( "<STR_LIT>" , <NUM_LIT:0> ) , <EOL> ( "<STR_LIT>" , <NUM_LIT:1> ) , <EOL> ( "<STR_LIT>" , <NUM_LIT:2> ) , <EOL> ( "<STR_LIT>" , <NUM_LIT:3> ) , <EOL> ( "<STR_LIT>" , - <NUM_LIT:1> ) , <EOL> ( "<STR_LIT>" , - <NUM_LIT:1> ) , <EOL> ( "<STR_LIT>" , <NUM_LIT:0> ) , <EOL> ( "<STR_LIT>" , <NUM_LIT:1> ) , <EOL> ( "<STR_LIT>" , <NUM_LIT:2> ) , <EOL> ( "<STR_LIT>" , <NUM_LIT:3> ) , <EOL> ( "<STR_LIT>" , - <NUM_LIT:1> ) , <EOL> ] : <EOL> self . assertEqual ( GafferImage . colorIndex ( channelName ) , index ) <EOL> def testChannelExists ( self ) : <EOL> c = GafferImage . Constant ( ) <EOL> d = GafferImage . DeleteChannels ( ) <EOL> d [ "<STR_LIT>" ] . setInput ( c [ "<STR_LIT>" ] ) <EOL> d [ "<STR_LIT>" ] . setValue ( GafferImage . DeleteChannels . Mode . Delete ) <EOL> d [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ ] ) ) <EOL> self . assertTrue ( GafferImage . channelExists ( d [ "<STR_LIT>" ] , "<STR_LIT:R>" ) ) <EOL> self . assertTrue ( GafferImage . channelExists ( d [ "<STR_LIT>" ] , "<STR_LIT>" ) ) <EOL> self . assertTrue ( GafferImage . channelExists ( d [ "<STR_LIT>" ] , "<STR_LIT:B>" ) ) <EOL> self . assertTrue ( GafferImage . channelExists ( d [ "<STR_LIT>" ] , "<STR_LIT:A>" ) ) <EOL> for chan in [ "<STR_LIT:R>" , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT:A>" ] : <EOL> d [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ chan ] ) ) <EOL> self . assertFalse ( GafferImage . channelExists ( d [ "<STR_LIT>" ] , chan ) ) <EOL> def testChannelExistsBindings ( self ) : <EOL> c = GafferImage . Constant ( ) <EOL> d = GafferImage . DeleteChannels ( ) <EOL> d [ "<STR_LIT>" ] . setInput ( c [ "<STR_LIT>" ] ) <EOL> d [ "<STR_LIT>" ] . setValue ( GafferImage . DeleteChannels . Mode . Delete ) <EOL> d [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ "<STR_LIT:R>" , "<STR_LIT:A>" ] ) ) <EOL> for chan in [ "<STR_LIT:R>" , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT:A>" ] : <EOL> self . assertEqual ( GafferImage . channelExists ( d [ "<STR_LIT>" ] , chan ) , GafferImage . channelExists ( d [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , chan ) ) <EOL> def testParallelProcessEmptyDataWindow ( self ) : <EOL> d = GafferImage . Display ( ) <EOL> self . assertEqual ( d [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . Box2i ( ) ) <EOL> GafferImageTest . processTiles ( d [ "<STR_LIT>" ] ) <EOL> d [ "<STR_LIT>" ] . image ( ) <EOL> d [ "<STR_LIT>" ] . imageHash ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
