Skip to content

Commit 7597180

Browse files
authored
Merge pull request #5658 from N-Dekker/Remove-vnl_sample-from-tests
Remove or replace `vnl_sample` from a few more tests
2 parents baea356 + fa35af3 commit 7597180

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Modules/Registration/Common/test/itkImageRegistrationMethodTest_17.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#include "itkTextOutput.h"
2525
#include "itkCommandIterationUpdate.h"
26-
#include "vnl/vnl_sample.h"
26+
2727
namespace
2828
{
2929

Modules/Segmentation/SignedDistanceFunction/test/itkPCAShapeSignedDistanceFunctionGTest.cxx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818

1919
#include "itkPCAShapeSignedDistanceFunction.h"
2020

21-
#include "vnl/vnl_sample.h"
2221
#include "itkImageRegionIterator.h"
2322
#include "itkEuler2DTransform.h"
2423

2524
#include <gtest/gtest.h>
2625

26+
#include <random> // For mt19937.
27+
2728
/**
2829
* This module tests the functionality of the PCAShapeSignedDistanceFunction
2930
* class.
@@ -65,7 +66,8 @@ TEST(PCAShapeSignedDistanceFunction, Test)
6566

6667

6768
// set up the random number generator
68-
vnl_sample_reseed();
69+
std::mt19937 randomNumberEngine{};
70+
std::normal_distribution<double> randomNumberDistribution(0.0, 1.0);
6971

7072
// set up the mean image
7173
auto meanImage = ImageType::New();
@@ -77,7 +79,7 @@ TEST(PCAShapeSignedDistanceFunction, Test)
7779

7880
for (meanImageIt.GoToBegin(); !meanImageIt.IsAtEnd(); ++meanImageIt)
7981
{
80-
ImageType::PixelType randomPixel = vnl_sample_normal(0, 1);
82+
ImageType::PixelType randomPixel = randomNumberDistribution(randomNumberEngine);
8183
meanImageIt.Set(randomPixel);
8284
}
8385

@@ -99,7 +101,7 @@ TEST(PCAShapeSignedDistanceFunction, Test)
99101

100102
for (pcImageIts[i].GoToBegin(); !pcImageIts[i].IsAtEnd(); ++pcImageIts[i])
101103
{
102-
ImageType::PixelType randomPixel = vnl_sample_normal(0, 1);
104+
ImageType::PixelType randomPixel = randomNumberDistribution(randomNumberEngine);
103105
pcImageIts[i].Set(randomPixel);
104106
}
105107
}
@@ -112,7 +114,7 @@ TEST(PCAShapeSignedDistanceFunction, Test)
112114

113115
for (unsigned int i = 0; i < NumberOfPCs; ++i)
114116
{
115-
pcStandardDeviations[i] = vnl_sample_normal(0, 1);
117+
pcStandardDeviations[i] = randomNumberDistribution(randomNumberEngine);
116118
}
117119

118120
shape->SetPrincipalComponentStandardDeviations(pcStandardDeviations);
@@ -126,7 +128,7 @@ TEST(PCAShapeSignedDistanceFunction, Test)
126128

127129
for (unsigned int i = 0; i < numberOfParameters; ++i)
128130
{
129-
parameters[i] = vnl_sample_normal(0, 1);
131+
parameters[i] = randomNumberDistribution(randomNumberEngine);
130132
}
131133

132134
shape->SetParameters(parameters);

0 commit comments

Comments
 (0)