Commit fcedf9ee authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix invalid types error in JSON API

parent 802bc6ef
......@@ -257,6 +257,8 @@ def api():
def clean_floats(d):
new_d = {}
for k, v in d.items():
if k == "sbm_fit":
continue
if isinstance(v, dict):
v = clean_floats(v)
else:
......@@ -265,6 +267,10 @@ def clean_floats(d):
v = None
except TypeError:
pass
if isinstance(v, numpy.float64):
v = float(v)
if isinstance(v, numpy.ndarray):
v = v.to_list()
new_d[k] = v
return new_d
......@@ -273,7 +279,8 @@ def get_entry_json(entry):
for i in range(len(entry.citation)):
fname = f"./cache/bibtex/{entry.name}/{i}.bib"
if os.path.exists(fname):
bibtex.append(open(fname).read())
with open(fname) as f:
bibtex.append(f.read())
return dict(title=entry.title,
description=entry.description,
citation=entry.citation,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment