Skip to content
Snippets Groups Projects
Commit 142e673e authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

add information about experiment to `inbreeding load` (!134)

this can be used by `plot` without passing extra arguments, i.e. the pipeline becomes
```bash
use bins/inbreeding

let experiment = "..."
```
```bash
inbreeding load $experiment | inbreeding plot
```
instead of having to know the value of `k` and do
```bash
inbreeding load $experiment | inbreeding plot --options { k: $k }
```
parent a3a5f2e2
No related branches found
No related tags found
1 merge request!134add information about experiment to `inbreeding load`
Pipeline #5351 passed
...@@ -37,5 +37,5 @@ inbreeding run --options $OPTS --prng-seed $PRNG_SEED ...@@ -37,5 +37,5 @@ inbreeding run --options $OPTS --prng-seed $PRNG_SEED
``` ```
```bash ```bash
let experiment = $"($PRNG_SEED)-($OPTS.environment)-($OPTS.k)-($OPTS.n)-($OPTS.nb_bytes)" 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
``` ```
...@@ -18,8 +18,18 @@ def get-experiments []: nothing -> list<string> { ...@@ -18,8 +18,18 @@ def get-experiments []: nothing -> list<string> {
export def main [ export def main [
experiment: string@get-experiments, 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 == {} { if $exp == {} {
error throw { error throw {
err: "invalid experiment", err: "invalid experiment",
...@@ -45,7 +55,7 @@ export def main [ ...@@ -45,7 +55,7 @@ export def main [
} }
} }
$experiment_files let measurements = $experiment_files
| select name | select name
| insert . { get name | remove-cache-prefix | parse --regex $consts.EXPERIMENT_FORMAT } | insert . { get name | remove-cache-prefix | parse --regex $consts.EXPERIMENT_FORMAT }
| flatten --all | flatten --all
...@@ -71,4 +81,14 @@ export def main [ ...@@ -71,4 +81,14 @@ export def main [
$d | skip 1 | reduce --fold $d.0 {|it, acc| $acc | append $it} $d | skip 1 | reduce --fold $d.0 {|it, acc| $acc | append $it}
} }
| rename --column { group: "strategy", items: "diversity" } | rename --column { group: "strategy", items: "diversity" }
{
experiment: {
env: $exp.env,
k: $exp.k,
n: $exp.n,
nb_bytes: $exp.nb_bytes,
},
measurements: $measurements,
}
} }
...@@ -40,14 +40,16 @@ def get-color []: int -> string { ...@@ -40,14 +40,16 @@ def get-color []: int -> string {
} }
} }
export def main [ export def main [ --save: path ]: [
--save: path, record<
--options: record<k: int> experiment: record<k: int, n: int, nb_bytes: int, env: string>,
]: table<strategy: string, diversity: table<x: int, y: float, e: float>> -> nothing { measurements: table<strategy: string, diversity: table<x: int, y: float, e: float>>,
let data = $in > -> nothing
let l = $data.diversity.0 | length ] {
let experiment = $in
let l = $experiment.measurements.diversity.0 | length
$data $experiment.measurements
| update strategy { parse strategy } | update strategy { parse strategy }
| insert sort {|it| | insert sort {|it|
match $it.strategy.type { match $it.strategy.type {
...@@ -61,10 +63,10 @@ export def main [ ...@@ -61,10 +63,10 @@ export def main [
| insert name {|it| | insert name {|it|
match $it.strategy.type { match $it.strategy.type {
"single" => { "single" => {
let sigma = if $it.strategy.n == $options.k { let sigma = if $it.strategy.n == $experiment.experiment.k {
"k" "k"
} else { } else {
$"k - ($options.k - $it.strategy.n)" $"k - ($experiment.experiment.k - $it.strategy.n)"
} }
$"$\\sigma = ($sigma) = ($it.strategy.n)$" $"$\\sigma = ($sigma) = ($it.strategy.n)$"
} }
......
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