From 4e71f5065cc1b43f5e4a9652f3ce85e9160c9c34 Mon Sep 17 00:00:00 2001 From: Christopher Spinrath <christopher.spinrath@univ-grenoble-alpes.fr> Date: Fri, 24 Jan 2025 00:08:44 +0100 Subject: [PATCH] Support range variables --- run-exp.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/run-exp.py b/run-exp.py index 1a26376..35f15b6 100755 --- a/run-exp.py +++ b/run-exp.py @@ -37,15 +37,24 @@ class Variable: return cls.new_scalar(name, value_config) var_type = value_config["type"] - assert var_type in ["file"], "Unsupported variable type." + assert var_type in ["file", "range"], "Unsupported variable type." - directory = pathlib.Path(value_config["directory"]) - assert directory.exists() and directory.is_dir() + if var_type == "file": + directory = pathlib.Path(value_config["directory"]) + assert directory.exists() and directory.is_dir() - values = list(directory.iterdir()) + values = list(directory.iterdir()) - if value_config.get("basename", False): - values = [v.name for v in values] + if value_config.get("basename", False): + values = [v.name for v in values] + + if var_type == "range": + assert "max" in value_config, f"Missing \"max\" value for range variable \"{name}\"" + upper = value_config["max"] + lower = value_config.get("min", 0) + step = value_config.get("step", 1) + + values = list(range(lower, upper + 1, step)) return cls.new_multi_valued(name, values) -- GitLab