From fde36a8a32076638b36c6a993bacea499c736a15 Mon Sep 17 00:00:00 2001 From: Joris Snellenburg Date: Wed, 18 Oct 2023 00:05:45 +0200 Subject: [PATCH 1/2] Add dry run option to optimize --- glotaran/project/scheme.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/glotaran/project/scheme.py b/glotaran/project/scheme.py index a0db9ba86..1d1ac9814 100644 --- a/glotaran/project/scheme.py +++ b/glotaran/project/scheme.py @@ -59,8 +59,9 @@ def optimize( "Dogbox", "Levenberg-Marquardt", ] = "TrustRegionReflection", + dry_run: bool = False, ) -> Result: - optimized_parameters, optimized_data, optimization_result = Optimization( + optimization = Optimization( list(self.experiments.values()), parameters, library=self.library, @@ -72,7 +73,10 @@ def optimize( gtol=gtol, xtol=xtol, optimization_method=optimization_method, - ).run() + ) + optimized_parameters, optimized_data, optimization_result = ( + optimization.dry_run() if dry_run else optimization.run() + ) return Result( data=optimized_data, experiments=self.experiments, From e4013a42890767e3ed00685b275532d9b520deda Mon Sep 17 00:00:00 2001 From: Joris Snellenburg Date: Wed, 18 Oct 2023 00:06:50 +0200 Subject: [PATCH 2/2] Small pytest fix --- glotaran/optimization/test/test_objective.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glotaran/optimization/test/test_objective.py b/glotaran/optimization/test/test_objective.py index 58bb99759..6c3666828 100644 --- a/glotaran/optimization/test/test_objective.py +++ b/glotaran/optimization/test/test_objective.py @@ -170,4 +170,4 @@ def test_penalty(): data_size_one = data_model_one.data["model"].size * data_model_one.data["global"].size data_size_two = data_model_two.data["model"].size * data_model_two.data["global"].size assert penalty.size == data_size_one + data_size_two + 1 - assert penalty[-1] == 5 + assert penalty[-1] == 20 # TODO: investigate