<s> import unittest <EOL> import IECore <EOL> import Gaffer <EOL> import GafferTest <EOL> import GafferImage <EOL> import GafferImageTest <EOL> class ShuffleTest ( GafferImageTest . ImageTestCase ) : <EOL> def test ( self ) : <EOL> c = GafferImage . Constant ( ) <EOL> c [ "<STR_LIT>" ] . setValue ( GafferImage . Format ( IECore . Box2i ( IECore . V2i ( <NUM_LIT:0> ) , IECore . V2i ( <NUM_LIT> ) ) , <NUM_LIT:1> ) ) <EOL> c [ "<STR_LIT>" ] . setValue ( IECore . Color4f ( <NUM_LIT:1> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:1> ) ) <EOL> s = GafferImage . Shuffle ( ) <EOL> s [ "<STR_LIT>" ] . setInput ( c [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( s [ "<STR_LIT>" ] . image ( ) , c [ "<STR_LIT>" ] . image ( ) ) <EOL> for outName , inName in [ ( "<STR_LIT:R>" , "<STR_LIT:R>" ) , ( "<STR_LIT>" , "<STR_LIT>" ) , ( "<STR_LIT:B>" , "<STR_LIT:B>" ) , ( "<STR_LIT:A>" , "<STR_LIT:A>" ) ] : <EOL> self . assertEqual ( <EOL> s [ "<STR_LIT>" ] . channelDataHash ( outName , IECore . V2i ( <NUM_LIT:0> ) ) , <EOL> c [ "<STR_LIT>" ] . channelDataHash ( inName , IECore . V2i ( <NUM_LIT:0> ) ) , <EOL> ) <EOL> self . assertTrue ( <EOL> s [ "<STR_LIT>" ] . channelData ( outName , IECore . V2i ( <NUM_LIT:0> ) , _copy = False ) . isSame ( <EOL> c [ "<STR_LIT>" ] . channelData ( inName , IECore . V2i ( <NUM_LIT:0> ) , _copy = False ) <EOL> ) <EOL> ) <EOL> s [ "<STR_LIT>" ] . addChild ( s . ChannelPlug ( "<STR_LIT:R>" , "<STR_LIT>" ) ) <EOL> s [ "<STR_LIT>" ] . addChild ( s . ChannelPlug ( "<STR_LIT>" , "<STR_LIT:B>" ) ) <EOL> s [ "<STR_LIT>" ] . addChild ( s . ChannelPlug ( "<STR_LIT:B>" , "<STR_LIT:A>" ) ) <EOL> s [ "<STR_LIT>" ] . addChild ( s . ChannelPlug ( "<STR_LIT:A>" , "<STR_LIT:R>" ) ) <EOL> for outName , inName in [ ( "<STR_LIT:R>" , "<STR_LIT>" ) , ( "<STR_LIT>" , "<STR_LIT:B>" ) , ( "<STR_LIT:B>" , "<STR_LIT:A>" ) , ( "<STR_LIT:A>" , "<STR_LIT:R>" ) ] : <EOL> self . assertEqual ( <EOL> s [ "<STR_LIT>" ] . channelDataHash ( outName , IECore . V2i ( <NUM_LIT:0> ) ) , <EOL> c [ "<STR_LIT>" ] . channelDataHash ( inName , IECore . V2i ( <NUM_LIT:0> ) ) , <EOL> ) <EOL> self . assertTrue ( <EOL> s [ "<STR_LIT>" ] . channelData ( outName , IECore . V2i ( <NUM_LIT:0> ) , _copy = False ) . isSame ( <EOL> c [ "<STR_LIT>" ] . channelData ( inName , IECore . V2i ( <NUM_LIT:0> ) , _copy = False ) <EOL> ) <EOL> ) <EOL> def testAddConstantChannel ( self ) : <EOL> s = GafferImage . Shuffle ( ) <EOL> self . assertEqual ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . StringVectorData ( [ "<STR_LIT:R>" , "<STR_LIT>" , "<STR_LIT:B>" ] ) ) <EOL> s [ "<STR_LIT>" ] . addChild ( s . ChannelPlug ( "<STR_LIT:A>" , "<STR_LIT>" ) ) <EOL> self . assertEqual ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . StringVectorData ( [ "<STR_LIT:R>" , "<STR_LIT>" , "<STR_LIT:B>" , "<STR_LIT:A>" ] ) ) <EOL> self . assertEqual ( s [ "<STR_LIT>" ] . channelData ( "<STR_LIT:A>" , IECore . V2i ( <NUM_LIT:0> ) ) [ <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> self . assertTrue ( <EOL> s [ "<STR_LIT>" ] . channelData ( "<STR_LIT:A>" , IECore . V2i ( <NUM_LIT:0> ) , _copy = False ) . isSame ( <EOL> s [ "<STR_LIT>" ] . channelData ( "<STR_LIT:A>" , IECore . V2i ( s [ "<STR_LIT>" ] . tileSize ( ) ) , _copy = False ) <EOL> ) <EOL> ) <EOL> def testSerialisation ( self ) : <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT>" ] = GafferImage . Shuffle ( ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . addChild ( GafferImage . Shuffle . ChannelPlug ( "<STR_LIT:R>" , "<STR_LIT>" ) ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . addChild ( GafferImage . Shuffle . ChannelPlug ( "<STR_LIT>" , "<STR_LIT:B>" ) ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . addChild ( GafferImage . Shuffle . ChannelPlug ( "<STR_LIT:B>" , "<STR_LIT:R>" ) ) <EOL> s2 = Gaffer . ScriptNode ( ) <EOL> s2 . execute ( s . serialise ( ) ) <EOL> self . assertTrue ( len ( s2 [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( s2 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT:R>" ) <EOL> self . assertEqual ( s2 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( s2 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( s2 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT:B>" ) <EOL> self . assertEqual ( s2 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:2> ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT:B>" ) <EOL> self . assertEqual ( s2 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:2> ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT:R>" ) <EOL> s3 = Gaffer . ScriptNode ( ) <EOL> s3 . execute ( s2 . serialise ( ) ) <EOL> self . assertTrue ( len ( s3 [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( s3 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT:R>" ) <EOL> self . assertEqual ( s3 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( s3 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( s3 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT:B>" ) <EOL> self . assertEqual ( s3 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:2> ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT:B>" ) <EOL> self . assertEqual ( s3 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:2> ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT:R>" ) <EOL> def testCreateCounterpart ( self ) : <EOL> p = GafferImage . Shuffle . ChannelPlug ( ) <EOL> p2 = p . createCounterpart ( "<STR_LIT>" , p . Direction . Out ) <EOL> self . assertTrue ( isinstance ( p2 , GafferImage . Shuffle . ChannelPlug ) ) <EOL> self . assertTrue ( p2 . direction ( ) , p . Direction . Out ) <EOL> def testAffects ( self ) : <EOL> s = GafferImage . Shuffle ( ) <EOL> self . assertEqual ( s . affects ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) , [ s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ] ) <EOL> self . assertEqual ( s . affects ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) , [ s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ] ) <EOL> s [ "<STR_LIT>" ] . addChild ( s . ChannelPlug ( "<STR_LIT:R>" , "<STR_LIT>" ) ) <EOL> self . assertEqual ( s . affects ( s [ "<STR_LIT>" ] [ <NUM_LIT:0> ] [ "<STR_LIT>" ] ) , [ s [ "<STR_LIT>" ] [ "<STR_LIT>" ] , s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ] ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
