diff --git a/trains/backend_interface/metrics/reporter.py b/trains/backend_interface/metrics/reporter.py index 794e8634..cacee174 100644 --- a/trains/backend_interface/metrics/reporter.py +++ b/trains/backend_interface/metrics/reporter.py @@ -195,11 +195,12 @@ class Reporter(InterfaceBase, AbstractContextManager, SetupUploadMixin, AsyncMan :type round_digits: int """ def floatstr(o): + inf_value = math.inf if six.PY3 else float("inf") if o != o: return 'nan' - elif o == math.inf: + elif o == inf_value: return 'inf' - elif o == -math.inf: + elif o == -inf_value: return '-inf' return round(o, ndigits=round_digits) if round_digits is not None else o diff --git a/trains/logger.py b/trains/logger.py index a4af2bb3..69a8604b 100644 --- a/trains/logger.py +++ b/trains/logger.py @@ -344,9 +344,9 @@ class Logger(object): reporter_table = table else: 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) + replace("NaN", np.nan, math.nan if six.PY3 else float("nan")) + replace("Inf", np.inf, math.inf if six.PY3 else float("inf")) + replace("-Inf", -np.inf, np.NINF, -math.inf if six.PY3 else -float("inf")) # noinspection PyProtectedMember return self._task._reporter.report_table( title=title,