From 2848e9190e89bd5c2cb728e530f0f8f58ad429d5 Mon Sep 17 00:00:00 2001 From: allegroai <> Date: Fri, 22 May 2020 10:49:49 +0300 Subject: [PATCH] Fix NaN, Inf and -Inf values in reported table (not supported by JSON) --- trains/logger.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/trains/logger.py b/trains/logger.py index aeea679d..959bd771 100644 --- a/trains/logger.py +++ b/trains/logger.py @@ -1,4 +1,5 @@ import logging +import math import warnings from typing import Any, Sequence, Union, List, Optional, Tuple @@ -299,10 +300,19 @@ class Logger(object): elif csv: table = pd.read_csv(csv) + def replace(dst, *srcs): + for src in srcs: + reporter_table.replace(src, dst, inplace=True) + + reporter_table = table.fillna(str(np.nan)) + replace("NaN", np.nan, math.nan) + replace("Inf", np.inf, math.inf) + replace("-Inf", -np.inf, np.NINF, -math.inf) + return self._task.reporter.report_table( title=title, series=series, - table=table, + table=reporter_table, iteration=iteration )