<s> import os <EOL> import unittest <EOL> import IECore <EOL> import Gaffer <EOL> import GafferTest <EOL> import GafferScene <EOL> import GafferSceneTest <EOL> import GafferRenderMan <EOL> import GafferRenderManTest <EOL> class RenderManShaderTest ( GafferRenderManTest . RenderManTestCase ) : <EOL> def setUp ( self ) : <EOL> GafferRenderManTest . RenderManTestCase . setUp ( self ) <EOL> GafferRenderMan . RenderManShader . shaderLoader ( ) . clear ( ) <EOL> def test ( self ) : <EOL> n = GafferRenderMan . RenderManShader ( ) <EOL> n . loadShader ( "<STR_LIT>" ) <EOL> self . failUnless ( isinstance ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . FloatPlug ) ) <EOL> self . failUnless ( isinstance ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . FloatPlug ) ) <EOL> self . failUnless ( isinstance ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . FloatPlug ) ) <EOL> self . failUnless ( isinstance ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . FloatPlug ) ) <EOL> self . failUnless ( isinstance ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . Color3fPlug ) ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0.5> ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0.5> ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:1> ) <EOL> self . assertAlmostEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0.1> ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . Color3f ( <NUM_LIT:1> ) ) <EOL> def testSerialisation ( self ) : <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT:n>" ] = GafferRenderMan . RenderManShader ( ) <EOL> s [ "<STR_LIT:n>" ] . loadShader ( "<STR_LIT>" ) <EOL> ss = s . serialise ( ) <EOL> s = Gaffer . ScriptNode ( ) <EOL> s . execute ( ss ) <EOL> st = s [ "<STR_LIT:n>" ] . state ( ) <EOL> self . assertEqual ( len ( st ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( st [ <NUM_LIT:0> ] . type , "<STR_LIT>" ) <EOL> self . assertEqual ( st [ <NUM_LIT:0> ] . name , "<STR_LIT>" ) <EOL> self . failUnless ( isinstance ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . FloatPlug ) ) <EOL> self . failUnless ( isinstance ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . FloatPlug ) ) <EOL> self . failUnless ( isinstance ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . FloatPlug ) ) <EOL> self . failUnless ( isinstance ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . FloatPlug ) ) <EOL> self . failUnless ( isinstance ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . Color3fPlug ) ) <EOL> self . assertTrue ( "<STR_LIT>" not in s [ "<STR_LIT:n>" ] ) <EOL> def testShader ( self ) : <EOL> n = GafferRenderMan . RenderManShader ( ) <EOL> n . loadShader ( "<STR_LIT>" ) <EOL> s = n . state ( ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . type , "<STR_LIT>" ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . name , "<STR_LIT>" ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] , IECore . FloatData ( <NUM_LIT> ) ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] , IECore . FloatData ( <NUM_LIT> ) ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] , IECore . FloatData ( <NUM_LIT:1> ) ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] , IECore . FloatData ( <NUM_LIT> ) ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] , IECore . Color3fData ( IECore . Color3f ( <NUM_LIT:1> ) ) ) <EOL> def testShaderHash ( self ) : <EOL> n = GafferRenderMan . RenderManShader ( ) <EOL> n . loadShader ( "<STR_LIT>" ) <EOL> h1 = n . stateHash ( ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT> ) <EOL> self . assertNotEqual ( n . stateHash ( ) , h1 ) <EOL> def testCoshaderHash ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> self . assertTrue ( "<STR_LIT>" in shaderNode [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . typeId ( ) , Gaffer . Plug . staticTypeId ( ) ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode . loadShader ( coshader ) <EOL> shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( coshaderNode [ "<STR_LIT>" ] ) <EOL> h1 = shaderNode . stateHash ( ) <EOL> coshaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT> ) <EOL> self . assertNotEqual ( shaderNode . stateHash ( ) , h1 ) <EOL> def testParameterOrdering ( self ) : <EOL> n = GafferRenderMan . RenderManShader ( ) <EOL> n . loadShader ( "<STR_LIT>" ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . getName ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . getName ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ <NUM_LIT:2> ] . getName ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ <NUM_LIT:3> ] . getName ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ <NUM_LIT:4> ] . getName ( ) , "<STR_LIT>" ) <EOL> n = GafferRenderMan . RenderManShader ( ) <EOL> n . loadShader ( "<STR_LIT>" ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . getName ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . getName ( ) , "<STR_LIT>" ) <EOL> def testCoshader ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> self . assertTrue ( "<STR_LIT>" in shaderNode [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . typeId ( ) , Gaffer . Plug . staticTypeId ( ) ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode . loadShader ( coshader ) <EOL> shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( coshaderNode [ "<STR_LIT>" ] ) <EOL> s = shaderNode . state ( ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . name , coshader ) <EOL> self . assertEqual ( s [ <NUM_LIT:1> ] . name , shader ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] , s [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] ) <EOL> def testInputAcceptance ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode . loadShader ( coshader ) <EOL> random = Gaffer . Random ( ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderNode [ "<STR_LIT>" ] ) ) <EOL> self . assertFalse ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( random [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( random [ "<STR_LIT>" ] ) ) <EOL> self . assertFalse ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderNode [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( coshaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( random [ "<STR_LIT>" ] ) ) <EOL> self . assertFalse ( coshaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderNode [ "<STR_LIT>" ] ) ) <EOL> def testParameterDefaultValue ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , <NUM_LIT:1> ) <EOL> def testParameterMinMax ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . minValue ( ) , - <NUM_LIT:1> ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . maxValue ( ) , <NUM_LIT:10> ) <EOL> def testReload ( self ) : <EOL> shader1 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader1 ) <EOL> shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:0.1> ) <EOL> shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( "<STR_LIT:test>" ) <EOL> shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( IECore . Color3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> self . assertAlmostEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0.1> ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT:test>" ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . Color3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> shader2 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode . loadShader ( shader2 , keepExistingValues = True ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] . keys ( ) , [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertAlmostEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0.1> ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT:test>" ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . Color3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> shaderNode . loadShader ( shader1 , keepExistingValues = True ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] . keys ( ) , [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertAlmostEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0.1> ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT:test>" ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . Color3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> shaderNode . loadShader ( shader1 , keepExistingValues = False ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] . keys ( ) , [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . Color3f ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> ) ) <EOL> def testReloadRemovesOldParameters ( self ) : <EOL> shader2 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader2 ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] . keys ( ) , [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> shader3 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode . loadShader ( shader3 ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] . keys ( ) , [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> def testAutomaticReloadOnScriptLoad ( self ) : <EOL> shader1 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" , shaderName = "<STR_LIT>" ) <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT>" ] = GafferRenderMan . RenderManShader ( ) <EOL> s [ "<STR_LIT>" ] . loadShader ( shader1 ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:0.1> ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( "<STR_LIT:test>" ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( IECore . Color3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> ss = s . serialise ( ) <EOL> self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" , shaderName = "<STR_LIT>" ) <EOL> GafferRenderMan . RenderManShader . shaderLoader ( ) . clear ( ) <EOL> s = Gaffer . ScriptNode ( ) <EOL> s . execute ( ss ) <EOL> self . assertEqual ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . keys ( ) , [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertAlmostEqual ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0.1> ) <EOL> self . assertEqual ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT:test>" ) <EOL> self . assertEqual ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . Color3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> def testReloadPreservesConnections ( self ) : <EOL> n = GafferRenderMan . RenderManShader ( ) <EOL> n . loadShader ( "<STR_LIT>" ) <EOL> random = Gaffer . Random ( ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( random [ "<STR_LIT>" ] ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( random [ "<STR_LIT>" ] ) <EOL> n . loadShader ( "<STR_LIT>" , keepExistingValues = True ) <EOL> self . assertTrue ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getInput ( ) . isSame ( random [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getInput ( ) . isSame ( random [ "<STR_LIT>" ] ) ) <EOL> def testReloadPreservesConnectionsWhenMinMaxOrDefaultChanges ( self ) : <EOL> shader1 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" , shaderName = "<STR_LIT>" ) <EOL> n = GafferRenderMan . RenderManShader ( ) <EOL> n . loadShader ( shader1 ) <EOL> self . assertFalse ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . hasMinValue ( ) ) <EOL> self . assertFalse ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . hasMaxValue ( ) ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , "<STR_LIT>" ) <EOL> nn = Gaffer . Node ( ) <EOL> nn [ "<STR_LIT>" ] = Gaffer . FloatPlug ( direction = Gaffer . Plug . Direction . Out ) <EOL> nn [ "<STR_LIT>" ] = Gaffer . StringPlug ( direction = Gaffer . Plug . Direction . Out ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( nn [ "<STR_LIT>" ] ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( nn [ "<STR_LIT>" ] ) <EOL> shader2 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" , shaderName = "<STR_LIT>" ) <EOL> GafferRenderMan . RenderManShader . shaderLoader ( ) . clear ( ) <EOL> n . loadShader ( shader1 , keepExistingValues = True ) <EOL> self . assertTrue ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . hasMinValue ( ) ) <EOL> self . assertTrue ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . hasMaxValue ( ) ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . minValue ( ) , - <NUM_LIT:1> ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . maxValue ( ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , "<STR_LIT>" ) <EOL> self . assertTrue ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getInput ( ) . isSame ( nn [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getInput ( ) . isSame ( nn [ "<STR_LIT>" ] ) ) <EOL> def testReloadPreservesPartialConnectionsWhenMinMaxOrDefaultChanges ( self ) : <EOL> shader1 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" , shaderName = "<STR_LIT>" ) <EOL> n = GafferRenderMan . RenderManShader ( ) <EOL> n . loadShader ( shader1 ) <EOL> nn = Gaffer . Node ( ) <EOL> nn [ "<STR_LIT>" ] = Gaffer . FloatPlug ( direction = Gaffer . Plug . Direction . Out ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( nn [ "<STR_LIT>" ] ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . setInput ( nn [ "<STR_LIT>" ] ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:2> ] . setValue ( <NUM_LIT> ) <EOL> shader2 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" , shaderName = "<STR_LIT>" ) <EOL> GafferRenderMan . RenderManShader . shaderLoader ( ) . clear ( ) <EOL> n . loadShader ( shader1 , keepExistingValues = True ) <EOL> self . assertTrue ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . getInput ( ) . isSame ( nn [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . getInput ( ) . isSame ( nn [ "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:2> ] . getValue ( ) , <NUM_LIT> ) <EOL> def testReloadPreservesValuesWhenMinMaxOrDefaultChanges ( self ) : <EOL> shader1 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" , shaderName = "<STR_LIT>" ) <EOL> n = GafferRenderMan . RenderManShader ( ) <EOL> n . loadShader ( shader1 ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT> ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( IECore . Color3f ( <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT:0.5> ) ) <EOL> shader2 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" , shaderName = "<STR_LIT>" ) <EOL> GafferRenderMan . RenderManShader . shaderLoader ( ) . clear ( ) <EOL> n . loadShader ( shader1 , keepExistingValues = True ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . Color3f ( <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT:0.5> ) ) <EOL> def testOutputParameters ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> n = GafferRenderMan . RenderManShader ( ) <EOL> n . loadShader ( shader ) <EOL> self . failIf ( "<STR_LIT>" in n [ "<STR_LIT>" ] . keys ( ) ) <EOL> def testAssignmentDirtyPropagation ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode . loadShader ( coshader ) <EOL> shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( coshaderNode [ "<STR_LIT>" ] ) <EOL> plane = GafferScene . Plane ( ) <EOL> assignment = GafferScene . ShaderAssignment ( ) <EOL> assignment [ "<STR_LIT>" ] . setInput ( plane [ "<STR_LIT>" ] ) <EOL> assignment [ "<STR_LIT>" ] . setInput ( shaderNode [ "<STR_LIT>" ] ) <EOL> cs = GafferTest . CapturingSlot ( assignment . plugDirtiedSignal ( ) ) <EOL> coshaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:12> ) <EOL> dirtiedNames = [ x [ <NUM_LIT:0> ] . fullName ( ) for x in cs ] <EOL> self . assertEqual ( len ( dirtiedNames ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( dirtiedNames [ <NUM_LIT:0> ] , "<STR_LIT>" ) <EOL> self . assertEqual ( dirtiedNames [ <NUM_LIT:1> ] , "<STR_LIT>" ) <EOL> self . assertEqual ( dirtiedNames [ <NUM_LIT:2> ] , "<STR_LIT>" ) <EOL> def testArrayParameters ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> n = GafferRenderMan . RenderManShader ( ) <EOL> n . loadShader ( shader ) <EOL> expected = { <EOL> "<STR_LIT>" : IECore . FloatVectorData ( [ ] ) , <EOL> "<STR_LIT>" : IECore . FloatVectorData ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ) , <EOL> "<STR_LIT>" : IECore . StringVectorData ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) , <EOL> "<STR_LIT>" : IECore . StringVectorData ( [ "<STR_LIT:hello>" , "<STR_LIT>" ] ) , <EOL> "<STR_LIT>" : IECore . Color3fVectorData ( [ IECore . Color3f ( <NUM_LIT:1> ) , IECore . Color3f ( <NUM_LIT:2> ) ] ) , <EOL> "<STR_LIT>" : IECore . Color3fVectorData ( [ IECore . Color3f ( <NUM_LIT:1> ) , IECore . Color3f ( <NUM_LIT:2> ) ] ) , <EOL> "<STR_LIT>" : IECore . V3fVectorData ( [ ] , IECore . GeometricData . Interpretation . Vector ) , <EOL> "<STR_LIT>" : IECore . V3fVectorData ( [ IECore . V3f ( x ) for x in range ( <NUM_LIT:1> , <NUM_LIT:6> ) ] , IECore . GeometricData . Interpretation . Vector ) , <EOL> "<STR_LIT>" : IECore . V3fVectorData ( [ ] , IECore . GeometricData . Interpretation . Point ) , <EOL> "<STR_LIT>" : IECore . V3fVectorData ( [ IECore . V3f ( x ) for x in range ( <NUM_LIT:1> , <NUM_LIT:6> ) ] , IECore . GeometricData . Interpretation . Point ) , <EOL> "<STR_LIT>" : IECore . V3fVectorData ( [ ] , IECore . GeometricData . Interpretation . Normal ) , <EOL> "<STR_LIT>" : IECore . V3fVectorData ( [ IECore . V3f ( x ) for x in range ( <NUM_LIT:1> , <NUM_LIT:6> ) ] , IECore . GeometricData . Interpretation . Normal ) , <EOL> } <EOL> self . assertEqual ( set ( n [ "<STR_LIT>" ] . keys ( ) ) , set ( expected . keys ( ) ) ) <EOL> for name , value in expected . items ( ) : <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ name ] . defaultValue ( ) , value ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ name ] . getValue ( ) , value ) <EOL> s = n . state ( ) [ <NUM_LIT:0> ] <EOL> for name , value in expected . items ( ) : <EOL> self . assertEqual ( s . parameters [ name ] , value ) <EOL> def testFixedCoshaderArrayParameters ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> n = GafferRenderMan . RenderManShader ( ) <EOL> n . loadShader ( shader ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] . keys ( ) , [ "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertTrue ( isinstance ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . ArrayPlug ) ) <EOL> self . assertEqual ( len ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) , <NUM_LIT:4> ) <EOL> self . assertTrue ( isinstance ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . Plug ) ) <EOL> self . assertTrue ( isinstance ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . Plug ) ) <EOL> self . assertTrue ( isinstance ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . Plug ) ) <EOL> self . assertTrue ( isinstance ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . Plug ) ) <EOL> state = n . state ( ) <EOL> self . assertEqual ( state [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] , IECore . StringVectorData ( [ "<STR_LIT>" ] * <NUM_LIT:4> ) ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode . loadShader ( coshader ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( coshaderNode [ "<STR_LIT>" ] ) <EOL> state = n . state ( ) <EOL> self . assertEqual ( state [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] , IECore . StringVectorData ( [ state [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] . value , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> def testCoshaderType ( self ) : <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode . loadShader ( coshader ) <EOL> self . assertEqual ( coshaderNode . state ( ) [ <NUM_LIT:0> ] . type , "<STR_LIT>" ) <EOL> def testCantConnectSurfaceShaderIntoCoshaderInput ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> n1 = GafferRenderMan . RenderManShader ( ) <EOL> n1 . loadShader ( shader ) <EOL> n2 = GafferRenderMan . RenderManShader ( ) <EOL> n2 . loadShader ( "<STR_LIT>" ) <EOL> self . assertFalse ( n1 [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( n2 [ "<STR_LIT>" ] ) ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> n3 = GafferRenderMan . RenderManShader ( ) <EOL> n3 . loadShader ( coshader ) <EOL> self . assertTrue ( n1 [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( n3 [ "<STR_LIT>" ] ) ) <EOL> arrayShader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> n4 = GafferRenderMan . RenderManShader ( ) <EOL> n4 . loadShader ( arrayShader ) <EOL> self . assertFalse ( n4 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( n2 [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( n4 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( n3 [ "<STR_LIT>" ] ) ) <EOL> def testConnectionsBetweenParameters ( self ) : <EOL> s = GafferRenderMan . RenderManShader ( ) <EOL> s . loadShader ( "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT> ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> shader = s . state ( ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( shader . parameters [ "<STR_LIT>" ] . value , <NUM_LIT> ) <EOL> self . assertEqual ( shader . parameters [ "<STR_LIT>" ] . value , <NUM_LIT> ) <EOL> def testFixedCoshaderArrayParameterHash ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> n = GafferRenderMan . RenderManShader ( ) <EOL> n . loadShader ( shader ) <EOL> h1 = n . stateHash ( ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode . loadShader ( coshader ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( coshaderNode [ "<STR_LIT>" ] ) <EOL> h2 = n . stateHash ( ) <EOL> self . assertNotEqual ( h2 , h1 ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( coshaderNode [ "<STR_LIT>" ] ) <EOL> h3 = n . stateHash ( ) <EOL> self . assertNotEqual ( h3 , h2 ) <EOL> self . assertNotEqual ( h3 , h1 ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( None ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( coshaderNode [ "<STR_LIT>" ] ) <EOL> h4 = n . stateHash ( ) <EOL> self . assertNotEqual ( h4 , h3 ) <EOL> self . assertNotEqual ( h4 , h2 ) <EOL> self . assertNotEqual ( h4 , h1 ) <EOL> def testDisabling ( self ) : <EOL> s = GafferRenderMan . RenderManShader ( ) <EOL> s . loadShader ( "<STR_LIT>" ) <EOL> stateHash = s . stateHash ( ) <EOL> state = s . state ( ) <EOL> self . assertEqual ( len ( state ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( state [ <NUM_LIT:0> ] . name , "<STR_LIT>" ) <EOL> self . assertTrue ( s [ "<STR_LIT>" ] . isSame ( s . enabledPlug ( ) ) ) <EOL> s [ "<STR_LIT>" ] . setValue ( False ) <EOL> stateHash2 = s . stateHash ( ) <EOL> self . assertNotEqual ( stateHash2 , stateHash ) <EOL> state2 = s . state ( ) <EOL> self . assertEqual ( len ( state2 ) , <NUM_LIT:0> ) <EOL> def testDisablingCoshaders ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode . loadShader ( coshader ) <EOL> shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( coshaderNode [ "<STR_LIT>" ] ) <EOL> s = shaderNode . state ( ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . name , coshader ) <EOL> self . assertEqual ( s [ <NUM_LIT:1> ] . name , shader ) <EOL> h = shaderNode . stateHash ( ) <EOL> coshaderNode [ "<STR_LIT>" ] . setValue ( False ) <EOL> s2 = shaderNode . state ( ) <EOL> self . assertEqual ( len ( s2 ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( s2 [ <NUM_LIT:0> ] . name , shader ) <EOL> self . assertTrue ( "<STR_LIT>" not in s2 [ <NUM_LIT:0> ] . parameters ) <EOL> self . assertNotEqual ( shaderNode . stateHash ( ) , h ) <EOL> def testDisablingCoshaderArrayInputs ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> n = GafferRenderMan . RenderManShader ( ) <EOL> n . loadShader ( shader ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode1 = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode1 . loadShader ( coshader ) <EOL> coshaderNode2 = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode2 . loadShader ( coshader ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( coshaderNode1 [ "<STR_LIT>" ] ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:2> ] . setInput ( coshaderNode2 [ "<STR_LIT>" ] ) <EOL> state = n . state ( ) <EOL> h1 = n . stateHash ( ) <EOL> self . assertEqual ( <EOL> state [ <NUM_LIT:2> ] . parameters [ "<STR_LIT>" ] , <EOL> IECore . StringVectorData ( [ <EOL> state [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] . value , <EOL> "<STR_LIT>" , <EOL> state [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] . value , <EOL> "<STR_LIT>" <EOL> ] ) <EOL> ) <EOL> coshaderNode1 [ "<STR_LIT>" ] . setValue ( False ) <EOL> state = n . state ( ) <EOL> self . assertEqual ( <EOL> state [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] , <EOL> IECore . StringVectorData ( [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> state [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] . value , <EOL> "<STR_LIT>" <EOL> ] ) <EOL> ) <EOL> h2 = n . stateHash ( ) <EOL> self . assertNotEqual ( h2 , h1 ) <EOL> coshaderNode2 [ "<STR_LIT>" ] . setValue ( False ) <EOL> state = n . state ( ) <EOL> self . assertEqual ( <EOL> state [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] , <EOL> IECore . StringVectorData ( [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ] ) <EOL> ) <EOL> self . assertNotEqual ( n . stateHash ( ) , h1 ) <EOL> self . assertNotEqual ( n . stateHash ( ) , h2 ) <EOL> def testCorrespondingInput ( self ) : <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode . loadShader ( coshader ) <EOL> self . assertEqual ( coshaderNode . correspondingInput ( coshaderNode [ "<STR_LIT>" ] ) , None ) <EOL> coshader2 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode2 = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode2 . loadShader ( coshader2 ) <EOL> self . assertTrue ( coshaderNode2 . correspondingInput ( coshaderNode2 [ "<STR_LIT>" ] ) . isSame ( coshaderNode2 [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) ) <EOL> def testCoshaderPassThrough ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> passThroughCoshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> passThroughCoshaderNode = GafferRenderMan . RenderManShader ( ) <EOL> passThroughCoshaderNode . loadShader ( passThroughCoshader ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode . loadShader ( coshader ) <EOL> shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( passThroughCoshaderNode [ "<STR_LIT>" ] ) <EOL> passThroughCoshaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( coshaderNode [ "<STR_LIT>" ] ) <EOL> h = shaderNode . stateHash ( ) <EOL> s = shaderNode . state ( ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( s [ <NUM_LIT:2> ] . parameters [ "<STR_LIT>" ] , s [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( s [ <NUM_LIT:1> ] . name , passThroughCoshader ) <EOL> self . assertEqual ( s [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] , s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . name , coshader ) <EOL> passThroughCoshaderNode [ "<STR_LIT>" ] . setValue ( False ) <EOL> s = shaderNode . state ( ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( s [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] , s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . name , coshader ) <EOL> def testSplineParameters ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> n = GafferRenderMan . RenderManShader ( ) <EOL> n . loadShader ( shader ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] . keys ( ) , [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> self . assertTrue ( isinstance ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . SplineffPlug ) ) <EOL> self . assertTrue ( isinstance ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . SplinefColor3fPlug ) ) <EOL> self . assertEqual ( <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , <EOL> IECore . Splineff ( <EOL> IECore . CubicBasisf . catmullRom ( ) , <EOL> [ <EOL> ( <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> ( <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> ( <NUM_LIT:1> , <NUM_LIT:1> ) , <EOL> ] <EOL> ) <EOL> ) <EOL> self . assertEqual ( <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , <EOL> IECore . SplinefColor3f ( <EOL> IECore . CubicBasisf . catmullRom ( ) , <EOL> [ <EOL> ( <NUM_LIT:0> , IECore . Color3f ( <NUM_LIT:0> ) ) , <EOL> ( <NUM_LIT:0> , IECore . Color3f ( <NUM_LIT:0> ) ) , <EOL> ( <NUM_LIT:1> , IECore . Color3f ( <NUM_LIT:1> ) ) , <EOL> ( <NUM_LIT:1> , IECore . Color3f ( <NUM_LIT:1> ) ) , <EOL> ] <EOL> ) <EOL> ) <EOL> floatValue = IECore . Splineff ( <EOL> IECore . CubicBasisf . catmullRom ( ) , <EOL> [ <EOL> ( <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> ( <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> ( <NUM_LIT:1> , <NUM_LIT:2> ) , <EOL> ( <NUM_LIT:1> , <NUM_LIT:2> ) , <EOL> ] <EOL> ) <EOL> colorValue = IECore . SplinefColor3f ( <EOL> IECore . CubicBasisf . catmullRom ( ) , <EOL> [ <EOL> ( <NUM_LIT:0> , IECore . Color3f ( <NUM_LIT:0> ) ) , <EOL> ( <NUM_LIT:0> , IECore . Color3f ( <NUM_LIT:0> ) ) , <EOL> ( <NUM_LIT:1> , IECore . Color3f ( <NUM_LIT> ) ) , <EOL> ( <NUM_LIT:1> , IECore . Color3f ( <NUM_LIT> ) ) , <EOL> ] <EOL> ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( floatValue ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( colorValue ) <EOL> s = n . state ( ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( s . parameters [ "<STR_LIT>" ] . value , floatValue ) <EOL> self . assertEqual ( s . parameters [ "<STR_LIT>" ] . value , colorValue ) <EOL> def testSplineParameterSerialisationKeepsExistingValues ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT:n>" ] = GafferRenderMan . RenderManShader ( ) <EOL> s [ "<STR_LIT:n>" ] . loadShader ( shader ) <EOL> s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <EOL> IECore . Splineff ( <EOL> IECore . CubicBasisf . catmullRom ( ) , <EOL> [ <EOL> ( <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> ( <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> ( <NUM_LIT:1> , <NUM_LIT:2> ) , <EOL> ( <NUM_LIT:1> , <NUM_LIT:2> ) , <EOL> ] <EOL> ) <EOL> ) <EOL> self . assertEqual ( <EOL> s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <EOL> IECore . Splineff ( <EOL> IECore . CubicBasisf . catmullRom ( ) , <EOL> [ <EOL> ( <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> ( <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> ( <NUM_LIT:1> , <NUM_LIT:2> ) , <EOL> ( <NUM_LIT:1> , <NUM_LIT:2> ) , <EOL> ] <EOL> ) , <EOL> ) <EOL> ss = s . serialise ( ) <EOL> s2 = Gaffer . ScriptNode ( ) <EOL> s2 . execute ( ss ) <EOL> self . assertEqual ( <EOL> s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <EOL> IECore . Splineff ( <EOL> IECore . CubicBasisf . catmullRom ( ) , <EOL> [ <EOL> ( <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> ( <NUM_LIT:0> , <NUM_LIT:0> ) , <EOL> ( <NUM_LIT:1> , <NUM_LIT:2> ) , <EOL> ( <NUM_LIT:1> , <NUM_LIT:2> ) , <EOL> ] <EOL> ) , <EOL> ) <EOL> def testSplineParameterDefaultValueAnnotation ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> n = GafferRenderMan . RenderManShader ( ) <EOL> n . loadShader ( shader ) <EOL> self . assertEqual ( <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <EOL> IECore . SplinefColor3f ( <EOL> IECore . CubicBasisf . catmullRom ( ) , <EOL> [ <EOL> ( <NUM_LIT:0> , IECore . Color3f ( <NUM_LIT:1> ) ) , <EOL> ( <NUM_LIT:0> , IECore . Color3f ( <NUM_LIT:1> ) ) , <EOL> ( <NUM_LIT:0.5> , IECore . Color3f ( <NUM_LIT:1> , <NUM_LIT:0.5> , <NUM_LIT> ) ) , <EOL> ( <NUM_LIT:1> , IECore . Color3f ( <NUM_LIT:0> ) ) , <EOL> ( <NUM_LIT:1> , IECore . Color3f ( <NUM_LIT:0> ) ) , <EOL> ] <EOL> ) , <EOL> ) <EOL> def testCoshadersInBox ( self ) : <EOL> s = Gaffer . ScriptNode ( ) <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] = GafferRenderMan . RenderManShader ( ) <EOL> s [ "<STR_LIT>" ] . loadShader ( shader ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] = GafferRenderMan . RenderManShader ( ) <EOL> s [ "<STR_LIT>" ] . loadShader ( coshader ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> b = Gaffer . Box . create ( s , Gaffer . StandardSet ( [ s [ "<STR_LIT>" ] ] ) ) <EOL> self . assertTrue ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getInput ( ) . parent ( ) . isSame ( b ) ) <EOL> s = s [ "<STR_LIT>" ] . state ( ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( s [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] , s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . name , coshader ) <EOL> def testShaderInBoxWithExternalCoshader ( self ) : <EOL> s = Gaffer . ScriptNode ( ) <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] = GafferRenderMan . RenderManShader ( ) <EOL> s [ "<STR_LIT>" ] . loadShader ( shader ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s [ "<STR_LIT>" ] = GafferRenderMan . RenderManShader ( ) <EOL> s [ "<STR_LIT>" ] . loadShader ( coshader ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> b = Gaffer . Box . create ( s , Gaffer . StandardSet ( [ s [ "<STR_LIT>" ] ] ) ) <EOL> self . assertTrue ( b [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getInput ( ) . parent ( ) . isSame ( b ) ) <EOL> s = b [ "<STR_LIT>" ] . state ( ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( s [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] , s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . name , coshader ) <EOL> def testNumericTypeAnnotations ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> self . assertTrue ( isinstance ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . FloatPlug ) ) <EOL> self . assertTrue ( isinstance ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . FloatPlug ) ) <EOL> self . assertTrue ( isinstance ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . IntPlug ) ) <EOL> self . assertTrue ( isinstance ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . BoolPlug ) ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , <NUM_LIT:10> ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , True ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:10> ) <EOL> self . assertEqual ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , True ) <EOL> def testCoshaderTypeAnnotations ( self ) : <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode . loadShader ( coshader ) <EOL> coshaderType1 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderType1Node = GafferRenderMan . RenderManShader ( ) <EOL> coshaderType1Node . loadShader ( coshaderType1 ) <EOL> coshaderType2 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderType2Node = GafferRenderMan . RenderManShader ( ) <EOL> coshaderType2Node . loadShader ( coshaderType2 ) <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderNode [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderType1Node [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderType2Node [ "<STR_LIT>" ] ) ) <EOL> self . assertFalse ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderNode [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderType1Node [ "<STR_LIT>" ] ) ) <EOL> self . assertFalse ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderType2Node [ "<STR_LIT>" ] ) ) <EOL> self . assertFalse ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderNode [ "<STR_LIT>" ] ) ) <EOL> self . assertFalse ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderType1Node [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderType2Node [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderNode [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderType1Node [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderType2Node [ "<STR_LIT>" ] ) ) <EOL> self . assertFalse ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderNode [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderType1Node [ "<STR_LIT>" ] ) ) <EOL> self . assertFalse ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderType2Node [ "<STR_LIT>" ] ) ) <EOL> self . assertFalse ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . acceptsInput ( coshaderNode [ "<STR_LIT>" ] ) ) <EOL> self . assertFalse ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . acceptsInput ( coshaderType1Node [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . acceptsInput ( coshaderType2Node [ "<STR_LIT>" ] ) ) <EOL> def testMultipleCoshaderTypeAnnotations ( self ) : <EOL> coshaderType1And2 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderType1And2Node = GafferRenderMan . RenderManShader ( ) <EOL> coshaderType1And2Node . loadShader ( coshaderType1And2 ) <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderType1And2Node [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderType1And2Node [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderType1And2Node [ "<STR_LIT>" ] ) ) <EOL> self . assertFalse ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( coshaderType1And2Node [ "<STR_LIT>" ] ) ) <EOL> def testSplitCoshaderPassThrough ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> S = GafferRenderMan . RenderManShader ( ) <EOL> S . loadShader ( shader ) <EOL> passThroughCoshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> D = GafferRenderMan . RenderManShader ( ) <EOL> D . loadShader ( passThroughCoshader ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> C = GafferRenderMan . RenderManShader ( ) <EOL> C . loadShader ( coshader ) <EOL> S [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( C [ "<STR_LIT>" ] ) <EOL> S [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . setInput ( D [ "<STR_LIT>" ] ) <EOL> D [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( C [ "<STR_LIT>" ] ) <EOL> h = S . stateHash ( ) <EOL> s = S . state ( ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( s [ <NUM_LIT:2> ] . parameters [ "<STR_LIT>" ] , IECore . StringVectorData ( [ s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] . value , s [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] . value , "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . name , coshader ) <EOL> self . assertEqual ( s [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] , s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( s [ <NUM_LIT:1> ] . name , passThroughCoshader ) <EOL> D [ "<STR_LIT>" ] . setValue ( False ) <EOL> self . assertNotEqual ( S . stateHash ( ) , h ) <EOL> s = S . state ( ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( s [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] , IECore . StringVectorData ( [ s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] . value , s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] . value , "<STR_LIT>" , "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . name , coshader ) <EOL> def testSerialDisabledShaders ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> S = GafferRenderMan . RenderManShader ( ) <EOL> S . loadShader ( shader ) <EOL> passThroughCoshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> D1 = GafferRenderMan . RenderManShader ( ) <EOL> D1 . loadShader ( passThroughCoshader ) <EOL> D2 = GafferRenderMan . RenderManShader ( ) <EOL> D2 . loadShader ( passThroughCoshader ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> C = GafferRenderMan . RenderManShader ( ) <EOL> C . loadShader ( coshader ) <EOL> S [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( D2 [ "<STR_LIT>" ] ) <EOL> D2 [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( D1 [ "<STR_LIT>" ] ) <EOL> D1 [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( C [ "<STR_LIT>" ] ) <EOL> h1 = S . stateHash ( ) <EOL> s = S . state ( ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:4> ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . name , coshader ) <EOL> self . assertEqual ( s [ <NUM_LIT:1> ] . name , passThroughCoshader ) <EOL> self . assertEqual ( s [ <NUM_LIT:2> ] . name , passThroughCoshader ) <EOL> self . assertEqual ( s [ <NUM_LIT:3> ] . name , shader ) <EOL> self . assertEqual ( s [ <NUM_LIT:3> ] . parameters [ "<STR_LIT>" ] , s [ <NUM_LIT:2> ] . parameters [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( s [ <NUM_LIT:2> ] . parameters [ "<STR_LIT>" ] , s [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( s [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] , s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] ) <EOL> D2 [ "<STR_LIT>" ] . setValue ( False ) <EOL> h2 = S . stateHash ( ) <EOL> self . assertNotEqual ( h1 , h2 ) <EOL> s = S . state ( ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . name , coshader ) <EOL> self . assertEqual ( s [ <NUM_LIT:1> ] . name , passThroughCoshader ) <EOL> self . assertEqual ( s [ <NUM_LIT:2> ] . name , shader ) <EOL> self . assertEqual ( s [ <NUM_LIT:2> ] . parameters [ "<STR_LIT>" ] , s [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( s [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] , s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] ) <EOL> D1 [ "<STR_LIT>" ] . setValue ( False ) <EOL> h3 = S . stateHash ( ) <EOL> self . assertNotEqual ( h3 , h2 ) <EOL> self . assertNotEqual ( h3 , h1 ) <EOL> s = S . state ( ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . name , coshader ) <EOL> self . assertEqual ( s [ <NUM_LIT:1> ] . name , shader ) <EOL> self . assertEqual ( s [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] , s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] ) <EOL> def testDynamicCoshaderArrayParameters ( self ) : <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode . loadShader ( coshader ) <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> self . assertEqual ( len ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) , <NUM_LIT:1> ) <EOL> self . assertTrue ( isinstance ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] , Gaffer . Plug ) ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . getInput ( ) is None ) <EOL> shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( coshaderNode [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( len ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) , <NUM_LIT:2> ) <EOL> self . assertTrue ( isinstance ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] , Gaffer . Plug ) ) <EOL> self . assertTrue ( isinstance ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] , Gaffer . Plug ) ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . getInput ( ) . isSame ( coshaderNode [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . getInput ( ) is None ) <EOL> shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( None ) <EOL> self . assertEqual ( len ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) , <NUM_LIT:1> ) <EOL> self . assertTrue ( isinstance ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] , Gaffer . Plug ) ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . getInput ( ) is None ) <EOL> def testSerialiseDynamicCoshaderArrayParameters ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT:n>" ] = GafferRenderMan . RenderManShader ( ) <EOL> s [ "<STR_LIT:n>" ] . loadShader ( shader ) <EOL> s [ "<STR_LIT:c>" ] = GafferRenderMan . RenderManShader ( ) <EOL> s [ "<STR_LIT:c>" ] . loadShader ( coshader ) <EOL> s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( s [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . setInput ( s [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:2> ] . setInput ( s [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) <EOL> s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . setInput ( None ) <EOL> self . assertEqual ( len ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) , <NUM_LIT:4> ) <EOL> s2 = Gaffer . ScriptNode ( ) <EOL> s2 . execute ( s . serialise ( ) ) <EOL> self . assertEqual ( len ( s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) , <NUM_LIT:4> ) <EOL> self . assertTrue ( s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . getInput ( ) . isSame ( s2 [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . getInput ( ) is None ) <EOL> self . assertTrue ( s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:2> ] . getInput ( ) . isSame ( s2 [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:3> ] . getInput ( ) is None ) <EOL> s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:3> ] . setInput ( s2 [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( len ( s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) , <NUM_LIT:5> ) <EOL> self . assertTrue ( s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . getInput ( ) . isSame ( s2 [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . getInput ( ) is None ) <EOL> self . assertTrue ( s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:2> ] . getInput ( ) . isSame ( s2 [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:3> ] . getInput ( ) . isSame ( s2 [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:4> ] . getInput ( ) is None ) <EOL> def testConvertFixedCoshaderArrayToDynamic ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderV2 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT:n>" ] = GafferRenderMan . RenderManShader ( ) <EOL> s [ "<STR_LIT:n>" ] . loadShader ( shader ) <EOL> s [ "<STR_LIT:c>" ] = GafferRenderMan . RenderManShader ( ) <EOL> s [ "<STR_LIT:c>" ] . loadShader ( coshader ) <EOL> s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( s [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) <EOL> self . assertTrue ( len ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) , <NUM_LIT:4> ) <EOL> s [ "<STR_LIT:n>" ] . loadShader ( shaderV2 , keepExistingValues = True ) <EOL> self . assertTrue ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . getInput ( ) . isSame ( s [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . getInput ( ) is None ) <EOL> s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( None ) <EOL> self . assertEqual ( len ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) , <NUM_LIT:1> ) <EOL> self . assertTrue ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . getInput ( ) is None ) <EOL> def testConvertFixedCoshaderArrayToDynamicWithFirstPlugUnconnected ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderV2 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT:n>" ] = GafferRenderMan . RenderManShader ( ) <EOL> s [ "<STR_LIT:n>" ] . loadShader ( shader ) <EOL> s [ "<STR_LIT:c>" ] = GafferRenderMan . RenderManShader ( ) <EOL> s [ "<STR_LIT:c>" ] . loadShader ( coshader ) <EOL> s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . setInput ( s [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) <EOL> self . assertTrue ( len ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) , <NUM_LIT:4> ) <EOL> s [ "<STR_LIT:n>" ] . loadShader ( shaderV2 , keepExistingValues = True ) <EOL> self . assertTrue ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . getInput ( ) . isSame ( s [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . getInput ( ) is None ) <EOL> s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . setInput ( None ) <EOL> self . assertEqual ( len ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) , <NUM_LIT:1> ) <EOL> self . assertTrue ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . getInput ( ) is None ) <EOL> def testConvertFixedCoshaderArrayToDynamicDuringLoading ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT:n>" ] = GafferRenderMan . RenderManShader ( ) <EOL> s [ "<STR_LIT:n>" ] . loadShader ( shader ) <EOL> s [ "<STR_LIT:c>" ] = GafferRenderMan . RenderManShader ( ) <EOL> s [ "<STR_LIT:c>" ] . loadShader ( coshader ) <EOL> s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . setInput ( s [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) <EOL> self . assertTrue ( len ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) , <NUM_LIT:4> ) <EOL> GafferRenderMan . RenderManShader . shaderLoader ( ) . clear ( ) <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" , shaderName = "<STR_LIT>" ) <EOL> s2 = Gaffer . ScriptNode ( ) <EOL> s2 . execute ( s . serialise ( ) ) <EOL> self . assertTrue ( s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . getInput ( ) . isSame ( s2 [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . getInput ( ) is None ) <EOL> s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . setInput ( None ) <EOL> self . assertEqual ( len ( s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) , <NUM_LIT:1> ) <EOL> self . assertTrue ( s2 [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . getInput ( ) is None ) <EOL> def testHashThroughBox ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> b = Gaffer . Box ( ) <EOL> b . addChild ( Gaffer . Plug ( "<STR_LIT>" ) ) <EOL> b . addChild ( Gaffer . Plug ( "<STR_LIT>" , direction = Gaffer . Plug . Direction . Out ) ) <EOL> intermediateCoshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> intermediateCoshaderNode = GafferRenderMan . RenderManShader ( ) <EOL> intermediateCoshaderNode . loadShader ( intermediateCoshader ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode . loadShader ( coshader ) <EOL> b [ "<STR_LIT>" ] . setInput ( coshaderNode [ "<STR_LIT>" ] ) <EOL> intermediateCoshaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( b [ "<STR_LIT>" ] ) <EOL> b [ "<STR_LIT>" ] . setInput ( intermediateCoshaderNode [ "<STR_LIT>" ] ) <EOL> shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( b [ "<STR_LIT>" ] ) <EOL> h1 = shaderNode . stateHash ( ) <EOL> coshaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT> ) <EOL> self . assertNotEqual ( shaderNode . stateHash ( ) , h1 ) <EOL> def testDanglingBoxConnection ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode1 = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode1 . loadShader ( shader ) <EOL> shaderNode2 = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode2 . loadShader ( shader ) <EOL> b = Gaffer . Box ( ) <EOL> b . addChild ( Gaffer . Plug ( "<STR_LIT>" ) ) <EOL> b . addChild ( Gaffer . Plug ( "<STR_LIT>" , direction = Gaffer . Plug . Direction . Out ) ) <EOL> b [ "<STR_LIT>" ] = shaderNode1 <EOL> shaderNode1 [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( b [ "<STR_LIT>" ] ) <EOL> shaderNode2 [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( b [ "<STR_LIT>" ] ) <EOL> def testUnconnectedCustomBoxInput ( self ) : <EOL> class CustomBox ( Gaffer . Box ) : <EOL> def __init__ ( self , name = "<STR_LIT>" ) : <EOL> Gaffer . Box . __init__ ( self , name ) <EOL> IECore . registerRunTimeTyped ( CustomBox ) <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> b = CustomBox ( ) <EOL> b [ "<STR_LIT:s>" ] = GafferRenderMan . RenderManShader ( ) <EOL> b [ "<STR_LIT:s>" ] . loadShader ( shader ) <EOL> b [ "<STR_LIT>" ] = b [ "<STR_LIT:s>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . createCounterpart ( "<STR_LIT>" , Gaffer . Plug . Direction . In ) <EOL> b [ "<STR_LIT:s>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( b [ "<STR_LIT>" ] ) <EOL> s = b [ "<STR_LIT:s>" ] . state ( ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( s [ <NUM_LIT:0> ] . name , shader ) <EOL> self . assertTrue ( b [ "<STR_LIT:s>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getInput ( ) . isSame ( b [ "<STR_LIT>" ] ) ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> c = GafferRenderMan . RenderManShader ( ) <EOL> c . loadShader ( coshader ) <EOL> self . assertTrue ( b [ "<STR_LIT>" ] . acceptsInput ( c [ "<STR_LIT>" ] ) ) <EOL> b [ "<STR_LIT>" ] . setInput ( c [ "<STR_LIT>" ] ) <EOL> s = b [ "<STR_LIT:s>" ] . state ( ) <EOL> self . assertEqual ( len ( s ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( s [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] , s [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] ) <EOL> n = Gaffer . Node ( ) <EOL> n [ "<STR_LIT>" ] = b [ "<STR_LIT>" ] . createCounterpart ( "<STR_LIT>" , Gaffer . Plug . Direction . Out ) <EOL> self . assertFalse ( b [ "<STR_LIT>" ] . acceptsInput ( n [ "<STR_LIT>" ] ) ) <EOL> self . assertRaises ( RuntimeError , b [ "<STR_LIT>" ] . setInput , n [ "<STR_LIT>" ] ) <EOL> b [ "<STR_LIT:s>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( None ) <EOL> self . assertTrue ( b [ "<STR_LIT>" ] . acceptsInput ( n [ "<STR_LIT>" ] ) ) <EOL> b [ "<STR_LIT>" ] . setInput ( n [ "<STR_LIT>" ] ) <EOL> self . assertTrue ( b [ "<STR_LIT>" ] . getInput ( ) . isSame ( n [ "<STR_LIT>" ] ) ) <EOL> self . assertFalse ( b [ "<STR_LIT:s>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( b [ "<STR_LIT>" ] ) ) <EOL> self . assertRaises ( RuntimeError , b [ "<STR_LIT:s>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput , b [ "<STR_LIT>" ] ) <EOL> def testCoshaderSwitching ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode0 = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode0 . loadShader ( coshader ) <EOL> coshaderNode1 = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode1 . loadShader ( coshader ) <EOL> coshaderNode0 [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:0> ) <EOL> coshaderNode1 [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:1> ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> switch = GafferScene . ShaderSwitch ( ) <EOL> switch [ "<STR_LIT>" ] . setInput ( coshaderNode0 [ "<STR_LIT>" ] ) <EOL> switch [ "<STR_LIT>" ] . setInput ( coshaderNode1 [ "<STR_LIT>" ] ) <EOL> shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( switch [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( shaderNode . state ( ) [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] . value , <NUM_LIT:0> ) <EOL> switch [ "<STR_LIT:index>" ] . setValue ( <NUM_LIT:1> ) <EOL> self . assertEqual ( shaderNode . state ( ) [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] . value , <NUM_LIT:1> ) <EOL> switch [ "<STR_LIT>" ] . setValue ( False ) <EOL> self . assertEqual ( shaderNode . state ( ) [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] . value , <NUM_LIT:0> ) <EOL> def testCoshaderTypingPreventsNewInvalidSwitchInputs ( self ) : <EOL> coshaderType1 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderType1Node = GafferRenderMan . RenderManShader ( ) <EOL> coshaderType1Node . loadShader ( coshaderType1 ) <EOL> coshaderType2 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderType2Node = GafferRenderMan . RenderManShader ( ) <EOL> coshaderType2Node . loadShader ( coshaderType2 ) <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> switch = GafferScene . ShaderSwitch ( ) <EOL> switch [ "<STR_LIT>" ] . setInput ( coshaderType1Node [ "<STR_LIT>" ] ) <EOL> shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( switch [ "<STR_LIT>" ] ) <EOL> self . assertFalse ( switch [ "<STR_LIT>" ] . acceptsInput ( coshaderType2Node [ "<STR_LIT>" ] ) ) <EOL> self . assertTrue ( switch [ "<STR_LIT>" ] . acceptsInput ( coshaderType1Node [ "<STR_LIT>" ] ) ) <EOL> def testAcceptInputFromEmptySwitch ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> switch = GafferScene . ShaderSwitch ( ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( switch [ "<STR_LIT>" ] ) ) <EOL> def testCoshaderSwitchingInBox ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> script = Gaffer . ScriptNode ( ) <EOL> script [ "<STR_LIT>" ] = GafferRenderMan . RenderManShader ( ) <EOL> script [ "<STR_LIT>" ] . loadShader ( coshader ) <EOL> script [ "<STR_LIT>" ] = GafferRenderMan . RenderManShader ( ) <EOL> script [ "<STR_LIT>" ] . loadShader ( coshader ) <EOL> script [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:0> ) <EOL> script [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:1> ) <EOL> script [ "<STR_LIT>" ] = GafferRenderMan . RenderManShader ( ) <EOL> script [ "<STR_LIT>" ] . loadShader ( shader ) <EOL> script [ "<STR_LIT>" ] = GafferScene . ShaderSwitch ( ) <EOL> script [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( script [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> script [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( script [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> script [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( script [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( script [ "<STR_LIT>" ] . state ( ) [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] . value , <NUM_LIT:0> ) <EOL> box = Gaffer . Box . create ( script , Gaffer . StandardSet ( script . children ( Gaffer . Node ) ) ) <EOL> self . assertEqual ( box [ "<STR_LIT>" ] . state ( ) [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] . value , <NUM_LIT:0> ) <EOL> promotedIndex = box . promotePlug ( box [ "<STR_LIT>" ] [ "<STR_LIT:index>" ] ) <EOL> self . assertEqual ( box [ "<STR_LIT>" ] . state ( ) [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] . value , <NUM_LIT:0> ) <EOL> promotedIndex . setValue ( <NUM_LIT:1> ) <EOL> self . assertEqual ( box [ "<STR_LIT>" ] . state ( ) [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] . value , <NUM_LIT:1> ) <EOL> def testRepeatability ( self ) : <EOL> s1 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s2 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> sn1 = GafferRenderMan . RenderManShader ( ) <EOL> sn2 = GafferRenderMan . RenderManShader ( ) <EOL> sn1 . loadShader ( s1 ) <EOL> sn2 . loadShader ( s2 ) <EOL> sn2 [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( sn1 [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( sn2 . stateHash ( ) , sn2 . stateHash ( ) ) <EOL> self . assertEqual ( sn2 . state ( ) , sn2 . state ( ) ) <EOL> def testHandlesAreHumanReadable ( self ) : <EOL> s1 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s2 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> sn1 = GafferRenderMan . RenderManShader ( "<STR_LIT>" ) <EOL> sn2 = GafferRenderMan . RenderManShader ( "<STR_LIT>" ) <EOL> sn1 . loadShader ( s1 ) <EOL> sn2 . loadShader ( s2 ) <EOL> sn2 [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( sn1 [ "<STR_LIT>" ] ) <EOL> state = sn2 . state ( ) <EOL> self . assertTrue ( "<STR_LIT>" in state [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] . value ) <EOL> def testHandlesAreUniqueEvenIfNodeNamesArent ( self ) : <EOL> s1 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s2 = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> script = Gaffer . ScriptNode ( ) <EOL> script [ "<STR_LIT>" ] = GafferRenderMan . RenderManShader ( ) <EOL> script [ "<STR_LIT>" ] . loadShader ( s1 ) <EOL> script [ "<STR_LIT>" ] = GafferRenderMan . RenderManShader ( ) <EOL> script [ "<STR_LIT>" ] . loadShader ( s1 ) <EOL> script [ "<STR_LIT>" ] = GafferRenderMan . RenderManShader ( ) <EOL> script [ "<STR_LIT>" ] . loadShader ( s2 ) <EOL> script [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:0> ] . setInput ( script [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> script [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ <NUM_LIT:1> ] . setInput ( script [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> box = Gaffer . Box . create ( script , Gaffer . StandardSet ( [ script [ "<STR_LIT>" ] ] ) ) <EOL> box [ "<STR_LIT>" ] . setName ( "<STR_LIT>" ) <EOL> script [ "<STR_LIT>" ] . setName ( "<STR_LIT>" ) <EOL> state = script [ "<STR_LIT>" ] . state ( ) <EOL> self . assertNotEqual ( state [ <NUM_LIT:0> ] . parameters [ "<STR_LIT>" ] , state [ <NUM_LIT:1> ] . parameters [ "<STR_LIT>" ] ) <EOL> def testShaderTypesInState ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode . loadShader ( coshader ) <EOL> shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( coshaderNode [ "<STR_LIT>" ] ) <EOL> state = shaderNode . state ( ) <EOL> self . assertEqual ( state [ <NUM_LIT:0> ] . type , "<STR_LIT>" ) <EOL> self . assertEqual ( state [ <NUM_LIT:1> ] . type , "<STR_LIT>" ) <EOL> def testAssignmentAttributeName ( self ) : <EOL> p = GafferScene . Plane ( ) <EOL> s = GafferRenderMan . RenderManShader ( ) <EOL> s . loadShader ( "<STR_LIT>" ) <EOL> a = GafferScene . ShaderAssignment ( ) <EOL> a [ "<STR_LIT>" ] . setInput ( p [ "<STR_LIT>" ] ) <EOL> a [ "<STR_LIT>" ] . setInput ( s [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( a [ "<STR_LIT>" ] . attributes ( "<STR_LIT>" ) . keys ( ) , [ "<STR_LIT>" ] ) <EOL> def testVolumeShader ( self ) : <EOL> s = GafferRenderMan . RenderManShader ( ) <EOL> s . loadShader ( "<STR_LIT>" ) <EOL> self . assertEqual ( s [ "<STR_LIT:type>" ] . getValue ( ) , "<STR_LIT>" ) <EOL> s [ "<STR_LIT:type>" ] . setValue ( "<STR_LIT>" ) <EOL> s . loadShader ( "<STR_LIT>" , keepExistingValues = True ) <EOL> self . assertEqual ( s [ "<STR_LIT:type>" ] . getValue ( ) , "<STR_LIT>" ) <EOL> s . loadShader ( "<STR_LIT>" , keepExistingValues = False ) <EOL> self . assertEqual ( s [ "<STR_LIT:type>" ] . getValue ( ) , "<STR_LIT>" ) <EOL> def testInputAcceptanceFromDots ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshaderNode = GafferRenderMan . RenderManShader ( ) <EOL> coshaderNode . loadShader ( coshader ) <EOL> dot = Gaffer . Dot ( ) <EOL> dot . setup ( coshaderNode [ "<STR_LIT>" ] ) <EOL> self . assertTrue ( shaderNode [ "<STR_LIT>" ] [ "<STR_LIT>" ] . acceptsInput ( dot [ "<STR_LIT>" ] ) ) <EOL> def testShaderTypeOverride ( self ) : <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> shaderNode = GafferRenderMan . RenderManShader ( ) <EOL> shaderNode . loadShader ( shader ) <EOL> self . assertEqual ( shaderNode [ '<STR_LIT:type>' ] . getValue ( ) , "<STR_LIT>" ) <EOL> def testReferencePromotedCoshader ( self ) : <EOL> s = Gaffer . ScriptNode ( ) <EOL> shader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> coshader = self . compileShader ( os . path . dirname ( __file__ ) + "<STR_LIT>" ) <EOL> s [ "<STR_LIT:b>" ] = Gaffer . Box ( ) <EOL> s [ "<STR_LIT:b>" ] [ "<STR_LIT:s>" ] = GafferRenderMan . RenderManShader ( ) <EOL> s [ "<STR_LIT:b>" ] [ "<STR_LIT:s>" ] . loadShader ( shader ) <EOL> p = s [ "<STR_LIT:b>" ] . promotePlug ( s [ "<STR_LIT:b>" ] [ "<STR_LIT:s>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> p . setName ( "<STR_LIT:p>" ) <EOL> s [ "<STR_LIT:c>" ] = GafferRenderMan . RenderManShader ( ) <EOL> s [ "<STR_LIT:c>" ] . loadShader ( coshader ) <EOL> self . assertTrue ( s [ "<STR_LIT:b>" ] [ "<STR_LIT:p>" ] . acceptsInput ( s [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) ) <EOL> s [ "<STR_LIT:b>" ] . exportForReference ( self . temporaryDirectory ( ) + "<STR_LIT>" ) <EOL> s [ "<STR_LIT:r>" ] = Gaffer . Reference ( ) <EOL> s [ "<STR_LIT:r>" ] . load ( self . temporaryDirectory ( ) + "<STR_LIT>" ) <EOL> self . assertTrue ( s [ "<STR_LIT:r>" ] [ "<STR_LIT:p>" ] . acceptsInput ( s [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) ) <EOL> def testLoadAndGIL ( self ) : <EOL> script = Gaffer . ScriptNode ( ) <EOL> script [ "<STR_LIT>" ] = GafferScene . Plane ( ) <EOL> script [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( IECore . V2i ( <NUM_LIT:20> ) ) <EOL> script [ "<STR_LIT>" ] = GafferScene . Sphere ( ) <EOL> script [ "<STR_LIT>" ] = Gaffer . Expression ( ) <EOL> script [ "<STR_LIT>" ] . setExpression ( "<STR_LIT>" ) <EOL> script [ "<STR_LIT>" ] = GafferScene . Instancer ( ) <EOL> script [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( script [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> script [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( script [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> script [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> script [ "<STR_LIT>" ] = GafferRenderMan . RenderManShader ( ) <EOL> script [ "<STR_LIT>" ] = GafferScene . ShaderAssignment ( ) <EOL> script [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( script [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> script [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setInput ( script [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> traverseConnection = Gaffer . ScopedConnection ( GafferSceneTest . connectTraverseSceneToPlugDirtiedSignal ( script [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) ) <EOL> script [ "<STR_LIT>" ] . loadShader ( "<STR_LIT>" ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
