def allCalculables(calcs,weights,adjustedSteps) : secondaries = [ s for s in adjustedSteps if self.isSecondary(s) ] weightsAlready = [next(c for c in secondaries+calcs if c.name==w) for w in weights if type(w)==str ] weightsAdditional = [ w for w in weights if type(w)!=str ] def check(As,Bs) : intersect = set([a.name for a in As]).intersection(set([b.name for b in Bs])) assert not intersect, "Warning: { %s } are already listed in listOfCalculables."%','.join(intersect) check(calcs,weightsAdditional) check(calcs,secondaries) check(weightsAdditional,secondaries) return calcs + [calculables.weight(weightsAdditional+weightsAlready)] + weightsAdditional + secondaries
def allCalculables(calcs,weights,adjustedSteps) : secondaries = [ s for s in adjustedSteps if self.isSecondary(s) ] weightsAlready = [next(c for c in secondaries+calcs if c.name==w) for w in weights if type(w)==str ] weightsAdditional = [ w for w in weights if type(w)!=str ] def check(As,Bs) : nonCalcs = [c for c in As + Bs if not issubclass(type(c), wrappedChain.calculable)] assert not nonCalcs, "\n\nWarning, the following items from listOfCalculables() are not calculables:\n"+('\n'.join(' '+str(c) for c in nonCalcs)) intersect = set([a.name for a in As]).intersection(set([b.name for b in Bs])) assert not intersect, "Warning: { %s } are already listed in listOfCalculables."%','.join(intersect) check(calcs,weightsAdditional) check(calcs,secondaries) check(weightsAdditional,secondaries) return calcs + [calculables.weight(weightsAdditional+weightsAlready)] + weightsAdditional + secondaries