From 7d55e08d59ddf02ead5046fcd4fe162df08fc8c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Sun, 5 Nov 2023 10:51:17 -0500 Subject: [PATCH 1/2] ENH: Increase `itk::SingleValuedNonLinearVnlOptimizer` coverage Increase `itk::SingleValuedNonLinearVnlOptimizer` coverage: test the `CanUseScales` method. --- Modules/Numerics/Optimizers/test/itkAmoebaOptimizerTest.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/Numerics/Optimizers/test/itkAmoebaOptimizerTest.cxx b/Modules/Numerics/Optimizers/test/itkAmoebaOptimizerTest.cxx index e41d5e575ff..5711a021b01 100644 --- a/Modules/Numerics/Optimizers/test/itkAmoebaOptimizerTest.cxx +++ b/Modules/Numerics/Optimizers/test/itkAmoebaOptimizerTest.cxx @@ -278,6 +278,8 @@ AmoebaTest1() ITK_EXERCISE_BASIC_OBJECT_METHODS(itkOptimizer, AmoebaOptimizer, SingleValuedNonLinearVnlOptimizer); + ITK_TEST_EXPECT_TRUE(itkOptimizer->CanUseScales()); + // set optimizer parameters typename OptimizerType::NumberOfIterationsType numberOfIterations = 10; itkOptimizer->SetMaximumNumberOfIterations(numberOfIterations); From a4120d87cbff405ecc2d0bedf6f48edf4e43584c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Haitz=20Legarreta=20Gorro=C3=B1o?= Date: Sun, 5 Nov 2023 11:17:49 -0500 Subject: [PATCH 2/2] ENH: Increase coverage for `itk::ObjectToObjectOptimizerBaseTemplate` Increase coverage for `itk::ObjectToObjectOptimizerBaseTemplate`: test the `CanUseScales` method and the Set/Get/Boolean macros for the `DoEstimateScales` ivar. Take advantage of the commit to remove an uninformative comment. --- .../Numerics/Optimizersv4/test/itkAmoebaOptimizerv4Test.cxx | 5 +++++ .../test/itkGradientDescentOptimizerBasev4Test.cxx | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Modules/Numerics/Optimizersv4/test/itkAmoebaOptimizerv4Test.cxx b/Modules/Numerics/Optimizersv4/test/itkAmoebaOptimizerv4Test.cxx index 6d05d0ede52..fe5820dcadd 100644 --- a/Modules/Numerics/Optimizersv4/test/itkAmoebaOptimizerv4Test.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkAmoebaOptimizerv4Test.cxx @@ -343,6 +343,11 @@ AmoebaTest1() ITK_EXERCISE_BASIC_OBJECT_METHODS(itkOptimizer, AmoebaOptimizerv4, SingleValuedNonLinearVnlOptimizerv4); + ITK_TEST_EXPECT_TRUE(itkOptimizer->CanUseScales()); + + bool doEstimateScales = true; + ITK_TEST_SET_GET_BOOLEAN(itkOptimizer, DoEstimateScales, doEstimateScales); + // set optimizer parameters itk::SizeValueType numberOfIterations = 10; itkOptimizer->SetNumberOfIterations(numberOfIterations); diff --git a/Modules/Numerics/Optimizersv4/test/itkGradientDescentOptimizerBasev4Test.cxx b/Modules/Numerics/Optimizersv4/test/itkGradientDescentOptimizerBasev4Test.cxx index 600bb25dfc1..9de7749688e 100644 --- a/Modules/Numerics/Optimizersv4/test/itkGradientDescentOptimizerBasev4Test.cxx +++ b/Modules/Numerics/Optimizersv4/test/itkGradientDescentOptimizerBasev4Test.cxx @@ -173,7 +173,9 @@ itkGradientDescentOptimizerBasev4Test(int, char *[]) auto metric = MetricType::New(); auto optimizer = GradientDescentOptimizerBasev4TestOptimizer::New(); - /* exercise some methods */ + bool doEstimateScales = true; + ITK_TEST_SET_GET_BOOLEAN(optimizer, DoEstimateScales, doEstimateScales); + optimizer->SetMetric(metric); if (optimizer->GetMetric() != metric) {