Skip to content

Commit

Permalink
BUG: Set ivar to appropriate value when condition is met
Browse files Browse the repository at this point in the history
Set the appropriate value to the `itk::OnePlusOneEvolutionaryOptimizer`
`m_Initialized` ivar when the condition described in the documentation
for its purpose is fulfilled.

The variable was initialized to `false` in the constructor and its value
was not being changed anywhere else, and the variable is not meant to be
changed through a setter method.
  • Loading branch information
jhlegarreta authored and dzenanz committed Jan 2, 2023
1 parent d1c46d6 commit cd3e200
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
Expand Up @@ -73,6 +73,8 @@ OnePlusOneEvolutionaryOptimizer::Initialize(double initialRadius, double grow, d
{
m_ShrinkFactor = shrink;
}

m_Initialized = true;
}

void
Expand Down
Expand Up @@ -20,6 +20,7 @@
#include "itkNormalVariateGenerator.h"
#include "itkCommand.h"
#include "itkMath.h"
#include "itkTestingMacros.h"

namespace itk
{
Expand Down Expand Up @@ -152,6 +153,8 @@ itkOnePlusOneEvolutionaryOptimizerTest(int, char *[])
// Declaration of an itkOptimizer
auto itkOptimizer = OptimizerType::New();

ITK_TEST_EXPECT_TRUE(!itkOptimizer->GetInitialized());

itk::OnePlusOneCommandIterationUpdate::Pointer observer = itk::OnePlusOneCommandIterationUpdate::New();
itkOptimizer->AddObserver(itk::IterationEvent(), observer);

Expand All @@ -178,6 +181,8 @@ itkOnePlusOneEvolutionaryOptimizerTest(int, char *[])
itkOptimizer->SetMaximumIteration(8000);


ITK_TEST_EXPECT_TRUE(itkOptimizer->GetInitialized());

using GeneratorType = itk::Statistics::NormalVariateGenerator;
auto generator = GeneratorType::New();
itkOptimizer->SetNormalVariateGenerator(generator);
Expand Down

0 comments on commit cd3e200

Please sign in to comment.