Skip to content

BUG: Use itk::Math::Absolute instead of legacy itk::Math::abs in tests#6657

Merged
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:mainfrom
hjmjohnson:fix-math-abs-future-legacy-remove
Jul 17, 2026
Merged

BUG: Use itk::Math::Absolute instead of legacy itk::Math::abs in tests#6657
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:mainfrom
hjmjohnson:fix-math-abs-future-legacy-remove

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

Replace the deprecated itk::Math::abs shim with its non-deprecated equivalent itk::Math::Absolute in two test files, fixing the nightly build failures on all dashboard clients that set ITK_FUTURE_LEGACY_REMOVE.

Why the nightlies fail

itk::Math::abs is a backward-compatibility shim in itkMath.h, wrapped in #if !defined(ITK_FUTURE_LEGACY_REMOVE). Dashboard clients that build with ITK_FUTURE_LEGACY_REMOVE:BOOL=1 compile the shim out, so itk::Math::abs no longer resolves and these translation units fail with no member named 'abs' in namespace 'itk::Math'.

itk::Math::Absolute is the non-deprecated function the shim forwards to. For the double arguments used in both tests it has identical behavior.

Affected nightly builds (2026-07-17): RogueResearch Mac13/Mac14/Mac15/Mac10.15/Mac11 dbg-Universal, Mac26 ClangMain, Mac15 ASan/UBSan — every dashboard build-error on that day traced to this single site.

The second file is a latent breakage

The nightly reported only itkInverseDisplacementFieldImageFilterGTest.cxx, because the build stops at the first compile error. itkJointHistogramMutualInformationImageToImageMetricv4Test.cxx uses the same deprecated call and would fail as soon as the first is fixed, so both are corrected here in one commit.

Local verification

Replicated the RogueResearch24 Mac13.x-AppleClang-dbg-Universal cache locally (ITK_LEGACY_REMOVE=1, ITK_FUTURE_LEGACY_REMOVE=1, universal Debug).

  • ITKDisplacementFieldGTestDriver + ITKMetricsv4TestDriver: 0 compile errors.
  • InverseDisplacementFieldImageFilter GTest: 8/8 cases pass (including the two whose maxError assertions use the changed lines).
  • itkJointHistogramMutualInformationImageToImageMetricv4Test: passes.
  • pre-commit run --all-files: clean.

itk::Math::abs is a backward-compatibility shim compiled out when
ITK_FUTURE_LEGACY_REMOVE is enabled, so nightly dashboards building
with that option (RogueResearch Universal, ClangMain, ASan/UBSan)
fail to compile these two test translation units. itk::Math::Absolute
is the non-deprecated equivalent with identical behavior for the
floating-point arguments used here.
@github-actions github-actions Bot added type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Filtering Issues affecting the Filtering module area:Registration Issues affecting the Registration module labels Jul 17, 2026
@hjmjohnson
hjmjohnson marked this pull request as ready for review July 17, 2026 18:00
@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes nightly build failures on dashboard clients that set ITK_FUTURE_LEGACY_REMOVE=1 by replacing the deprecated itk::Math::abs shim (gated behind #if !defined(ITK_FUTURE_LEGACY_REMOVE) in itkMath.h) with its non-deprecated equivalent itk::Math::Absolute in two test files.

  • itkInverseDisplacementFieldImageFilterGTest.cxx: two itk::Math::abs calls in maxError accumulation expressions replaced with itk::Math::Absolute.
  • itkJointHistogramMutualInformationImageToImageMetricv4Test.cxx: three itk::Math::abs calls in the analytic/finite-difference ratio guard replaced with itk::Math::Absolute. The PR also proactively fixes the second file, which would have failed as soon as the first compile error was resolved.

Confidence Score: 5/5

Safe to merge — both changes are mechanical symbol substitutions with identical runtime semantics for the double arguments used.

All five changed call sites substitute itk::Math::Absolute for the deprecated itk::Math::abs shim, which is a direct forwarding wrapper. The argument types are double in both files, so there is no behavioral difference. A grep across the entire Modules/ tree confirms no remaining itk::Math::abs usages, and the second file was proactively included to avoid a follow-on failure.

No files require special attention.

Important Files Changed

Filename Overview
Modules/Filtering/DisplacementField/test/itkInverseDisplacementFieldImageFilterGTest.cxx Replaces two calls to deprecated itk::Math::abs with itk::Math::Absolute; behavior is identical for the double arguments used here.
Modules/Registration/Metricsv4/test/itkJointHistogramMutualInformationImageToImageMetricv4Test.cxx Replaces three calls to deprecated itk::Math::abs with itk::Math::Absolute in the analytic/finite-difference comparison guard; behavior is identical for double arguments.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Compiler processes test TU"] --> B{ITK_FUTURE_LEGACY_REMOVE defined?}
    B -- No --> C["itk::Math::abs shim available\n(backwards-compat wrapper)"]
    B -- Yes --> D["itk::Math::abs shim compiled out\n→ compile error: 'no member abs'"]
    C --> E["itk::Math::Absolute called via shim"]
    D -.fix.-> F["itk::Math::Absolute called directly"]
    E --> G["double abs value returned"]
    F --> G
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["Compiler processes test TU"] --> B{ITK_FUTURE_LEGACY_REMOVE defined?}
    B -- No --> C["itk::Math::abs shim available\n(backwards-compat wrapper)"]
    B -- Yes --> D["itk::Math::abs shim compiled out\n→ compile error: 'no member abs'"]
    C --> E["itk::Math::Absolute called via shim"]
    D -.fix.-> F["itk::Math::Absolute called directly"]
    E --> G["double abs value returned"]
    F --> G
Loading

Reviews (1): Last reviewed commit: "BUG: Use itk::Math::Absolute instead of ..." | Re-trigger Greptile

@hjmjohnson
hjmjohnson merged commit 21253ca into InsightSoftwareConsortium:main Jul 17, 2026
19 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Filtering Issues affecting the Filtering module area:Registration Issues affecting the Registration module type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants