Skip to content

Commit

Permalink
clean up function def statements
Browse files Browse the repository at this point in the history
  • Loading branch information
mjohnson541 committed Jan 31, 2019
1 parent 44e3ed5 commit 4184189
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions rmgpy/data/kinetics/family.py
Original file line number Diff line number Diff line change
Expand Up @@ -2454,7 +2454,7 @@ def addAtomLabelsForReaction(self, reaction, output_with_resonance = True):
for species in reaction.reactants + reaction.products:
species.generate_resonance_structures()

def getw0(self,rxn):
def getw0(self, rxn):
"""
calculates the w0 for Blower Masel kinetics by calculating wf (total bond energy of bonds formed)
and wb (total bond energy of bonds broken) with w0 = (wf+wb)/2
Expand Down Expand Up @@ -2508,7 +2508,7 @@ def getw0(self,rxn):

return (wf+wb)/2.0

def getw0s(self,rxns):
def getw0s(self, rxns):
return map(self.getw0,rxns)

def getTrainingDepository(self):
Expand All @@ -2522,7 +2522,7 @@ def getTrainingDepository(self):
raise DatabaseError('Could not find training depository in family {0}.'.format(self.label))


def addEntry(self,parent,grp,name):
def addEntry(self, parent, grp, name):
"""
Adds a group entry with parent parent
group structure grp
Expand All @@ -2535,7 +2535,7 @@ def addEntry(self,parent,grp,name):
if entry.parent:
entry.parent.children.append(entry)

def splitReactions(self,rxns,newgrp):
def splitReactions(self, rxns, newgrp):
"""
divides the reactions in rxns between the new
group structure newgrp and the old structure with
Expand Down Expand Up @@ -2564,7 +2564,7 @@ def splitReactions(self,rxns,newgrp):

return new,comp,newInds

def evalExt(self,parent,ext,extname,templateRxnMap,obj=None,T=1000.0):
def evalExt(self, parent, ext, extname, templateRxnMap, obj=None, T=1000.0):
"""
evaluates the objective function obj
for the extension ext with name extname to the parent entry parent
Expand All @@ -2582,7 +2582,7 @@ def evalExt(self,parent,ext,extname,templateRxnMap,obj=None,T=1000.0):
ob,boo = getObjectiveFunction(new,old,T=T)
return ob,True

def getExtensionEdge(self,parent,templateRxnMap,obj,T):
def getExtensionEdge(self, parent, templateRxnMap, obj, T):
"""
finds the set of all extension groups to parent such that
1) the extension group divides the set of reactions under parent
Expand Down Expand Up @@ -2734,7 +2734,7 @@ def getExtensionEdge(self,parent,templateRxnMap,obj,T):
return out


def extendNode(self,parent,templateRxnMap,thermoDatabase=None,obj=None,T=1000.0,):
def extendNode(self, parent, templateRxnMap, thermoDatabase=None, obj=None, T=1000.0,):
"""
Constructs an extension to the group parent based on evaluation
of the objective function obj
Expand Down Expand Up @@ -2837,7 +2837,7 @@ def extendNode(self,parent,templateRxnMap,thermoDatabase=None,obj=None,T=1000.0,

return True

def generateTree(self,obj=None,thermoDatabase=None,T=1000.0):
def generateTree(self, obj=None, thermoDatabase=None, T=1000.0):
"""
Generate a tree by greedy optimization based on the objective function obj
the optimization is done by iterating through every group and if the group has
Expand Down Expand Up @@ -2877,7 +2877,7 @@ def generateTree(self,obj=None,thermoDatabase=None,T=1000.0):
return


def makeBMRulesFromTemplateRxnMap(self,templateRxnMap):
def makeBMRulesFromTemplateRxnMap(self, templateRxnMap):

index = max([e.index for e in self.rules.getEntries()] or [0]) + 1

Expand Down Expand Up @@ -2910,7 +2910,7 @@ def makeBMRulesFromTemplateRxnMap(self,templateRxnMap):



def crossValidate(self,folds=5,templateRxnMap=None,T=1000.0,iters=0,random_state=1):
def crossValidate(self, folds=5, templateRxnMap=None, T=1000.0, iters=0, random_state=1):
"""
Perform K-fold cross validation on an automatically generated tree at temperature T
after finding an appropriate node for kinetics estimation it will move up the tree
Expand Down Expand Up @@ -2967,7 +2967,7 @@ def crossValidate(self,folds=5,templateRxnMap=None,T=1000.0,iters=0,random_state

return errors

def crossValidateOld(self,folds=5,T=1000.0,random_state=1,estimator='rate rules',thermoDatabase=None):
def crossValidateOld(self, folds=5, T=1000.0, random_state=1, estimator='rate rules', thermoDatabase=None):
"""
Perform K-fold cross validation on an automatically generated tree at temperature T
Returns a dictionary mapping {rxn:Ln(k_Est/k_Train)}
Expand Down Expand Up @@ -3096,7 +3096,7 @@ def simpleRegularization(self, node):
if vals != [] and all([set(child.item.getBond(child.item.atoms[i],child.item.atoms[j]).order) <= set(vals) for child in node.children]):
bd.order = vals

def regularize(self, regularization=simpleRegularization,keepRoot=True):
def regularize(self, regularization=simpleRegularization, keepRoot=True):
"""
Regularizes the tree according to the regularization function regularization
"""
Expand All @@ -3120,7 +3120,7 @@ def checkTree(self, entry=None):
raise ValueError('Child not subgraph isomorphic to parent')
self.checkTree(child)

def makeTree(self,obj=None,regularization=simpleRegularization,thermoDatabase=None,T=1000.0):
def makeTree(self, obj=None, regularization=simpleRegularization, thermoDatabase=None, T=1000.0):
"""
generates tree structure and then generates rules for the tree
"""
Expand All @@ -3134,7 +3134,7 @@ def cleanTreeRules(self):
self.rules.entries = OrderedDict()
self.rules.entries['Root'] = []

def cleanTreeGroups(self,thermoDatabase=None):
def cleanTreeGroups(self, thermoDatabase=None):
"""
clears groups and rules in the tree, generates an appropriate
root group to start from and then reads training reactions
Expand Down Expand Up @@ -3166,11 +3166,11 @@ def cleanTreeGroups(self,thermoDatabase=None):

return

def cleanTree(self,thermoDatabase=None):
def cleanTree(self, thermoDatabase=None):
self.cleanTreeRules()
self.cleanTreeGroups(thermoDatabase=thermoDatabase)

def saveGeneratedTree(self,path=None):
def saveGeneratedTree(self, path=None):
"""
clears the rules and saves the family to its
current location in database
Expand Down Expand Up @@ -3320,7 +3320,7 @@ def getTrainingSet(self, thermoDatabase=None, removeDegeneracy=False, estimateTh
else:
return rxns

def getReactionMatches(self,rxns=None,thermoDatabase=None,removeDegeneracy=False,estimateThermo=True,fixLabels=False,exactMatchesOnly=False,getReverse=False):
def getReactionMatches(self, rxns=None, thermoDatabase=None, removeDegeneracy=False, estimateThermo=True, fixLabels=False, exactMatchesOnly=False, getReverse=False):
"""
returns a dictionary mapping for each entry in the tree:
(entry.label,entry.item) : list of all training reactions (or the list given) that match that entry
Expand Down Expand Up @@ -3378,7 +3378,7 @@ def getReactionMatches(self,rxns=None,thermoDatabase=None,removeDegeneracy=False
return rxnLists


def isEntryMatch(self,mol,entry):
def isEntryMatch(self, mol, entry):
"""
determines if the labeled molecule object of reactants matches the entry entry
"""
Expand Down

0 comments on commit 4184189

Please sign in to comment.