Merge pull request #59 from andresmrm/patch-2

Allow round to INT
This commit is contained in:
enkore 2014-05-19 15:13:28 +02:00
commit 68ca823fce

View File

@ -50,9 +50,14 @@ def partition(iterable, limit, key=lambda x: x):
def round_dict(dic, places): def round_dict(dic, places):
""" """
Rounds all values in a dict containing only numeric types to `places` decimal places. Rounds all values in a dict containing only numeric types to `places` decimal places.
If places is None, round to INT.
""" """
for key, value in dic.items(): if places is None:
dic[key] = round(value, places) for key, value in dic.items():
dic[key] = round(value)
else:
for key, value in dic.items():
dic[key] = round(value, places)
class ModuleList(collections.UserList): class ModuleList(collections.UserList):