mirror of
https://github.com/clearml/clearml
synced 2025-02-12 07:35:08 +00:00
Fix python 2.7/3.5 math support
This commit is contained in:
parent
1651faac3d
commit
4aa5c620f4
@ -195,11 +195,12 @@ class Reporter(InterfaceBase, AbstractContextManager, SetupUploadMixin, AsyncMan
|
|||||||
:type round_digits: int
|
:type round_digits: int
|
||||||
"""
|
"""
|
||||||
def floatstr(o):
|
def floatstr(o):
|
||||||
|
inf_value = math.inf if six.PY3 else float("inf")
|
||||||
if o != o:
|
if o != o:
|
||||||
return 'nan'
|
return 'nan'
|
||||||
elif o == math.inf:
|
elif o == inf_value:
|
||||||
return 'inf'
|
return 'inf'
|
||||||
elif o == -math.inf:
|
elif o == -inf_value:
|
||||||
return '-inf'
|
return '-inf'
|
||||||
return round(o, ndigits=round_digits) if round_digits is not None else o
|
return round(o, ndigits=round_digits) if round_digits is not None else o
|
||||||
|
|
||||||
|
@ -344,9 +344,9 @@ class Logger(object):
|
|||||||
reporter_table = table
|
reporter_table = table
|
||||||
else:
|
else:
|
||||||
reporter_table = table.fillna(str(np.nan))
|
reporter_table = table.fillna(str(np.nan))
|
||||||
replace("NaN", np.nan, math.nan)
|
replace("NaN", np.nan, math.nan if six.PY3 else float("nan"))
|
||||||
replace("Inf", np.inf, math.inf)
|
replace("Inf", np.inf, math.inf if six.PY3 else float("inf"))
|
||||||
replace("-Inf", -np.inf, np.NINF, -math.inf)
|
replace("-Inf", -np.inf, np.NINF, -math.inf if six.PY3 else -float("inf"))
|
||||||
# noinspection PyProtectedMember
|
# noinspection PyProtectedMember
|
||||||
return self._task._reporter.report_table(
|
return self._task._reporter.report_table(
|
||||||
title=title,
|
title=title,
|
||||||
|
Loading…
Reference in New Issue
Block a user