fixed buggy mapIncremental behavior for anything else than averaging (the standard case luckily…)

This commit is contained in:
Philip Eisenlohr 2015-10-27 20:16:24 +00:00
parent 4ed5553822
commit ad06fc1a77
1 changed files with 5 additions and 5 deletions

View File

@ -479,13 +479,13 @@ def mapIncremental(label, mapping, N, base, new):
# to a list of data # to a list of data
# ----------------------------- # -----------------------------
theMap = { 'min': lambda n,b,a: min(b,a), theMap = { 'min': lambda n,b,a: a if n==0 else min(b,a),
'max': lambda n,b,a: max(b,a), 'max': lambda n,b,a: a if n==0 else max(b,a),
'avg': lambda n,b,a: (n*b+a)/(n+1), 'avg': lambda n,b,a: (n*b+a)/(n+1),
'avgabs': lambda n,b,a: (n*b+abs(a))/(n+1), 'avgabs': lambda n,b,a: (n*b+abs(a))/(n+1),
'sum': lambda n,b,a: b+a, 'sum': lambda n,b,a: a if n==0 else b+a,
'sumabs': lambda n,b,a: b+abs(a), 'sumabs': lambda n,b,a: abs(a) if n==0 else b+abs(a),
'unique': lambda n,b,a: {True:a,False:'n/a'}[n==0 or b==a] 'unique': lambda n,b,a: a if n==0 or b==a else 'n/a'
} }
if mapping in theMap: if mapping in theMap:
mapped = map(theMap[mapping],[N]*len(base),base,new) # map one of the standard functions to data mapped = map(theMap[mapping],[N]*len(base),base,new) # map one of the standard functions to data