Skip to content

Commit

Permalink
server: add convert inf to null in variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Tharun Paul authored and Tharun Paul committed Jul 5, 2024
1 parent 2e78428 commit 502b8a4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/models/variables.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from math import isnan
from math import isinf, isnan
from typing import Any, Dict, List, Optional, Union

from pydantic import BaseModel, Field, constr, validator
Expand Down Expand Up @@ -57,6 +57,8 @@ class VariableProperties(BaseModel):
def change_nan_to_none(cls, v, field):
if field.outer_type_ is float and isnan(v):
return None
elif isinstance(v, float) and isinf(v):
return None
return v


Expand Down

0 comments on commit 502b8a4

Please sign in to comment.