<s> from __future__ import with_statement <EOL> import os <EOL> import unittest <EOL> import datetime <EOL> import IECore <EOL> import Gaffer <EOL> import GafferTest <EOL> import GafferCortex <EOL> import GafferCortexTest <EOL> class ParameterisedHolderTest ( GafferTest . TestCase ) : <EOL> @ staticmethod <EOL> def classSpecification ( className , searchPathEnvVar ) : <EOL> return ( <EOL> className , <EOL> IECore . ClassLoader . defaultLoader ( searchPathEnvVar ) . versions ( className ) [ - <NUM_LIT:1> ] , <EOL> searchPathEnvVar <EOL> ) <EOL> def testCreateEmpty ( self ) : <EOL> n = GafferCortex . ParameterisedHolderNode ( ) <EOL> self . assertEqual ( n . getName ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( n . getParameterised ( ) , ( None , "<STR_LIT>" , - <NUM_LIT:1> , "<STR_LIT>" ) ) <EOL> def testSetParameterisedWithoutClassLoader ( self ) : <EOL> n = GafferCortex . ParameterisedHolderNode ( ) <EOL> op = IECore . SequenceRenumberOp ( ) <EOL> n . setParameterised ( op ) <EOL> self . assertEqual ( n . getParameterised ( ) , ( op , "<STR_LIT>" , - <NUM_LIT:1> , "<STR_LIT>" ) ) <EOL> def testSimplePlugTypes ( self ) : <EOL> n = GafferCortex . ParameterisedHolderNode ( ) <EOL> op = IECore . SequenceRenumberOp ( ) <EOL> n . setParameterised ( op ) <EOL> self . failUnless ( isinstance ( n [ "<STR_LIT>" ] [ "<STR_LIT:src>" ] , Gaffer . StringPlug ) ) <EOL> self . failUnless ( isinstance ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . StringPlug ) ) <EOL> self . failUnless ( isinstance ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . IntPlug ) ) <EOL> self . failUnless ( isinstance ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . IntPlug ) ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT:src>" ] . defaultValue ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT:src>" ] . getValue ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0> ) <EOL> for k in op . parameters ( ) . keys ( ) : <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ k ] . defaultValue ( ) , op . parameters ( ) [ k ] . defaultValue . value ) <EOL> with n . parameterModificationContext ( ) as parameters : <EOL> parameters [ "<STR_LIT>" ] . setNumericValue ( <NUM_LIT:10> ) <EOL> parameters [ "<STR_LIT>" ] . setTypedValue ( self . temporaryDirectory ( ) + "<STR_LIT>" ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:10> ) <EOL> self . assertEqual ( n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , self . temporaryDirectory ( ) + "<STR_LIT>" ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:20> ) <EOL> n [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( "<STR_LIT>" ) <EOL> n . setParameterisedValues ( ) <EOL> self . assertEqual ( op [ "<STR_LIT>" ] . getNumericValue ( ) , <NUM_LIT:20> ) <EOL> self . assertEqual ( op [ "<STR_LIT>" ] . getTypedValue ( ) , "<STR_LIT>" ) <EOL> def testVectorTypedParameter ( self ) : <EOL> p = IECore . Parameterised ( "<STR_LIT>" ) <EOL> p . parameters ( ) . addParameters ( <EOL> [ <EOL> IECore . BoolVectorParameter ( "<STR_LIT>" , "<STR_LIT>" , IECore . BoolVectorData ( ) ) , <EOL> IECore . IntVectorParameter ( "<STR_LIT>" , "<STR_LIT>" , IECore . IntVectorData ( ) ) , <EOL> IECore . FloatVectorParameter ( "<STR_LIT>" , "<STR_LIT>" , IECore . FloatVectorData ( ) ) , <EOL> IECore . StringVectorParameter ( "<STR_LIT>" , "<STR_LIT>" , IECore . StringVectorData ( ) ) , <EOL> IECore . V3fVectorParameter ( "<STR_LIT>" , "<STR_LIT>" , IECore . V3fVectorData ( ) ) , <EOL> ] <EOL> ) <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( p ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , IECore . BoolVectorData ( ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , IECore . IntVectorData ( ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , IECore . FloatVectorData ( ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , IECore . StringVectorData ( ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , IECore . V3fVectorData ( ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . BoolVectorData ( ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . IntVectorData ( ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . FloatVectorData ( ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . StringVectorData ( ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . V3fVectorData ( ) ) <EOL> with ph . parameterModificationContext ( ) as parameters : <EOL> parameters [ "<STR_LIT>" ] . setValue ( IECore . BoolVectorData ( [ True , False ] ) ) <EOL> parameters [ "<STR_LIT>" ] . setValue ( IECore . IntVectorData ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) ) <EOL> parameters [ "<STR_LIT>" ] . setValue ( IECore . FloatVectorData ( [ <NUM_LIT:1> ] ) ) <EOL> parameters [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ "<STR_LIT:a>" ] ) ) <EOL> parameters [ "<STR_LIT>" ] . setValue ( IECore . V3fVectorData ( [ IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ] ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . BoolVectorData ( [ True , False ] ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . IntVectorData ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . FloatVectorData ( [ <NUM_LIT:1> ] ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . StringVectorData ( [ "<STR_LIT:a>" ] ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . V3fVectorData ( [ IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ] ) ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( IECore . BoolVectorData ( [ True , True ] ) ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( IECore . IntVectorData ( [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ) ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( IECore . FloatVectorData ( [ <NUM_LIT:2> ] ) ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( IECore . StringVectorData ( [ "<STR_LIT:b>" ] ) ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( IECore . V3fVectorData ( [ IECore . V3f ( <NUM_LIT:10> , <NUM_LIT:20> , <NUM_LIT:30> ) ] ) ) <EOL> ph . setParameterisedValues ( ) <EOL> self . assertEqual ( parameters [ "<STR_LIT>" ] . getValue ( ) , IECore . BoolVectorData ( [ True , True ] ) ) <EOL> self . assertEqual ( parameters [ "<STR_LIT>" ] . getValue ( ) , IECore . IntVectorData ( [ <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ) ) <EOL> self . assertEqual ( parameters [ "<STR_LIT>" ] . getValue ( ) , IECore . FloatVectorData ( [ <NUM_LIT:2> ] ) ) <EOL> self . assertEqual ( parameters [ "<STR_LIT>" ] . getValue ( ) , IECore . StringVectorData ( [ "<STR_LIT:b>" ] ) ) <EOL> self . assertEqual ( parameters [ "<STR_LIT>" ] . getValue ( ) , IECore . V3fVectorData ( [ IECore . V3f ( <NUM_LIT:10> , <NUM_LIT:20> , <NUM_LIT:30> ) ] ) ) <EOL> def testNoHostMapping ( self ) : <EOL> p = IECore . Parameterised ( "<STR_LIT>" ) <EOL> p . parameters ( ) . addParameters ( <EOL> [ <EOL> IECore . IntParameter ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:1> , userData = { "<STR_LIT>" : IECore . BoolData ( False ) } ) , <EOL> IECore . IntParameter ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:2> , userData = { "<STR_LIT>" : IECore . BoolData ( True ) } ) , <EOL> IECore . IntParameter ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:2> ) , <EOL> ] <EOL> ) <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( p ) <EOL> self . failUnless ( "<STR_LIT>" in ph [ "<STR_LIT>" ] ) <EOL> self . failIf ( "<STR_LIT>" in ph [ "<STR_LIT>" ] ) <EOL> self . failUnless ( "<STR_LIT>" in ph [ "<STR_LIT>" ] ) <EOL> def testCreateWithNonDefaultValues ( self ) : <EOL> p = IECore . Parameterised ( "<STR_LIT>" ) <EOL> p . parameters ( ) . addParameter ( IECore . IntParameter ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:1> , ) ) <EOL> p [ "<STR_LIT>" ] . setNumericValue ( <NUM_LIT:10> ) <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( p ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:10> ) <EOL> def testCompoundNumericTypes ( self ) : <EOL> p = IECore . Parameterised ( "<STR_LIT>" ) <EOL> p . parameters ( ) . addParameters ( <EOL> [ <EOL> IECore . V2iParameter ( "<STR_LIT>" , "<STR_LIT>" , IECore . V2i ( <NUM_LIT:1> , <NUM_LIT:2> ) ) , <EOL> IECore . V3fParameter ( "<STR_LIT>" , "<STR_LIT>" , IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) , <EOL> IECore . Color4fParameter ( "<STR_LIT>" , "<STR_LIT>" , IECore . Color4f ( <NUM_LIT> , <NUM_LIT:0.5> , <NUM_LIT> , <NUM_LIT:1> ) ) , <EOL> ] <EOL> ) <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( p ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , IECore . V2i ( <NUM_LIT:1> , <NUM_LIT:2> ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . defaultValue ( ) , IECore . Color4f ( <NUM_LIT> , <NUM_LIT:0.5> , <NUM_LIT> , <NUM_LIT:1> ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . V2i ( <NUM_LIT:1> , <NUM_LIT:2> ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . V3f ( <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . Color4f ( <NUM_LIT> , <NUM_LIT:0.5> , <NUM_LIT> , <NUM_LIT:1> ) ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( IECore . V2i ( <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( IECore . V3f ( <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ) ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( IECore . Color4f ( <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0.5> ) ) <EOL> ph . setParameterisedValues ( ) <EOL> self . assertEqual ( p [ "<STR_LIT>" ] . getTypedValue ( ) , IECore . V2i ( <NUM_LIT:2> , <NUM_LIT:3> ) ) <EOL> self . assertEqual ( p [ "<STR_LIT>" ] . getTypedValue ( ) , IECore . V3f ( <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ) ) <EOL> self . assertEqual ( p [ "<STR_LIT>" ] . getTypedValue ( ) , IECore . Color4f ( <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT:0.5> ) ) <EOL> def testParameterHandlerMethod ( self ) : <EOL> p = IECore . Parameterised ( "<STR_LIT>" ) <EOL> p . parameters ( ) . addParameter ( IECore . IntParameter ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:1> , ) ) <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( p ) <EOL> h = ph . parameterHandler ( ) <EOL> self . failUnless ( isinstance ( h , GafferCortex . CompoundParameterHandler ) ) <EOL> self . failUnless ( h . parameter ( ) . isSame ( p . parameters ( ) ) ) <EOL> self . failUnless ( h . plug ( ) . isSame ( ph [ "<STR_LIT>" ] ) ) <EOL> def testBoxTypes ( self ) : <EOL> p = IECore . Parameterised ( "<STR_LIT>" ) <EOL> p . parameters ( ) . addParameters ( <EOL> [ <EOL> IECore . Box3iParameter ( <EOL> "<STR_LIT:b>" , <EOL> "<STR_LIT>" , <EOL> IECore . Box3i ( <EOL> IECore . V3i ( - <NUM_LIT:1> , - <NUM_LIT:2> , - <NUM_LIT:3> ) , <EOL> IECore . V3i ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:3> ) , <EOL> ) , <EOL> ) <EOL> ] <EOL> ) <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( p ) <EOL> self . failUnless ( isinstance ( ph [ "<STR_LIT>" ] [ "<STR_LIT:b>" ] , Gaffer . Box3iPlug ) ) <EOL> self . failUnless ( isinstance ( ph [ "<STR_LIT>" ] [ "<STR_LIT:b>" ] [ "<STR_LIT>" ] , Gaffer . V3iPlug ) ) <EOL> self . failUnless ( isinstance ( ph [ "<STR_LIT>" ] [ "<STR_LIT:b>" ] [ "<STR_LIT>" ] , Gaffer . V3iPlug ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:b>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . V3i ( - <NUM_LIT:1> , - <NUM_LIT:2> , - <NUM_LIT:3> ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:b>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . V3i ( <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:3> ) ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT:b>" ] [ "<STR_LIT>" ] . setValue ( IECore . V3i ( - <NUM_LIT:10> , - <NUM_LIT:20> , - <NUM_LIT:30> ) ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT:b>" ] [ "<STR_LIT>" ] . setValue ( IECore . V3i ( <NUM_LIT:10> , <NUM_LIT:20> , <NUM_LIT:30> ) ) <EOL> ph . parameterHandler ( ) . setParameterValue ( ) <EOL> self . assertEqual ( <EOL> p [ "<STR_LIT:b>" ] . getTypedValue ( ) , <EOL> IECore . Box3i ( IECore . V3i ( - <NUM_LIT:10> , - <NUM_LIT:20> , - <NUM_LIT:30> ) , IECore . V3i ( <NUM_LIT:10> , <NUM_LIT:20> , <NUM_LIT:30> ) ) <EOL> ) <EOL> with ph . parameterModificationContext ( ) : <EOL> p [ "<STR_LIT:b>" ] . setTypedValue ( IECore . Box3i ( IECore . V3i ( - <NUM_LIT:2> , - <NUM_LIT:4> , - <NUM_LIT:6> ) , IECore . V3i ( <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:6> ) ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:b>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . V3i ( - <NUM_LIT:2> , - <NUM_LIT:4> , - <NUM_LIT:6> ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:b>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . V3i ( <NUM_LIT:2> , <NUM_LIT:4> , <NUM_LIT:6> ) ) <EOL> def testAddAndRemoveParameters ( self ) : <EOL> p = IECore . Parameterised ( "<STR_LIT>" ) <EOL> p . parameters ( ) . addParameter ( <EOL> IECore . IntParameter ( <EOL> "<STR_LIT:a>" , <EOL> "<STR_LIT>" , <EOL> <NUM_LIT:1> <EOL> ) <EOL> ) <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( p ) <EOL> self . failUnless ( isinstance ( ph [ "<STR_LIT>" ] , Gaffer . CompoundPlug ) ) <EOL> self . failUnless ( isinstance ( ph [ "<STR_LIT>" ] [ "<STR_LIT:a>" ] , Gaffer . IntPlug ) ) <EOL> self . assertEqual ( len ( ph [ "<STR_LIT>" ] ) , <NUM_LIT:1> ) <EOL> with ph . parameterModificationContext ( ) : <EOL> p . parameters ( ) . removeParameter ( p . parameters ( ) [ "<STR_LIT:a>" ] ) <EOL> p . parameters ( ) . addParameter ( IECore . IntParameter ( "<STR_LIT:b>" , "<STR_LIT>" , <NUM_LIT:2> ) ) <EOL> self . failUnless ( isinstance ( ph [ "<STR_LIT>" ] , Gaffer . CompoundPlug ) ) <EOL> self . failUnless ( isinstance ( ph [ "<STR_LIT>" ] [ "<STR_LIT:b>" ] , Gaffer . IntPlug ) ) <EOL> self . assertEqual ( len ( ph [ "<STR_LIT>" ] ) , <NUM_LIT:1> ) <EOL> def testParameterChangingType ( self ) : <EOL> p = IECore . Parameterised ( "<STR_LIT>" ) <EOL> p . parameters ( ) . addParameter ( <EOL> IECore . IntParameter ( <EOL> "<STR_LIT:a>" , <EOL> "<STR_LIT>" , <EOL> <NUM_LIT:1> <EOL> ) <EOL> ) <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( p ) <EOL> self . failUnless ( isinstance ( ph [ "<STR_LIT>" ] , Gaffer . CompoundPlug ) ) <EOL> self . failUnless ( isinstance ( ph [ "<STR_LIT>" ] [ "<STR_LIT:a>" ] , Gaffer . IntPlug ) ) <EOL> self . assertEqual ( len ( ph [ "<STR_LIT>" ] ) , <NUM_LIT:1> ) <EOL> with ph . parameterModificationContext ( ) : <EOL> p . parameters ( ) . removeParameter ( p . parameters ( ) [ "<STR_LIT:a>" ] ) <EOL> p . parameters ( ) . addParameter ( IECore . FloatParameter ( "<STR_LIT:a>" , "<STR_LIT>" , <NUM_LIT:2> ) ) <EOL> self . failUnless ( isinstance ( ph [ "<STR_LIT>" ] , Gaffer . CompoundPlug ) ) <EOL> self . failUnless ( isinstance ( ph [ "<STR_LIT>" ] [ "<STR_LIT:a>" ] , Gaffer . FloatPlug ) ) <EOL> self . assertEqual ( len ( ph [ "<STR_LIT>" ] ) , <NUM_LIT:1> ) <EOL> def testParameterHandlerIsConstant ( self ) : <EOL> p = IECore . Parameterised ( "<STR_LIT>" ) <EOL> phn = GafferCortex . ParameterisedHolderNode ( ) <EOL> phn . setParameterised ( p ) <EOL> ph = phn . parameterHandler ( ) <EOL> with phn . parameterModificationContext ( ) : <EOL> p . parameters ( ) . addParameter ( IECore . FloatParameter ( "<STR_LIT:a>" , "<STR_LIT>" , <NUM_LIT:2> ) ) <EOL> self . failUnless ( ph . isSame ( phn . parameterHandler ( ) ) ) <EOL> def testClassLoading ( self ) : <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> classSpec = self . classSpecification ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ph . setParameterised ( * classSpec ) <EOL> p = ph . getParameterised ( ) <EOL> self . assertEqual ( p [ <NUM_LIT:0> ] . typeName ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( p [ <NUM_LIT:1> ] , "<STR_LIT>" ) <EOL> self . assertEqual ( p [ <NUM_LIT:2> ] , classSpec [ <NUM_LIT:1> ] ) <EOL> self . assertEqual ( p [ <NUM_LIT:3> ] , "<STR_LIT>" ) <EOL> def testRunTimeTyped ( self ) : <EOL> n = GafferCortex . ParameterisedHolderNode ( ) <EOL> self . assertEqual ( n . typeName ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( IECore . RunTimeTyped . typeNameFromTypeId ( n . typeId ( ) ) , "<STR_LIT>" ) <EOL> self . assertEqual ( IECore . RunTimeTyped . baseTypeId ( n . typeId ( ) ) , Gaffer . Node . staticTypeId ( ) ) <EOL> def testSerialisation ( self ) : <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> classSpec = self . classSpecification ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> ph . setParameterised ( * classSpec ) <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT:n>" ] = ph <EOL> s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT> ) <EOL> ss = s . serialise ( ) <EOL> s = Gaffer . ScriptNode ( ) <EOL> s . execute ( ss ) <EOL> self . failUnless ( "<STR_LIT:n>" in s ) <EOL> parameterised = s [ "<STR_LIT:n>" ] . getParameterised ( ) <EOL> self . assertEqual ( parameterised [ <NUM_LIT:1> : ] , classSpec ) <EOL> self . assertEqual ( parameterised [ <NUM_LIT:0> ] . typeName ( ) , "<STR_LIT>" ) <EOL> self . assertEqual ( s [ "<STR_LIT:n>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT> ) <EOL> def testKeepExistingValues ( self ) : <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( IECore . Grade ( ) ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( IECore . Color3f ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> ph . setParameterised ( IECore . Grade ( ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . Color3f ( <NUM_LIT:0> ) ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( IECore . Color3f ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> ph . setParameterised ( IECore . Grade ( ) , keepExistingValues = True ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , IECore . Color3f ( <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ) ) <EOL> def testDateTimeParameter ( self ) : <EOL> p = IECore . Parameterised ( "<STR_LIT>" ) <EOL> now = datetime . datetime . now ( ) <EOL> p . parameters ( ) . addParameters ( <EOL> [ <EOL> IECore . DateTimeParameter ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> now <EOL> ) <EOL> ] <EOL> ) <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( p ) <EOL> self . failUnless ( isinstance ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] , Gaffer . StringPlug ) ) <EOL> ph . parameterHandler ( ) . setParameterValue ( ) <EOL> self . assertEqual ( p [ "<STR_LIT>" ] . getValue ( ) , IECore . DateTimeData ( now ) ) <EOL> tomorrow = now + datetime . timedelta ( days = <NUM_LIT:1> ) <EOL> p [ "<STR_LIT>" ] . setValue ( IECore . DateTimeData ( tomorrow ) ) <EOL> ph . parameterHandler ( ) . setPlugValue ( ) <EOL> ph . parameterHandler ( ) . setParameterValue ( ) <EOL> self . assertEqual ( p [ "<STR_LIT>" ] . getValue ( ) , IECore . DateTimeData ( tomorrow ) ) <EOL> def testClassParameter ( self ) : <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( "<STR_LIT>" , <NUM_LIT:1> , "<STR_LIT>" ) <EOL> p = ph . getParameterised ( ) [ <NUM_LIT:0> ] <EOL> with ph . parameterModificationContext ( ) : <EOL> p [ "<STR_LIT:class>" ] . setClass ( * self . classSpecification ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> seqLsParameterNames = p [ "<STR_LIT:class>" ] . keys ( ) <EOL> for n in seqLsParameterNames : <EOL> self . failUnless ( n in ph [ "<STR_LIT>" ] [ "<STR_LIT:class>" ] ) <EOL> with ph . parameterModificationContext ( ) : <EOL> p [ "<STR_LIT:class>" ] . setClass ( "<STR_LIT>" , <NUM_LIT:0> ) <EOL> for n in seqLsParameterNames : <EOL> self . failIf ( n in ph [ "<STR_LIT>" ] [ "<STR_LIT:class>" ] ) <EOL> def testClassParameterSerialisation ( self ) : <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT>" ] = GafferCortex . ParameterisedHolderNode ( ) <EOL> s [ "<STR_LIT>" ] . setParameterised ( "<STR_LIT>" , <NUM_LIT:1> , "<STR_LIT>" ) <EOL> p = s [ "<STR_LIT>" ] . getParameterised ( ) [ <NUM_LIT:0> ] <EOL> classSpec = self . classSpecification ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> with s [ "<STR_LIT>" ] . parameterModificationContext ( ) : <EOL> p [ "<STR_LIT:class>" ] . setClass ( * classSpec ) <EOL> classPlugNames = s [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT:class>" ] . keys ( ) <EOL> for k in p [ "<STR_LIT:class>" ] . keys ( ) : <EOL> self . failUnless ( k in classPlugNames ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT:class>" ] [ "<STR_LIT>" ] . setValue ( True ) <EOL> ss = s . serialise ( ) <EOL> s2 = Gaffer . ScriptNode ( ) <EOL> s2 . execute ( ss ) <EOL> self . assertEqual ( s2 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT:class>" ] . keys ( ) , classPlugNames ) <EOL> p2 = s2 [ "<STR_LIT>" ] . getParameterised ( ) [ <NUM_LIT:0> ] <EOL> self . assertEqual ( p2 [ "<STR_LIT:class>" ] . getClass ( True ) [ <NUM_LIT:1> : ] , classSpec ) <EOL> s2 [ "<STR_LIT>" ] . parameterHandler ( ) . setParameterValue ( ) <EOL> self . assertEqual ( p2 [ "<STR_LIT:class>" ] [ "<STR_LIT>" ] . getTypedValue ( ) , True ) <EOL> def testClassVectorParameter ( self ) : <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( "<STR_LIT>" , <NUM_LIT:1> , "<STR_LIT>" ) <EOL> p = ph . getParameterised ( ) [ <NUM_LIT:0> ] <EOL> seqLsClassSpec = self . classSpecification ( "<STR_LIT>" , "<STR_LIT>" ) [ : <NUM_LIT:2> ] <EOL> gradeClassSpec = self . classSpecification ( "<STR_LIT>" , "<STR_LIT>" ) [ : <NUM_LIT:2> ] <EOL> classes = [ <EOL> ( "<STR_LIT>" , ) + seqLsClassSpec , <EOL> ( "<STR_LIT>" , ) + gradeClassSpec , <EOL> ] <EOL> with ph . parameterModificationContext ( ) : <EOL> p [ "<STR_LIT>" ] . setClasses ( classes ) <EOL> seqLsParameterNames = p [ "<STR_LIT>" ] [ "<STR_LIT>" ] . keys ( ) <EOL> for n in seqLsParameterNames : <EOL> self . failUnless ( n in ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> gradeParameterNames = p [ "<STR_LIT>" ] [ "<STR_LIT>" ] . keys ( ) <EOL> for n in gradeParameterNames : <EOL> self . failUnless ( n in ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> with ph . parameterModificationContext ( ) : <EOL> p [ "<STR_LIT>" ] . setClasses ( [ ] ) <EOL> for k in ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . keys ( ) : <EOL> self . failUnless ( k . startswith ( "<STR_LIT>" ) ) <EOL> def testClassVectorParameterMaintainsPlugValues ( self ) : <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( "<STR_LIT>" , <NUM_LIT:1> , "<STR_LIT>" ) <EOL> p = ph . getParameterised ( ) [ <NUM_LIT:0> ] <EOL> seqLsClassSpec = self . classSpecification ( "<STR_LIT>" , "<STR_LIT>" ) [ : <NUM_LIT:2> ] <EOL> gradeClassSpec = self . classSpecification ( "<STR_LIT>" , "<STR_LIT>" ) [ : <NUM_LIT:2> ] <EOL> classes = [ <EOL> ( "<STR_LIT>" , ) + gradeClassSpec , <EOL> ] <EOL> with ph . parameterModificationContext ( ) : <EOL> p [ "<STR_LIT>" ] . setClasses ( classes ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:15> ) <EOL> ph . setParameterisedValues ( ) <EOL> classes . append ( ( "<STR_LIT>" , ) + seqLsClassSpec ) <EOL> with ph . parameterModificationContext ( ) : <EOL> p [ "<STR_LIT>" ] . setClasses ( classes ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:15> ) <EOL> def testClassVectorParameterSerialisation ( self ) : <EOL> s = Gaffer . ScriptNode ( ) <EOL> s [ "<STR_LIT>" ] = GafferCortex . ParameterisedHolderNode ( ) <EOL> s [ "<STR_LIT>" ] . setParameterised ( "<STR_LIT>" , <NUM_LIT:1> , "<STR_LIT>" ) <EOL> p = s [ "<STR_LIT>" ] . getParameterised ( ) [ <NUM_LIT:0> ] <EOL> gradeClassSpec = self . classSpecification ( "<STR_LIT>" , "<STR_LIT>" ) [ : <NUM_LIT:2> ] <EOL> classes = [ <EOL> ( "<STR_LIT>" , ) + gradeClassSpec , <EOL> ] <EOL> with s [ "<STR_LIT>" ] . parameterModificationContext ( ) : <EOL> p [ "<STR_LIT>" ] . setClasses ( classes ) <EOL> s [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:12> ) <EOL> ss = s . serialise ( ) <EOL> s2 = Gaffer . ScriptNode ( ) <EOL> s2 . execute ( ss ) <EOL> self . assertEqual ( s2 [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:12> ) <EOL> def testTimeCodeParameter ( self ) : <EOL> p = IECore . Parameterised ( "<STR_LIT>" ) <EOL> p . parameters ( ) . addParameters ( <EOL> [ <EOL> IECore . TimeCodeParameter ( <EOL> "<STR_LIT:t>" , <EOL> "<STR_LIT>" , <EOL> IECore . TimeCode ( <EOL> hours = <NUM_LIT:10> , <EOL> minutes = <NUM_LIT:15> , <EOL> seconds = <NUM_LIT:1> , <EOL> frame = <NUM_LIT:12> , <EOL> ) <EOL> ) <EOL> ] <EOL> ) <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( p ) <EOL> self . failUnless ( "<STR_LIT:t>" in ph [ "<STR_LIT>" ] ) <EOL> self . failUnless ( isinstance ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] , Gaffer . CompoundPlug ) ) <EOL> self . failUnless ( isinstance ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] , Gaffer . IntPlug ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . minValue ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . maxValue ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . defaultValue ( ) , <NUM_LIT:10> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:10> ) <EOL> self . failUnless ( isinstance ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] , Gaffer . IntPlug ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . minValue ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . maxValue ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . defaultValue ( ) , <NUM_LIT:15> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:15> ) <EOL> self . failUnless ( isinstance ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] , Gaffer . IntPlug ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . minValue ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . maxValue ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . defaultValue ( ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:1> ) <EOL> self . failUnless ( isinstance ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] , Gaffer . IntPlug ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . minValue ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . maxValue ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . defaultValue ( ) , <NUM_LIT:12> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:12> ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:11> ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:10> ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:2> ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:20> ) <EOL> ph . parameterHandler ( ) . setParameterValue ( ) <EOL> tc = p [ "<STR_LIT:t>" ] . getTypedValue ( ) <EOL> self . assertEqual ( tc . hours ( ) , <NUM_LIT:11> ) <EOL> self . assertEqual ( tc . minutes ( ) , <NUM_LIT:10> ) <EOL> self . assertEqual ( tc . seconds ( ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( tc . frame ( ) , <NUM_LIT:20> ) <EOL> with ph . parameterModificationContext ( ) : <EOL> tc . setHours ( <NUM_LIT:1> ) <EOL> tc . setMinutes ( <NUM_LIT:2> ) <EOL> tc . setSeconds ( <NUM_LIT:3> ) <EOL> tc . setFrame ( <NUM_LIT:4> ) <EOL> p [ "<STR_LIT:t>" ] . setTypedValue ( tc ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:t>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:4> ) <EOL> def testParameterChangedCanChangeValues ( self ) : <EOL> class ParameterChanger ( IECore . Parameterised ) : <EOL> def __init__ ( self ) : <EOL> IECore . Parameterised . __init__ ( self , "<STR_LIT>" ) <EOL> self . parameters ( ) . addParameters ( <EOL> [ <EOL> IECore . IntParameter ( <EOL> name = "<STR_LIT>" , <EOL> description = "<STR_LIT>" , <EOL> ) , <EOL> IECore . IntParameter ( <EOL> name = "<STR_LIT>" , <EOL> description = "<STR_LIT>" , <EOL> ) , <EOL> ] , <EOL> ) <EOL> self . changes = [ ] <EOL> def parameterChanged ( self , parameter ) : <EOL> self . changes . append ( ( parameter , parameter . getNumericValue ( ) ) ) <EOL> if parameter . isSame ( self . parameters ( ) [ "<STR_LIT>" ] ) : <EOL> self . parameters ( ) [ "<STR_LIT>" ] . setNumericValue ( parameter . getNumericValue ( ) * <NUM_LIT:2> ) <EOL> c = ParameterChanger ( ) <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( c ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( c . changes ) , <NUM_LIT:0> ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:10> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:10> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:20> ) <EOL> self . assertEqual ( len ( c . changes ) , <NUM_LIT:1> ) <EOL> self . failUnless ( c . changes [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] . isSame ( c [ "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( c . changes [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , <NUM_LIT:10> ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:30> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:10> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:30> ) <EOL> self . assertEqual ( len ( c . changes ) , <NUM_LIT:2> ) <EOL> self . failUnless ( c . changes [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] . isSame ( c [ "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( c . changes [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] , <NUM_LIT:30> ) <EOL> def testParameterChangedWithCompoundParameters ( self ) : <EOL> class ParameterChanger ( IECore . Parameterised ) : <EOL> def __init__ ( self ) : <EOL> IECore . Parameterised . __init__ ( self , "<STR_LIT>" ) <EOL> self . parameters ( ) . addParameters ( <EOL> [ <EOL> IECore . IntParameter ( <EOL> name = "<STR_LIT>" , <EOL> description = "<STR_LIT>" , <EOL> ) , <EOL> IECore . CompoundParameter ( <EOL> name = "<STR_LIT:c>" , <EOL> members = [ <EOL> IECore . IntParameter ( <EOL> "<STR_LIT:i>" , "<STR_LIT>" <EOL> ) , <EOL> IECore . StringParameter ( <EOL> "<STR_LIT:s>" , "<STR_LIT>" , "<STR_LIT>" <EOL> ) , <EOL> ] <EOL> ) , <EOL> ] , <EOL> ) <EOL> self . changes = [ ] <EOL> def parameterChanged ( self , parameter ) : <EOL> pass <EOL> c = ParameterChanger ( ) <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( c ) <EOL> self . failUnless ( "<STR_LIT>" in ph ) <EOL> self . failUnless ( "<STR_LIT:c>" in ph [ "<STR_LIT>" ] ) <EOL> self . failUnless ( "<STR_LIT:i>" in ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] ) <EOL> self . failUnless ( "<STR_LIT:s>" in ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] ) <EOL> def testParameterChangedWithIntermediateClasses ( self ) : <EOL> class ClassParameterChanger ( IECore . Parameterised ) : <EOL> def __init__ ( self ) : <EOL> IECore . Parameterised . __init__ ( self , "<STR_LIT>" ) <EOL> self . parameters ( ) . addParameters ( <EOL> [ <EOL> IECore . IntParameter ( <EOL> name = "<STR_LIT>" , <EOL> description = "<STR_LIT>" , <EOL> ) , <EOL> IECore . IntParameter ( <EOL> name = "<STR_LIT>" , <EOL> description = "<STR_LIT>" , <EOL> ) , <EOL> IECore . CompoundParameter ( <EOL> name = "<STR_LIT:c>" , <EOL> description = "<STR_LIT>" , <EOL> members = [ <EOL> IECore . IntParameter ( <EOL> name = "<STR_LIT>" , <EOL> description = "<STR_LIT>" , <EOL> ) , <EOL> IECore . IntParameter ( <EOL> name = "<STR_LIT>" , <EOL> description = "<STR_LIT>" , <EOL> ) , <EOL> IECore . ClassParameter ( <EOL> name = "<STR_LIT:class>" , <EOL> description = "<STR_LIT>" , <EOL> searchPathEnvVar = "<STR_LIT>" , <EOL> ) , <EOL> IECore . ClassVectorParameter ( <EOL> name = "<STR_LIT>" , <EOL> description = "<STR_LIT>" , <EOL> searchPathEnvVar = "<STR_LIT>" , <EOL> ) , <EOL> ] , <EOL> ) , <EOL> ] , <EOL> ) <EOL> self . changes = [ ] <EOL> def parameterChanged ( self , parameter ) : <EOL> self . changes . append ( ( parameter , str ( parameter . getValue ( ) ) ) ) <EOL> if parameter . isSame ( self . parameters ( ) [ "<STR_LIT>" ] ) : <EOL> self . parameters ( ) [ "<STR_LIT>" ] . setNumericValue ( parameter . getNumericValue ( ) * <NUM_LIT:2> ) <EOL> elif parameter . isSame ( self . parameters ( ) [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) : <EOL> self . parameters ( ) [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] . setNumericValue ( parameter . getNumericValue ( ) * <NUM_LIT:4> ) <EOL> c = ClassParameterChanger ( ) <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( c ) <EOL> with ph . parameterModificationContext ( ) : <EOL> c [ "<STR_LIT:c>" ] [ "<STR_LIT:class>" ] . setClass ( "<STR_LIT>" , <NUM_LIT:1> ) <EOL> c [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] . setClasses ( <EOL> [ <EOL> ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:1> ) , <EOL> ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:1> ) , <EOL> ] <EOL> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( c . changes ) , <NUM_LIT:0> ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:10> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:10> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:20> ) <EOL> self . assertEqual ( len ( c . changes ) , <NUM_LIT:1> ) <EOL> self . failUnless ( c . changes [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] . isSame ( c [ "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( c . changes [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , "<STR_LIT>" ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:30> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:10> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:30> ) <EOL> self . assertEqual ( len ( c . changes ) , <NUM_LIT:2> ) <EOL> self . failUnless ( c . changes [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] . isSame ( c [ "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( c . changes [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] , "<STR_LIT>" ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:0> ) <EOL> self . assertEqual ( len ( c . changes ) , <NUM_LIT:2> ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:10> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:10> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT> ) <EOL> self . assertEqual ( len ( c . changes ) , <NUM_LIT:4> ) <EOL> self . failUnless ( c . changes [ <NUM_LIT:2> ] [ <NUM_LIT:0> ] . isSame ( c [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( c . changes [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] , "<STR_LIT>" ) <EOL> self . failUnless ( c . changes [ <NUM_LIT:3> ] [ <NUM_LIT:0> ] . isSame ( c [ "<STR_LIT:c>" ] ) ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:30> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:10> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:30> ) <EOL> self . assertEqual ( len ( c . changes ) , <NUM_LIT:6> ) <EOL> self . failUnless ( c . changes [ <NUM_LIT:4> ] [ <NUM_LIT:0> ] . isSame ( c [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( c . changes [ <NUM_LIT:4> ] [ <NUM_LIT:1> ] , "<STR_LIT>" ) <EOL> self . failUnless ( c . changes [ <NUM_LIT:5> ] [ <NUM_LIT:0> ] . isSame ( c [ "<STR_LIT:c>" ] ) ) <EOL> c2 = c [ "<STR_LIT:c>" ] [ "<STR_LIT:class>" ] . getClass ( ) <EOL> self . assertEqual ( len ( c2 . changes ) , <NUM_LIT:0> ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] [ "<STR_LIT:class>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:10> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] [ "<STR_LIT:class>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:10> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] [ "<STR_LIT:class>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:50> ) <EOL> self . assertEqual ( len ( c2 . changes ) , <NUM_LIT:1> ) <EOL> self . failUnless ( c2 . changes [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] . isSame ( c2 [ "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( c2 . changes [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , "<STR_LIT>" ) <EOL> c3 = c [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] . getClass ( "<STR_LIT>" ) <EOL> self . assertEqual ( len ( c3 . changes ) , <NUM_LIT:0> ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:10> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:10> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:50> ) <EOL> self . assertEqual ( len ( c3 . changes ) , <NUM_LIT:2> ) <EOL> self . failUnless ( c3 . changes [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] . isSame ( c3 [ "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( c3 . changes [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , "<STR_LIT>" ) <EOL> self . failUnless ( c3 . changes [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] . isSame ( c [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) ) <EOL> c4 = c [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] . getClass ( "<STR_LIT>" ) <EOL> self . assertEqual ( len ( c4 . changes ) , <NUM_LIT:0> ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue ( <NUM_LIT:10> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:10> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] . getValue ( ) , <NUM_LIT:50> ) <EOL> self . assertEqual ( len ( c4 . changes ) , <NUM_LIT:2> ) <EOL> self . failUnless ( c4 . changes [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] . isSame ( c4 [ "<STR_LIT>" ] ) ) <EOL> self . assertEqual ( c4 . changes [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] , "<STR_LIT>" ) <EOL> self . failUnless ( c4 . changes [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] . isSame ( c [ "<STR_LIT:c>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) ) <EOL> def testReadOnly ( self ) : <EOL> p = IECore . Parameterised ( "<STR_LIT>" ) <EOL> p . parameters ( ) . addParameters ( <EOL> [ <EOL> IECore . IntParameter ( <EOL> "<STR_LIT:i>" , <EOL> "<STR_LIT>" , <EOL> <NUM_LIT:1> , <EOL> ) <EOL> ] <EOL> ) <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( p ) <EOL> self . failUnless ( "<STR_LIT>" in ph ) <EOL> self . failUnless ( "<STR_LIT:i>" in ph [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:i>" ] . getValue ( ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:i>" ] . getFlags ( Gaffer . Plug . Flags . ReadOnly ) , False ) <EOL> with ph . parameterModificationContext ( ) : <EOL> p . parameters ( ) [ "<STR_LIT:i>" ] . userData ( ) [ "<STR_LIT>" ] = IECore . CompoundObject ( { <EOL> "<STR_LIT>" : IECore . BoolData ( True ) , <EOL> } ) <EOL> p . parameters ( ) [ "<STR_LIT:i>" ] . setNumericValue ( <NUM_LIT:2> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:i>" ] . getFlags ( Gaffer . Plug . Flags . ReadOnly ) , True ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:i>" ] . getValue ( ) , <NUM_LIT:1> ) <EOL> def testConections ( self ) : <EOL> p = IECore . Parameterised ( "<STR_LIT>" ) <EOL> p . parameters ( ) . addParameters ( <EOL> [ <EOL> IECore . IntParameter ( <EOL> "<STR_LIT:a>" , <EOL> "<STR_LIT>" , <EOL> <NUM_LIT:1> , <EOL> ) , <EOL> IECore . IntParameter ( <EOL> "<STR_LIT:b>" , <EOL> "<STR_LIT>" , <EOL> <NUM_LIT:2> , <EOL> ) <EOL> ] <EOL> ) <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( p ) <EOL> self . failUnless ( "<STR_LIT>" in ph ) <EOL> self . failUnless ( "<STR_LIT:a>" in ph [ "<STR_LIT>" ] ) <EOL> self . failUnless ( "<STR_LIT:b>" in ph [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:a>" ] . getValue ( ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:b>" ] . getValue ( ) , <NUM_LIT:2> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:b>" ] . getInput ( ) , None ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT:b>" ] . setInput ( ph [ "<STR_LIT>" ] [ "<STR_LIT:a>" ] ) <EOL> self . assertTrue ( ph [ "<STR_LIT>" ] [ "<STR_LIT:b>" ] . getInput ( ) . isSame ( ph [ "<STR_LIT>" ] [ "<STR_LIT:a>" ] ) ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:b>" ] . getValue ( ) , <NUM_LIT:1> ) <EOL> ph [ "<STR_LIT>" ] [ "<STR_LIT:a>" ] . setValue ( <NUM_LIT:2> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:b>" ] . getValue ( ) , <NUM_LIT:2> ) <EOL> messageHandler = IECore . CapturingMessageHandler ( ) <EOL> with messageHandler : <EOL> with ph . parameterModificationContext ( ) : <EOL> p . parameters ( ) [ "<STR_LIT:a>" ] . setNumericValue ( <NUM_LIT:3> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:a>" ] . getValue ( ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( ph [ "<STR_LIT>" ] [ "<STR_LIT:b>" ] . getValue ( ) , <NUM_LIT:3> ) <EOL> self . assertEqual ( messageHandler . messages , [ ] ) <EOL> def testExceptionInParameterChanged ( self ) : <EOL> class ParameterChangedRaiser ( IECore . Parameterised ) : <EOL> def __init__ ( self ) : <EOL> IECore . Parameterised . __init__ ( self , "<STR_LIT>" ) <EOL> self . parameters ( ) . addParameters ( <EOL> [ <EOL> IECore . IntParameter ( <EOL> name = "<STR_LIT>" , <EOL> description = "<STR_LIT>" , <EOL> ) , <EOL> ] , <EOL> ) <EOL> self . changes = [ ] <EOL> def parameterChanged ( self , parameter ) : <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> c = ParameterChangedRaiser ( ) <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( c ) <EOL> self . assertRaises ( RuntimeError , ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue , <NUM_LIT:10> ) <EOL> def testParameterInvalidWhenParameterChangedRaises ( self ) : <EOL> class InvalidValueRaiser ( IECore . Parameterised ) : <EOL> def __init__ ( self ) : <EOL> IECore . Parameterised . __init__ ( self , "<STR_LIT>" ) <EOL> self . parameters ( ) . addParameters ( <EOL> [ <EOL> IECore . IntParameter ( <EOL> name = "<STR_LIT>" , <EOL> description = "<STR_LIT>" , <EOL> defaultValue = <NUM_LIT:0> , <EOL> ) , <EOL> ] , <EOL> ) <EOL> self . changes = [ ] <EOL> def parameterChanged ( self , parameter ) : <EOL> parameter . setValue ( IECore . StringData ( "<STR_LIT>" ) ) <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> c = InvalidValueRaiser ( ) <EOL> ph = GafferCortex . ParameterisedHolderNode ( ) <EOL> ph . setParameterised ( c ) <EOL> with IECore . CapturingMessageHandler ( ) as mh : <EOL> self . assertRaisesRegexp ( RuntimeError , "<STR_LIT>" , ph [ "<STR_LIT>" ] [ "<STR_LIT>" ] . setValue , <NUM_LIT:1> ) <EOL> self . assertEqual ( len ( mh . messages ) , <NUM_LIT:1> ) <EOL> self . assertTrue ( "<STR_LIT>" in mh . messages [ <NUM_LIT:0> ] . message ) <EOL> def testTypeNamePrefixes ( self ) : <EOL> self . assertTypeNamesArePrefixed ( GafferCortex ) <EOL> self . assertTypeNamesArePrefixed ( GafferCortexTest ) <EOL> def setUp ( self ) : <EOL> GafferTest . TestCase . setUp ( self ) <EOL> os . environ [ "<STR_LIT>" ] = os . path . dirname ( __file__ ) + "<STR_LIT>" <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
