Skip to content

Commit

Permalink
Merge pull request #13526 from Dr15Jones/havePSetCloneWorkLikeModuleC…
Browse files Browse the repository at this point in the history
…lone

PSet.clone now works like module clone
  • Loading branch information
davidlange6 committed Mar 1, 2016
2 parents 76a40ec + 1440dd2 commit 62d5aa4
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions FWCore/ParameterSet/python/Types.py
@@ -1,4 +1,4 @@
from Mixins import PrintOptions, _SimpleParameterTypeBase, _ParameterTypeBase, _Parameterizable, _ConfigureComponent, _Labelable, _TypedParameterizable, _Unlabelable
from Mixins import PrintOptions, _SimpleParameterTypeBase, _ParameterTypeBase, _Parameterizable, _ConfigureComponent, _Labelable, _TypedParameterizable, _Unlabelable, _modifyParametersFromDict
from Mixins import _ValidatingParameterListBase
from ExceptionHandling import format_typename, format_outerframe

Expand Down Expand Up @@ -643,19 +643,7 @@ def dumpPython(self, options=PrintOptions()):
return self.pythonTypeName()+"(\n"+_Parameterizable.dumpPython(self, options)+options.indentation()+")"
def clone(self, *args, **params):
myparams = self.parameters_()
if len(params):
#need to treat items both in params and myparams specially
for key,value in params.iteritems():
if key in myparams:
if isinstance(value,_ParameterTypeBase):
myparams[key] =value
else:
myparams[key].setValue(value)
else:
if isinstance(value,_ParameterTypeBase):
myparams[key]=value
else:
self._Parameterizable__raiseBadSetAttr(key)
_modifyParametersFromDict(myparams, params, self._Parameterizable__raiseBadSetAttr)
returnValue = PSet(**myparams)
returnValue.setIsTracked(self.isTracked())
returnValue._isModified = False
Expand Down Expand Up @@ -1370,6 +1358,13 @@ def testPSet(self):
self.assertFalse(p4.b.isTracked())
self.assertFalse(p4.a.b.isTracked())
self.assert_(p4.b.b.isTracked())
p4 = p3.clone( i = None, b = dict(b = 5))
self.assertEqual(p3.i.value(), 1)
self.assertEqual(hasattr(p4,"i"), False)
self.assertEqual(p3.b.b.value(), 1)
self.assertEqual(p4.b.b.value(), 5)
self.assertEqual(p4.a.b.value(), 1)
self.assertEqual(p4.ui.value(), 2)
def testVPSet(self):
p1 = VPSet(PSet(anInt = int32(1)), PSet(anInt=int32(2)))
self.assertEqual(len(p1),2)
Expand Down

0 comments on commit 62d5aa4

Please sign in to comment.