From 9b0d7fd06a13676c09559715ae66ab05613a28cc Mon Sep 17 00:00:00 2001 From: Polina Lakrisenko Date: Tue, 10 Oct 2023 09:31:23 +0200 Subject: [PATCH] Get optimization result by id (#1116) * add possibility to get an optimization result with specified id --- pypesto/result/optimize.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pypesto/result/optimize.py b/pypesto/result/optimize.py index 6f38a4fba..c77a57460 100644 --- a/pypesto/result/optimize.py +++ b/pypesto/result/optimize.py @@ -406,3 +406,11 @@ def get_for_key(self, key) -> list: "releases." ) return [res[key] for res in self.list] + + def get_by_id(self, ores_id: str): + """Get OptimizationResult with the specified id.""" + for res in self.list: + if res.id == ores_id: + return res + else: + raise ValueError(f"no optimization result with id={ores_id}")