Skip to content
Snippets Groups Projects
Commit 52f5dc6d authored by Aymeric Varasse's avatar Aymeric Varasse :innocent:
Browse files

[records] Make AIMOS amplitude type optional

parent dc0c17ec
No related branches found
No related tags found
No related merge requests found
...@@ -51,13 +51,15 @@ let term_of_eps env eps = ...@@ -51,13 +51,15 @@ let term_of_eps env eps =
type threshold = float [@@deriving yojson, show] type threshold = float [@@deriving yojson, show]
type amplitude = { type amplitude_record = {
start : int option; start : int;
stop : int; stop : int;
step : int option; step : int;
} }
[@@deriving yojson, show] [@@deriving yojson, show]
type amplitude = amplitude_record option [@@deriving yojson, show]
type aimos_params = { type aimos_params = {
perturbation : string; perturbation : string;
ctp : string; ctp : string;
...@@ -69,20 +71,12 @@ type aimos_params = { ...@@ -69,20 +71,12 @@ type aimos_params = {
let string_of_threshold threshold = Float.to_string threshold let string_of_threshold threshold = Float.to_string threshold
let string_of_amplitude amplitude = let string_of_amplitude amplitude =
let start = match amplitude.start with Some a -> a | None -> 0 in match amplitude with
if start = amplitude.stop | Some a ->
then None
else
let start_str =
Option.value_map amplitude.start ~default:"" ~f:Int.to_string
in
let step_str =
Option.value_map amplitude.step ~default:"" ~f:Int.to_string
in
Some Some
(Fmt.str "range(%s, %s, %s)" start_str (Fmt.str "range(%s, %s, %s)" (Int.to_string a.start)
(Int.to_string amplitude.stop) (Int.to_string a.stop) (Int.to_string a.step))
step_str) | None -> None
type property = type property =
| Correct | Correct
...@@ -158,10 +152,10 @@ let interpret_predicate env ~on_model ~on_dataset task = ...@@ -158,10 +152,10 @@ let interpret_predicate env ~on_model ~on_dataset task =
ctp; ctp;
om; om;
amplitude = amplitude =
{ Some {
start = Some (Number.to_small_integer start); start = Number.to_small_integer start;
stop = Number.to_small_integer stop; stop = Number.to_small_integer stop;
step = Some (Number.to_small_integer step); step = Number.to_small_integer step;
}; };
} ) } )
else failwith_unsupported_ls ls else failwith_unsupported_ls ls
......
...@@ -30,13 +30,15 @@ val term_of_eps : Env.env -> eps -> Term.term ...@@ -30,13 +30,15 @@ val term_of_eps : Env.env -> eps -> Term.term
type threshold [@@deriving yojson, show] type threshold [@@deriving yojson, show]
type amplitude = { type amplitude_record = {
start : int option; start : int;
stop : int; stop : int;
step : int option; step : int;
} }
[@@deriving yojson, show] [@@deriving yojson, show]
type amplitude = amplitude_record option [@@deriving yojson, show]
type aimos_params = { type aimos_params = {
perturbation : string; perturbation : string;
ctp : string; ctp : string;
......
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