Skip to content
Snippets Groups Projects
Commit 48a02df7 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB
Browse files

Another bugfix for nan handling in eff_distance

Need to make sure values are actually numeric types before
just passing them to isnan(), since it can't handle them, apparently.
parent efcb67d7
No related branches found
No related tags found
No related merge requests found
from math import isnan
import numbers
from django.db import models, IntegrityError
from django.urls import reverse
......@@ -989,9 +990,13 @@ class SingleInspiral(models.Model):
for f in [cls._meta.get_field(f) for f in cls.field_names()]:
value = getattr(row, f.attname, f.default)
# Handle nan for eff_distance
if f.attname == 'eff_distance' and isnan(value):
value = None
# Awful kludge for handling nan for eff_distance
try:
if (f.attname == 'eff_distance' and
isinstance(value, numbers.Number) and isnan(value)):
value = None
except Exception as e:
pass
# Only set value of class instance member if
# value is not None or if field is nullable.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment