Skip to content

Commit

Permalink
fix nan and inf problems (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
ztxtech authored Sep 17, 2023
1 parent def816d commit 3c1a114
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fitlog/fastlog/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ def _parse_value(value: Union[int, str, float, dict], name: str, parent_name: st
elif isinstance(value, np.integer):
value = int(value)
elif isinstance(value, np.floating):
value = float(value)
value = float(value) if not(math.isnan(value) and math.isinf(value)) else str(value)
else:
value = str(value) # 直接专为str类型
assert name is not None, f"When value is `{type(value)}`, you must pass a name."
Expand Down Expand Up @@ -796,7 +796,7 @@ def _check_dict_value(_dict: dict, prefix: str = ''):
elif isinstance(value, (np.integer, int)):
_dict[key] = int(value)
elif isinstance(value, (np.floating, float)):
_dict[key] = float(value)
_dict[key] = float(value) if not (math.isnan(value) and math.isinf(value)) else str(value)
else:
_dict[key] = str(value)

Expand Down

0 comments on commit 3c1a114

Please sign in to comment.