From fec92e813539d1a85a82b04acc174d4b89671f3f Mon Sep 17 00:00:00 2001
From: "a.stevan" <antoine.stevan@isae-supaero.fr>
Date: Fri, 31 May 2024 09:38:43 +0200
Subject: [PATCH 1/2] add information about experiment to `load`

this can be used by `plot` without passing extra arguments.
---
 bins/inbreeding/load.nu | 26 +++++++++++++++++++++++---
 bins/inbreeding/plot.nu | 20 +++++++++++---------
 2 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/bins/inbreeding/load.nu b/bins/inbreeding/load.nu
index 3896ff4d..c14284c1 100644
--- a/bins/inbreeding/load.nu
+++ b/bins/inbreeding/load.nu
@@ -18,8 +18,18 @@ def get-experiments []: nothing -> list<string> {
 
 export def main [
     experiment: string@get-experiments,
-]: nothing -> table<strategy: string, diversity: table<x: int, y: float, e: float>> {
-    let exp = $experiment | parse --regex $consts.ARG_EXPERIMENT_FORMAT | into record
+]: [
+    nothing -> record<
+        experiment: record<k: int, n: int, nb_bytes: int, env: string>,
+        measurements: table<strategy: string, diversity: table<x: int, y: float, e: float>>,
+    >
+] {
+    let exp = $experiment
+        | parse --regex $consts.ARG_EXPERIMENT_FORMAT
+        | into record
+        | into int k
+        | into int n
+        | into int nb_bytes
     if $exp == {} {
         error throw {
             err: "invalid experiment",
@@ -45,7 +55,7 @@ export def main [
         }
     }
 
-    $experiment_files
+    let measurements = $experiment_files
         | select name
         | insert . { get name | remove-cache-prefix | parse --regex $consts.EXPERIMENT_FORMAT }
         | flatten --all
@@ -71,4 +81,14 @@ export def main [
             $d | skip 1 | reduce --fold $d.0 {|it, acc| $acc | append $it}
         }
         | rename --column { group: "strategy", items: "diversity" }
+
+    {
+        experiment: {
+            env: $exp.env,
+            k: $exp.k,
+            n: $exp.n,
+            nb_bytes: $exp.nb_bytes,
+        },
+        measurements: $measurements,
+    }
 }
diff --git a/bins/inbreeding/plot.nu b/bins/inbreeding/plot.nu
index abb10a24..6b267131 100644
--- a/bins/inbreeding/plot.nu
+++ b/bins/inbreeding/plot.nu
@@ -40,14 +40,16 @@ def get-color []: int -> string {
     }
 }
 
-export def main [
-    --save: path,
-    --options: record<k: int>
-]: table<strategy: string, diversity: table<x: int, y: float, e: float>> -> nothing {
-    let data = $in
-    let l = $data.diversity.0 | length
+export def main [ --save: path ]: [
+    record<
+        experiment: record<k: int, n: int, nb_bytes: int, env: string>,
+        measurements: table<strategy: string, diversity: table<x: int, y: float, e: float>>,
+    > -> nothing
+] {
+    let experiment = $in
+    let l = $experiment.measurements.diversity.0 | length
 
-    $data
+    $experiment.measurements
         | update strategy { parse strategy }
         | insert sort {|it|
             match $it.strategy.type {
@@ -61,10 +63,10 @@ export def main [
         | insert name {|it|
             match $it.strategy.type {
                 "single" => {
-                    let sigma = if $it.strategy.n == $options.k {
+                    let sigma = if $it.strategy.n == $experiment.experiment.k {
                         "k"
                     } else {
-                        $"k - ($options.k - $it.strategy.n)"
+                        $"k - ($experiment.experiment.k - $it.strategy.n)"
                     }
                     $"$\\sigma = ($sigma) = ($it.strategy.n)$"
                 }
-- 
GitLab


From bcf8a2d94ce95cf7df4296518d143400a0f5dc0e Mon Sep 17 00:00:00 2001
From: "a.stevan" <antoine.stevan@isae-supaero.fr>
Date: Fri, 31 May 2024 09:39:34 +0200
Subject: [PATCH 2/2] update the README

---
 bins/inbreeding/README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bins/inbreeding/README.md b/bins/inbreeding/README.md
index 1b27f8c0..208f0e31 100644
--- a/bins/inbreeding/README.md
+++ b/bins/inbreeding/README.md
@@ -37,5 +37,5 @@ inbreeding run --options $OPTS --prng-seed $PRNG_SEED
 ```
 ```bash
 let experiment = $"($PRNG_SEED)-($OPTS.environment)-($OPTS.k)-($OPTS.n)-($OPTS.nb_bytes)"
-inbreeding load $experiment | inbreeding plot --options { k: $OPTS.k }
+inbreeding load $experiment | inbreeding plot
 ```
-- 
GitLab