Updated Trace class

- Updated get_last_experiment_info(), a very useful function that returns the information of last experiment (to be used in feedback generation).
This commit is contained in:
Xisen Wang
2024-07-15 11:41:22 +08:00
committed by GitHub
parent 32ab23e58a
commit 0b6172dd43
+8
View File
@@ -54,6 +54,14 @@ class Trace(Generic[ASpecificScen]):
self.scen: ASpecificScen = scen
self.hist: list[Tuple[Hypothesis, Experiment, HypothesisFeedback]] = []
def get_last_experiment_info(self) -> Tuple[Hypothesis, ASpecificTask, Any]:
"""Access the last experiment result, sub-task, and the corresponding hypothesis."""
if not self.hist:
return None
last_hypothesis, last_experiment, _ = self.hist[-1]
last_task = last_experiment.sub_tasks[-1]
last_result = last_experiment.result
return last_hypothesis, last_task, last_result
class HypothesisGen:
def __init__(self, scen: Scenario):