Skip to content

Commit

Permalink
Add __delattr__ to EDAlias to work with Modifier
Browse files Browse the repository at this point in the history
The Modifier system uses the value of None to remove a parameter from
a configuration object. When used with an EDAlias the parameter was
removed by the name was not removed from the internal list of parameters.
This has now been fixed.
  • Loading branch information
Dr15Jones committed Sep 19, 2016
1 parent 1348d5a commit cb21b03
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions FWCore/ParameterSet/python/Types.py
Expand Up @@ -1132,6 +1132,11 @@ def __addParameter(self, name, value):
self.__dict__[name]=value
self.__parameterNames.append(name)

def __delattr__(self,attr):
if attr in self.__parameterNames:
self.__parameterNames.remove(attr)
return super(EDAlias,self).__delattr__(attr)

def __setParameters(self,parameters):
for name,value in parameters.iteritems():
self.__addParameter(name, value)
Expand Down Expand Up @@ -1376,6 +1381,10 @@ def testVPSet(self):
self.assertRaises(SyntaxError, lambda : VPSet(foo=PSet()))
def testEDAlias(self):
aliasfoo2 = EDAlias(foo2 = VPSet(PSet(type = string("Foo2"))))
self.assert_(hasattr(aliasfoo2,"foo2"))
del aliasfoo2.foo2
self.assert_(not hasattr(aliasfoo2,"foo2"))
self.assert_("foo2" not in aliasfoo2.parameterNames_())

def testFileInPath(self):
f = FileInPath("FWCore/ParameterSet/python/Types.py")
Expand Down

0 comments on commit cb21b03

Please sign in to comment.