def __call__(self, *args, **kwargs): def _is_float(value): return isinstance(value, (float, np.floating)) return self.str_template.format( *[format_float(i) if _is_float(i) else i for i in args], **{ k: format_float(v) if _is_float(v) else v for k, v in kwargs.items() })
def format_arg(value): if np.isnan(value): return "NaN" return format_float(value)