diff --git a/binarycpython/utils/functions.py b/binarycpython/utils/functions.py index ecf901772cd8b1ec001eb2b9021dbe8acc85963d..539601288eff8623c04629dff88d94be37ce582f 100644 --- a/binarycpython/utils/functions.py +++ b/binarycpython/utils/functions.py @@ -354,6 +354,7 @@ def datalinedict(line : str, Note: if the parameter is a floating point number, it will be converted to Python's float type. """ + return {param:convfloat(value) for param, value in zip(parameters, line.split())} def pad_output_distribution(dist : dict, @@ -361,23 +362,22 @@ def pad_output_distribution(dist : dict, """ Given a distribution, dist (a dictionary), which should be binned every binwidth (float), fill the distribution with zeros when there is no data. Note: this changes the data in place. """ + # sorted list of the keys skeys = sorted(dist.keys(), key = lambda x: float(x)) # get min and max, offset by the binwidth - min = skeys[ 0] - binwidth - max = skeys[-1] + binwidth + min_val = skeys[ 0] - binwidth + max_val = skeys[-1] + binwidth # pad with zeros - x = min - while x <= max: + x = min_val + while x <= max_val: dist[x] = dist.setdefault(x,0.0) x += binwidth return dist - - class catchtime(object): """ Context manager to calculate time spent