Skip to content

Commit

Permalink
Fix nan values bug on dump_json
Browse files Browse the repository at this point in the history
  • Loading branch information
luis11011 committed Apr 18, 2022
1 parent 5580108 commit 0908be6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion optimus/helpers/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ def _replace(data):
return {k: _replace(v) for k, v in data.items()}
elif isinstance(data, (list, set, tuple,)):
return [_replace(i) for i in data]
elif data is np.nan:
return None
elif data == float("inf"):
return "Infinity"
elif data == float("-inf"):
return "-Infinity"
else:
return data
return json.dumps(_replace(value), ignore_nan=True, default=json_converter, *args, **kwargs)
return json.dumps(_replace(value), default=json_converter, *args, **kwargs)

0 comments on commit 0908be6

Please sign in to comment.