Skip to content

Commit

Permalink
STYLE: Remove p->Initialize() calls after p = T::New() in tests
Browse files Browse the repository at this point in the history
For most ITK types, `p->Initialize()` has no effect, directly after
`p = T::New()`, so the `Initialize()` call might as well be removed.

Excluded a `randomNumberGenerator->Initialize()` call from this commit, as that
call appears to actually have an effect (randomizing the seed).

- Follow-up to pull request InsightSoftwareConsortium#4972
commit 674b3d2
"STYLE: Remove `p->Initialize()` calls directly after `p = T::New()`"
  • Loading branch information
N-Dekker committed Nov 21, 2024
1 parent 674b3d2 commit 366ce7e
Show file tree
Hide file tree
Showing 21 changed files with 0 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ itkDisplacementFieldToBSplineImageFilterTest(int, char *[])
confidenceImage->FillBuffer(1.0);

auto pointSet = PointSetType::New();
pointSet->Initialize();

auto ones_points = itk::MakeFilled<VectorType>(1.0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ itkBSplineScatteredDataPointSetToImageFilterTest2(int argc, char * argv[])

FilterType::WeightsContainerType::Pointer pointWeights = FilterType::WeightsContainerType::New();

pointWeights->Initialize();

unsigned int abritrarySize = filter->GetInput()->GetNumberOfPoints() - 1;
pointWeights->resize(abritrarySize);
for (unsigned int i = 0; i < pointWeights->Size(); ++i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,9 @@ itkBSplineScatteredDataPointSetToImageFilterTest4(int, char *[])
// Instantiate example corresponding points with relative weighting

auto pointSet = PointSetType::New();
pointSet->Initialize();

using WeightsContainerType = FilterType::WeightsContainerType;
auto weights = WeightsContainerType::New();
weights->Initialize();

// Create first landmark pair and weights
PointType landmarkInFirstImage1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ itkRegistrationParameterScalesFromPhysicalShiftPointSetTest(int, char *[])
using PointType = PointSetType::PointType;

auto fixedPoints = PointSetType::New();
fixedPoints->Initialize();
auto movingPoints = PointSetType::New();
movingPoints->Initialize();

itk::Size<Dimension> virtualDomainSize;
virtualDomainSize[0] = static_cast<itk::SizeValueType>(10);
Expand Down
1 change: 0 additions & 1 deletion Modules/Registration/Common/test/itkPointsLocatorTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ testPointsLocatorTest()

using PointsContainerType = TPointsContainer;
auto points = PointsContainerType::New();
points->Initialize();

using PointsLocatorType = itk::PointsLocator<PointsContainerType>;
auto pointsLocator = PointsLocatorType::New();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ itkEuclideanDistancePointSetMetricRegistrationTestRun(unsigned int
using CoordRepType = typename PointType::CoordRepType;

auto fixedPoints = PointSetType::New();
fixedPoints->Initialize();

auto movingPoints = PointSetType::New();
movingPoints->Initialize();

// Create a few points and apply a small rotation to make the moving point set

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ itkEuclideanDistancePointSetMetricTestRun()
using PointType = typename PointSetType::PointType;

auto fixedPoints = PointSetType::New();
fixedPoints->Initialize();

auto movingPoints = PointSetType::New();
movingPoints->Initialize();

// Produce two simple point sets of 1) a circle and 2) the same circle with an offset;
PointType offset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@ itkEuclideanDistancePointSetMetricTest2Run()
using PointType = typename PointSetType::PointType;

auto fixedPoints = PointSetType::New();
fixedPoints->Initialize();

auto movingPoints = PointSetType::New();
movingPoints->Initialize();

// Create a few points and apply a small offset to make the moving points
auto pointMax = static_cast<float>(100.0);
Expand Down Expand Up @@ -200,7 +198,6 @@ itkEuclideanDistancePointSetMetricTest2Run()

// Test with no valid points.
auto fixedPoints2 = PointSetType::New();
fixedPoints2->Initialize();
fixedPoint[0] = -pointMax;
fixedPoint[1] = 0.0;
fixedPoints2->SetPoint(0, fixedPoint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@ itkEuclideanDistancePointSetMetricTest3Run(double distanceThreshold)
auto pointsLocator = PointsLocatorType::New();

auto fixedPoints = PointSetType::New();
fixedPoints->Initialize();

auto movingPoints = PointSetType::New();
movingPoints->Initialize();

// Create a few points and apply a small offset to make the moving points
auto pointMax = static_cast<float>(1.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@ itkExpectationBasedPointSetMetricRegistrationTest(int argc, char * argv[])
using PointType = PointSetType::PointType;

auto fixedPoints = PointSetType::New();
fixedPoints->Initialize();

auto movingPoints = PointSetType::New();
movingPoints->Initialize();


// two ellipses, one rotated slightly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ itkExpectationBasedPointSetMetricTestRun()
using PointType = typename PointSetType::PointType;

auto fixedPoints = PointSetType::New();
fixedPoints->Initialize();

auto movingPoints = PointSetType::New();
movingPoints->Initialize();

// Produce two simple point sets of 1) a circle and 2) the same circle with an offset;
PointType offset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@ itkJensenHavrdaCharvatTsallisPointSetMetricRegistrationTest(int argc, char * arg
using PointType = PointSetType::PointType;

auto fixedPoints = PointSetType::New();
fixedPoints->Initialize();

auto movingPoints = PointSetType::New();
movingPoints->Initialize();


// two ellipses, one rotated slightly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ itkJensenHavrdaCharvatTsallisPointSetMetricTestRun()
using VectorType = typename PointType::VectorType;

auto fixedPoints = PointSetType::New();
fixedPoints->Initialize();

auto movingPoints = PointSetType::New();
movingPoints->Initialize();

// Produce two simple point sets of 1) a circle and 2) the same circle with an offset
PointType offset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,8 @@ itkLabeledPointSetMetricRegistrationTestPerMetric(unsigned int numberOfIteration
using PointType = typename PointSetType::PointType;

auto fixedPoints = PointSetType::New();
fixedPoints->Initialize();

auto movingPoints = PointSetType::New();
movingPoints->Initialize();

// two circles with a small offset
PointType offset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ itkLabeledPointSetMetricTestRun()
using PointType = typename PointSetType::PointType;

auto fixedPoints = PointSetType::New();
fixedPoints->Initialize();

auto movingPoints = PointSetType::New();
movingPoints->Initialize();

// Produce two simple point sets of 1) a circle and 2) the same circle with an offset;
PointType offset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ itkBSplineSyNPointSetRegistrationTest(int itkNotUsed(argc), char * itkNotUsed(ar


auto fixedPoints = PointSetType::New();
fixedPoints->Initialize();

auto movingPoints = PointSetType::New();
movingPoints->Initialize();

// two circles with a small offset
PointType offset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,8 @@ itkSimplePointSetRegistrationTest(int itkNotUsed(argc), char * itkNotUsed(argv)[


auto fixedPoints = PointSetType::New();
fixedPoints->Initialize();

auto movingPoints = PointSetType::New();
movingPoints->Initialize();

// two circles with a small offset
PointType offset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ itkSyNPointSetRegistrationTest(int itkNotUsed(argc), char * itkNotUsed(argv)[])


auto fixedPoints = PointSetType::New();
fixedPoints->Initialize();

auto movingPoints = PointSetType::New();
movingPoints->Initialize();

// two circles with a small offset
PointType offset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ itkTimeVaryingBSplineVelocityFieldPointSetRegistrationTest(int itkNotUsed(argc),


auto fixedPoints = PointSetType::New();
fixedPoints->Initialize();

auto movingPoints = PointSetType::New();
movingPoints->Initialize();

// two circles with a small offset
PointType offset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ itkShapePriorMAPCostFunctionTest(int, char *[])
*/
using ShapeFunctionType = itk::SphereSignedDistanceFunction<double, Dimension>;
auto shape = ShapeFunctionType::New();
shape->Initialize();

/**
* Set up a statistical model of the shape parameters.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ itkShapePriorSegmentationLevelSetFunctionTest(int, char *[])

using ShapeFunctionType = itk::SphereSignedDistanceFunction<double, Dimension>;
auto shape = ShapeFunctionType::New();
shape->Initialize();

ShapeFunctionType::ParametersType parameters(shape->GetNumberOfParameters());
parameters[0] = 10.0;
Expand Down

0 comments on commit 366ce7e

Please sign in to comment.