Skip to content

Commit

Permalink
STYLE: Replace NumericTraits<float> ZeroValue() and OneValue() calls
Browse files Browse the repository at this point in the history
Replaced `NumericTraits<float>::ZeroValue()` calls by `0.0f`. Also
replaced the one call to `itk::NumericTraits<float>::OneValue()`, from
inside itkMathTest.

Follow-up to similar commits for `double`, but now specific for `float`,
as suggested by Dženan Zukić.
  • Loading branch information
N-Dekker authored and hjmjohnson committed Jan 26, 2022
1 parent 7182b61 commit a0d4cef
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Modules/Core/Common/test/itkBoundaryConditionTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ itkBoundaryConditionTest(int, char *[])
SmartIteratorType it2d(sz2, image2D, image2D->GetRequestedRegion());

itk::ConstantBoundaryCondition<ImageType2D> cbc;
cbc.SetConstant(itk::NumericTraits<float>::ZeroValue());
cbc.SetConstant(0.0f);
it2d.OverrideBoundaryCondition(&cbc);

SmartIteratorType::NeighborhoodType tempN;
Expand Down
3 changes: 1 addition & 2 deletions Modules/Core/Common/test/itkMathTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,7 @@ main(int, char *[])
}

// Test comparison values of different types
if (itk::Math::NotExactlyEquals(itk::NumericTraits<float>::OneValue(), 1.0) ||
itk::Math::NotExactlyEquals(1.0, static_cast<float>(1)))
if (itk::Math::NotExactlyEquals(1.0f, 1.0) || itk::Math::NotExactlyEquals(1.0, 1.0f))
{
std::cout << __FILE__ << " " << __LINE__ << " " << f << " == " << d << std::endl;
testPassStatus = EXIT_FAILURE;
Expand Down
2 changes: 1 addition & 1 deletion Modules/IO/MINC/test/itkMINCImageIOTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ MINCReadWriteTest(const char * fileName, const char * minc_storage_type, double
success = EXIT_FAILURE;
}

float metaDataFloat = itk::NumericTraits<float>::ZeroValue();
float metaDataFloat = 0.0f;
if (!itk::ExposeMetaData<float>(metaDict2, "acquisition:TestFloat", metaDataFloat) || metaDataFloat != 1.2f)
{
std::cerr << "Failure reading metaData "
Expand Down
2 changes: 1 addition & 1 deletion Modules/IO/MeshFreeSurfer/src/itkFreeSurferAsciiMeshIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ FreeSurferAsciiMeshIO ::WritePoints(void * buffer)
}
case IOComponentEnum::FLOAT:
{
WritePoints(static_cast<float *>(buffer), outputFile, itk::NumericTraits<float>::ZeroValue());
WritePoints(static_cast<float *>(buffer), outputFile, 0.0f);

break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ CurvesLevelSetFunction<TImageType, TFeatureImageType>::CalculateAdvectionImage()

typename VectorImageType::Pointer gradientImage;

if (Math::NotAlmostEquals(m_DerivativeSigma, NumericTraits<float>::ZeroValue()))
if (Math::NotAlmostEquals(m_DerivativeSigma, 0.0f))
{
using DerivativeFilterType = GradientRecursiveGaussianImageFilter<FeatureImageType, VectorImageType>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ GeodesicActiveContourLevelSetFunction<TImageType, TFeatureImageType>::CalculateA

typename VectorImageType::Pointer gradientImage;

if (Math::NotAlmostEquals(m_DerivativeSigma, NumericTraits<float>::ZeroValue()))
if (Math::NotAlmostEquals(m_DerivativeSigma, 0.0f))
{
using DerivativeFilterType = GradientRecursiveGaussianImageFilter<FeatureImageType, VectorImageType>;

Expand Down

0 comments on commit a0d4cef

Please sign in to comment.