n | def fix(n): | n | def fix(n: int): |
| | | |
n | def decorator(fn): | n | def decorator(fun): |
| | | |
n | def wrapper(*args, **kwargs): | n | def fix_fun(*args, **kwargs): |
| n_arg = [] | | new_args = [] |
| for i in args: | | for arg in args: |
| if isinstance(i, float): | | if isinstance(arg, float): |
| n_arg.append(round(i, n)) | | new_args.append(round(arg, n)) |
| else: | | else: |
n | n_arg.append(i) | n | new_args.append(arg) |
| for (j, k) in kwargs.items(): | | for (key, value) in kwargs.items(): |
| if isinstance(k, float): | | if isinstance(value, float): |
| kwargs[j] = round(k, n) | | kwargs[key] = round(value, n) |
| res = fn(*n_arg, **kwargs) | | result = fun(*new_args, **kwargs) |
| if isinstance(res, float): | | if isinstance(result, float): |
| return round(res, n) | | return round(result, n) |
| else: | | else: |
t | return res | t | return result |
| return wrapper | | return fix_fun |
| return decorator | | return decorator |