Skip to content

Commit

Permalink
ENH: Increase the itk::SingleValuedNonLinearVnlOptimizerv4 coverage
Browse files Browse the repository at this point in the history
Increase the code coverage for the
`itk::SingleValuedNonLinearVnlOptimizerv4` class: exercise the
`GetCachedDerivative` and `GetCachedPosition` methods and test their
values against the expected values.
  • Loading branch information
jhlegarreta authored and dzenanz committed Nov 13, 2023
1 parent 50b905a commit 215209f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,12 @@ AmoebaTest1()
itkOptimizer->SetFunctionConvergenceTolerance(fTolerance);
ITK_TEST_SET_GET_VALUE(fTolerance, itkOptimizer->GetFunctionConvergenceTolerance());

OptimizerType::DerivativeType cachedDerivative{};
ITK_TEST_EXPECT_EQUAL(cachedDerivative, itkOptimizer->GetCachedDerivative());

OptimizerType::ParametersType cachedCurrentPos{};
ITK_TEST_EXPECT_EQUAL(cachedCurrentPos, itkOptimizer->GetCachedCurrentPosition());

auto metric = itkAmoebaOptimizerv4TestMetric1::New();
itkOptimizer->SetMetric(metric);
std::cout << "itkOptimizer->GetMetric(): " << itkOptimizer->GetMetric() << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ itkLBFGSOptimizerv4Test(int, char *[])
itkOptimizer->SetDefaultStepLength(defaultStepLength);
ITK_TEST_SET_GET_VALUE(defaultStepLength, itkOptimizer->GetDefaultStepLength());

OptimizerType::DerivativeType cachedDerivative{};
ITK_TEST_EXPECT_EQUAL(cachedDerivative, itkOptimizer->GetCachedDerivative());

OptimizerType::ParametersType cachedCurrentPos{};
ITK_TEST_EXPECT_EQUAL(cachedCurrentPos, itkOptimizer->GetCachedCurrentPosition());

std::cout << "GetValue() before optimizer starts: " << itkOptimizer->GetValue() << std::endl;
std::cout << "SetMetric." << std::endl;
itkOptimizer->SetMetric(metric);
Expand Down

0 comments on commit 215209f

Please sign in to comment.