Functional coverage tree: Difference between revisions
m
→Python: Composition of pure functions: Tidying
m (→Python: Composition of pure functions: (str.isspace() in lieu of `re`)) |
m (→Python: Composition of pure functions: Tidying) |
||
Line 1,606:
# TWO COMPUTATIONS BY TRAVERSAL
withResidueShares(1.0)(
foldTree(
# TREE FROM PARSE OF OUTLINE TEXT
Line 1,624:
# WEIGHTED COVERAGE, AND SHARE OF TOTAL RESIDUE -----------
# weightedCoverage :: Tree Dict ->
# [Tree Dict] -> Tree Dict
def
'''The weighted
as a function of the weighted averages
of its children.
'''
def go(xs):
cws = [(r['coverage'], r['weight']) for r in [root(x) for x in xs]]
totalWeight = reduce(lambda a, x: a + x[1], cws, 0)
return Node(dict(
x, **{
'coverage': round(
) / (totalWeight if 0 < totalWeight else
}
))(xs)
|