f | def fix(n): | f | def fix(n): |
| | | |
| def dec(fun): | | def dec(fun): |
| | | |
n | def wrap(*args, **kwargs): | n | def newfun(*args, **kwargs): |
| new_args = [] | | newargs = [] |
| new_kwargs = {} | | newkwargs = {} |
| for arg in args: | | for arg in args: |
n | if type(arg) is float: | n | if type(arg) == float: |
| arg = round(arg, n) | | arg = round(arg, n) |
t | new_args.append(arg) | t | newargs.append(arg) |
| for (k, v) in kwargs.items(): | | for (key, value) in kwargs.items(): |
| if type(v) is float: | | if type(value) == float: |
| v = round(v, n) | | value = round(value, n) |
| new_kwargs[k] = v | | newkwargs[key] = value |
| res = fun(*new_args, **new_kwargs) | | ret = fun(*newargs, **newkwargs) |
| if type(res) is float: | | if type(ret) == float: |
| res = round(res, n) | | ret = round(ret, n) |
| return res | | return ret |
| return wrap | | return newfun |
| return dec | | return dec |