# -*- coding: utf-8 -*- import math import numpy as np def round_half_up(n: float, decimals: int = 0) -> float: if np.isnan(n): return n else: multiplier = 10 ** decimals return math.floor(n * multiplier + 0.5) / multiplier