Docker-in-Docker (DinD) capabilities of public runners deactivated. More info

Commit 1850b1c6 authored by Philippe Veber's avatar Philippe Veber
Browse files

toolbox/Result_table: reimplemented of_file

for some reason it seems that Owl_dataframe.of_csv leaks file handlers
parent a257fb5c
......@@ -6,35 +6,38 @@ type t = {
}
let of_file fn =
let module D = Owl.Dataframe in
let df = D.of_csv fn in
let oracle =
try
D.get_col_by_name df "Oracle"
|> D.unpack_int_series
|> Array.map ~f:(function
| 0 -> false
| 1 -> true
| _ -> failwith "Unexpected element in oracle column"
)
|> Option.some
with Caml.Not_found -> None
in
let scores meth =
match D.get_col_by_name df meth with
| Float_Series xs -> Some xs
| Int_Series xs -> Some (Array.map xs ~f:Float.of_int)
| String_Series _ -> None (* has NA *)
| _ -> assert false
in
let methods =
D.get_heads df
|> Array.filter ~f:String.(fun m -> m <> "Oracle" && m <> "Sites")
in
let scores_per_meth =
Array.filter_map methods ~f:(fun m ->
Option.map (scores m) ~f:(fun c -> m, c)
match
In_channel.read_lines fn
|> List.map ~f:(String.split ~on:'\t')
|> List.transpose
with
| None -> failwith "Variable number of fields"
| Some cols ->
let cols = List.map cols ~f:(function
| [] -> assert false
| h :: t -> h, t
)
in
let oracle =
List.Assoc.find cols "Oracle" ~equal:String.equal
|> Option.map ~f:(
List.map ~f:(function
| "0" -> false
| "1" -> true
| _ -> failwith "Unexpected element in oracle column"
)
)
|> Array.to_list
in
{ oracle ; scores_per_meth }
|> Option.map ~f:Array.of_list
in
let scores_per_meth =
List.filter_map cols ~f:(fun (label, values) ->
if String.(label <> "Oracle" && label <> "Sites") then
let values =
List.map values ~f:Float.of_string
|> Array.of_list
in
Some (label, values)
else None
)
in
{ oracle ; scores_per_meth }
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