From 52f5dc6d4cfd3cbbba7815d0399e3158a2271e09 Mon Sep 17 00:00:00 2001 From: Aymeric Varasse <aymeric.varasse@cea.fr> Date: Wed, 28 Jun 2023 19:00:04 +0200 Subject: [PATCH] [records] Make AIMOS amplitude type optional --- src/dataset.ml | 32 +++++++++++++------------------- src/dataset.mli | 8 +++++--- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/dataset.ml b/src/dataset.ml index d08696f..dba47cd 100644 --- a/src/dataset.ml +++ b/src/dataset.ml @@ -51,13 +51,15 @@ let term_of_eps env eps = type threshold = float [@@deriving yojson, show] -type amplitude = { - start : int option; +type amplitude_record = { + start : int; stop : int; - step : int option; + step : int; } [@@deriving yojson, show] +type amplitude = amplitude_record option [@@deriving yojson, show] + type aimos_params = { perturbation : string; ctp : string; @@ -69,20 +71,12 @@ type aimos_params = { let string_of_threshold threshold = Float.to_string threshold let string_of_amplitude amplitude = - let start = match amplitude.start with Some a -> a | None -> 0 in - if start = amplitude.stop - 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 + match amplitude with + | Some a -> Some - (Fmt.str "range(%s, %s, %s)" start_str - (Int.to_string amplitude.stop) - step_str) + (Fmt.str "range(%s, %s, %s)" (Int.to_string a.start) + (Int.to_string a.stop) (Int.to_string a.step)) + | None -> None type property = | Correct @@ -158,10 +152,10 @@ let interpret_predicate env ~on_model ~on_dataset task = ctp; om; amplitude = - { - start = Some (Number.to_small_integer start); + Some { + start = Number.to_small_integer start; stop = Number.to_small_integer stop; - step = Some (Number.to_small_integer step); + step = Number.to_small_integer step; }; } ) else failwith_unsupported_ls ls diff --git a/src/dataset.mli b/src/dataset.mli index 1ad03f6..4660c27 100644 --- a/src/dataset.mli +++ b/src/dataset.mli @@ -30,13 +30,15 @@ val term_of_eps : Env.env -> eps -> Term.term type threshold [@@deriving yojson, show] -type amplitude = { - start : int option; +type amplitude_record = { + start : int; stop : int; - step : int option; + step : int; } [@@deriving yojson, show] +type amplitude = amplitude_record option [@@deriving yojson, show] + type aimos_params = { perturbation : string; ctp : string; -- GitLab