838 class __Test(_TypedParameterizable):
840 class __TestType(_SimpleParameterTypeBase):
841 def _isValid(self,value):
843 class __PSet(_ParameterTypeBase,_Parameterizable):
844 def __init__(self,*arg,**args):
846 _ParameterTypeBase.__init__(self)
847 _Parameterizable.__init__(self,*arg,**args)
849 return "__PSet(\n"+_Parameterizable.dumpPython(self, options)+options.indentation()+
")"
855 x = __PSet(a = __TestType(4),
857 c = __PSet(gamma = __TestType(5))))
864 c = a.clone(x = dict(a=
None, c=
None))
865 self.assertEqual(a.t.value(),1)
866 self.assertEqual(a.u.value(),2)
867 self.assertEqual(b.t.value(),3)
868 self.assertEqual(b.u.value(),2)
869 self.assertEqual(b.v.value(),4)
870 self.assertEqual(b.x.a.value(),7)
871 self.assertEqual(b.x.b.value(),6)
872 self.assertEqual(b.x.c.gamma.value(),8)
873 self.assertEqual(b.x.d.value(),9)
874 self.assertEqual(hasattr(b,
"w"),
False)
875 self.assertEqual(hasattr(c.x,
"a"),
False)
876 self.assertEqual(hasattr(c.x,
"c"),
False)
877 self.assertRaises(TypeError,a.clone,**{
"v":1})
878 d = a.clone(__PSet(k=__TestType(42)))
879 self.assertEqual(d.t.value(), 1)
880 self.assertEqual(d.k.value(), 42)
881 d2 = a.clone(__PSet(t=__TestType(42)))
882 self.assertEqual(d2.t.value(), 42)
883 d3 = a.clone(__PSet(t=__TestType(42)),
884 __PSet(u=__TestType(56)))
885 self.assertEqual(d3.t.value(), 42)
886 self.assertEqual(d3.u.value(), 56)
887 self.assertRaises(ValueError,a.clone,
888 __PSet(t=__TestType(42)),
889 __PSet(t=__TestType(56)))
890 d4 = a.clone(__PSet(t=__TestType(43)), u = 57)
891 self.assertEqual(d4.t.value(), 43)
892 self.assertEqual(d4.u.value(), 57)
893 self.assertRaises(TypeError,a.clone,t=__TestType(43),**{
"doesNotExist":57})
896 self.assertEqual(len(e.parameterNames_()), 0)
897 f = e.clone(__PSet(a = __TestType(1)), b = __TestType(2))
898 self.assertEqual(f.a.value(), 1)
899 self.assertEqual(f.b.value(), 2)
901 self.assertEqual(len(g.parameterNames_()), 0)