Skip to content

Commit

Permalink
add missing file seal5/metrics.py
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippvK committed Oct 30, 2024
1 parent 9da6974 commit e7f0a07
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions seal5/metrics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import ast
from typing import Union
from pathlib import Path
import csv


def read_metrics(metrics_file: Union[str, Path], allow_missing: bool = True):
# print("read_metrics", metrics_file, allow_missing)
# input("?")
if not Path(metrics_file).is_file():
# print("not file")
# input("!")
assert allow_missing
return {}
data = {}
with open(metrics_file, "r") as infile:
reader = csv.reader(infile)
data = []
for row in reader:
data.append(row)
assert len(data) == 2
keys = data[0]
vals = data[1]
print("keys", keys)
print("vals", vals)
# vals = list(map(lambda x: "{}" if x == "set()" else x, vals))
vals = list(map(lambda x: ast.literal_eval(x), vals))
data = dict(zip(keys, vals))
# print("data", data)
# input("ret")
return data

0 comments on commit e7f0a07

Please sign in to comment.