Skip to content

Commit becafb5

Browse files
committed
fixed json serialization
1 parent 53dde86 commit becafb5

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

model/distributions/sphere/watson/benchmark_fib_starts.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,25 @@ def _sanitize_filename(name):
7575
return name.replace(" ", "_").replace(":", "")
7676

7777
def _rows_from_results(results, x_label):
78+
def _to_builtin(value):
79+
if isinstance(value, np.integer):
80+
return int(value)
81+
if isinstance(value, np.floating):
82+
return float(value)
83+
return value
84+
7885
if x_label == "sample_count":
79-
return [dict(name=n, sample_count=k, time=t.mean()) for n, pts in results.items() for k, t in pts]
86+
return [
87+
dict(name=n, sample_count=_to_builtin(k), time=_to_builtin(t.mean()))
88+
for n, pts in results.items()
89+
for k, t in pts
90+
]
8091
if x_label == "kappa":
81-
return [dict(name=n, kappa=k, time=t.mean()) for n, pts in results.items() for k, t in pts]
92+
return [
93+
dict(name=n, kappa=_to_builtin(k), time=_to_builtin(t.mean()))
94+
for n, pts in results.items()
95+
for k, t in pts
96+
]
8297
raise ValueError(f"Unsupported x_label: {x_label}")
8398

8499
def _plot_rows(rows, title, filename, x_label, log_x=False, log_y=False):

0 commit comments

Comments
 (0)