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