<s> import unittest <EOL> import Gaffer <EOL> import GafferTest <EOL> class TimeWarpComputeNodeTest ( GafferTest . TestCase ) : <EOL> def test ( self ) : <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT:m>" ] = GafferTest . MultiplyNode ( ) <EOL> s [ "<STR_LIT:m>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:1> ) <EOL> s [ "<STR_LIT:e>" ] = Gaffer . Expression ( ) <EOL> s [ "<STR_LIT:e>" ] . setExpression ( "<STR_LIT>" ) <EOL> s [ "<STR_LIT:w>" ] = Gaffer . TimeWarpComputeNode ( ) <EOL> s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] = Gaffer . IntPlug ( ) <EOL> s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT:m>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] = Gaffer . IntPlug ( direction = Gaffer . Plug . Direction . Out ) <EOL> s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:2> ) <EOL> s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:2> ) <EOL> for i in range ( <NUM_LIT:0> , <NUM_LIT:10> ) : <EOL> c = Gaffer . Context ( ) <EOL> c . setFrame ( i ) <EOL> with c : <EOL> self . assertEqual ( s [ "<STR_LIT:m>" ] [ "<STR_LIT>" ] . getValue ( ) , i ) <EOL> self . assertEqual ( s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] . getValue ( ) , i * <NUM_LIT:2> + <NUM_LIT:2> ) <EOL> def testHash ( self ) : <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT:m>" ] = GafferTest . MultiplyNode ( ) <EOL> s [ "<STR_LIT:m>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:1> ) <EOL> s [ "<STR_LIT:e>" ] = Gaffer . Expression ( ) <EOL> s [ "<STR_LIT:e>" ] . setExpression ( "<STR_LIT>" ) <EOL> s [ "<STR_LIT:w>" ] = Gaffer . TimeWarpComputeNode ( ) <EOL> s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] = Gaffer . IntPlug ( ) <EOL> s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT:m>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] = Gaffer . IntPlug ( direction = Gaffer . Plug . Direction . Out ) <EOL> s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:2> ) <EOL> for i in range ( <NUM_LIT:0> , <NUM_LIT:10> ) : <EOL> c = Gaffer . Context ( ) <EOL> c . setFrame ( i ) <EOL> with c : <EOL> self . assertEqual ( s [ "<STR_LIT:m>" ] [ "<STR_LIT>" ] . getValue ( ) , i ) <EOL> self . assertEqual ( s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] . getValue ( ) , i + <NUM_LIT:2> ) <EOL> wh = s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] . hash ( ) <EOL> c . setFrame ( i + <NUM_LIT:2> ) <EOL> with c : <EOL> mh = s [ "<STR_LIT:m>" ] [ "<STR_LIT>" ] . hash ( ) <EOL> self . assertEqual ( wh , mh ) <EOL> def testAffects ( self ) : <EOL> w = Gaffer . TimeWarpComputeNode ( ) <EOL> w [ "<STR_LIT>" ] = Gaffer . IntPlug ( ) <EOL> w [ "<STR_LIT>" ] = Gaffer . IntPlug ( direction = Gaffer . Plug . Direction . Out ) <EOL> cs = GafferTest . CapturingSlot ( w . plugDirtiedSignal ( ) ) <EOL> w [ "<STR_LIT>" ] . setValue ( <NUM_LIT:10> ) <EOL> self . assertEqual ( len ( cs ) , <NUM_LIT:2> ) <EOL> self . assertTrue ( cs [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] . isSame ( w [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( cs [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] . isSame ( w [ "<STR_LIT>" ] ) ) <EOL> def testEnabled ( self ) : <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT:m>" ] = GafferTest . MultiplyNode ( ) <EOL> s [ "<STR_LIT:m>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:1> ) <EOL> s [ "<STR_LIT:e>" ] = Gaffer . Expression ( ) <EOL> s [ "<STR_LIT:e>" ] . setExpression ( "<STR_LIT>" ) <EOL> s [ "<STR_LIT:w>" ] = Gaffer . TimeWarpComputeNode ( ) <EOL> s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] = Gaffer . IntPlug ( ) <EOL> s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT:m>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] = Gaffer . IntPlug ( direction = Gaffer . Plug . Direction . Out ) <EOL> s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:2> ) <EOL> self . assertTrue ( s [ "<STR_LIT:w>" ] . enabledPlug ( ) . isSame ( s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( s [ "<STR_LIT:w>" ] . correspondingInput ( s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] ) . isSame ( s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] ) ) <EOL> s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] . setValue ( False ) <EOL> for i in range ( <NUM_LIT:0> , <NUM_LIT:10> ) : <EOL> with Gaffer . Context ( ) as c : <EOL> c . setFrame ( i ) <EOL> self . assertEqual ( s [ "<STR_LIT:m>" ] [ "<STR_LIT>" ] . getValue ( ) , s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] . getValue ( ) ) <EOL> self . assertEqual ( s [ "<STR_LIT:m>" ] [ "<STR_LIT>" ] . hash ( ) , s [ "<STR_LIT:w>" ] [ "<STR_LIT>" ] . hash ( ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
