From e5672c9946ecf6eab3b4d9c5ed4087041e743f15 Mon Sep 17 00:00:00 2001 From: Alexandros Evangelou Date: Fri, 14 Aug 2026 13:06:19 +0300 Subject: [PATCH 1/2] check if next difficulty exist check if next difficulty exists and if not stay in the same difficulty --- src/ethopy/core/experiment.py | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/ethopy/core/experiment.py b/src/ethopy/core/experiment.py index 2918943..8e3c4b4 100644 --- a/src/ethopy/core/experiment.py +++ b/src/ethopy/core/experiment.py @@ -679,15 +679,26 @@ def _update_block_difficulty(self, perf: float) -> None: perf: Current performance metric """ - if self.cur_block_sz >= self.curr_cond["staircase_window"]: - if perf >= self.curr_cond["stair_up"]: - self.cur_block = self.curr_cond["next_up"] - self.cur_block_sz = 0 - self.logger.update_setup_info({"difficulty": self.cur_block}) - elif perf < self.curr_cond["stair_down"]: - self.cur_block = self.curr_cond["next_down"] - self.cur_block_sz = 0 - self.logger.update_setup_info({"difficulty": self.cur_block}) + if self.cur_block_sz < self.curr_cond["staircase_window"]: + return + + if perf >= self.curr_cond["stair_up"]: + next_block = self.curr_cond["next_up"] + elif perf < self.curr_cond["stair_down"]: + next_block = self.curr_cond["next_down"] + else: + return + + self.cur_block_sz = 0 + if next_block not in self.blocks: + log.warning( + f"No conditions with difficulty {next_block}, " + f"staying in difficulty {self.cur_block}." + ) + return + + self.cur_block = next_block + self.logger.update_setup_info({"difficulty": self.cur_block}) def _get_valid_conditions(self, condition_idx: np.ndarray) -> List[Dict]: """Get list of valid conditions based on condition index. From ee2a29e77313082f3c08cb2ca39fe400430c4008 Mon Sep 17 00:00:00 2001 From: Alexandros Evangelou Date: Mon, 7 Sep 2026 10:54:11 +0300 Subject: [PATCH 2/2] raise error if the next block does not exist --- src/ethopy/core/experiment.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ethopy/core/experiment.py b/src/ethopy/core/experiment.py index 8e3c4b4..09033d8 100644 --- a/src/ethopy/core/experiment.py +++ b/src/ethopy/core/experiment.py @@ -691,11 +691,10 @@ def _update_block_difficulty(self, perf: float) -> None: self.cur_block_sz = 0 if next_block not in self.blocks: - log.warning( + raise ValueError( f"No conditions with difficulty {next_block}, " - f"staying in difficulty {self.cur_block}." + f"cannot move from difficulty {self.cur_block}." ) - return self.cur_block = next_block self.logger.update_setup_info({"difficulty": self.cur_block})