BUG: Use itk::Math::Absolute instead of legacy itk::Math::abs in tests#6657
Conversation
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.
|
| 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
%%{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
Reviews (1): Last reviewed commit: "BUG: Use itk::Math::Absolute instead of ..." | Re-trigger Greptile
21253ca
into
InsightSoftwareConsortium:main
Replace the deprecated
itk::Math::absshim with its non-deprecated equivalentitk::Math::Absolutein two test files, fixing the nightly build failures on all dashboard clients that setITK_FUTURE_LEGACY_REMOVE.Why the nightlies fail
itk::Math::absis a backward-compatibility shim initkMath.h, wrapped in#if !defined(ITK_FUTURE_LEGACY_REMOVE). Dashboard clients that build withITK_FUTURE_LEGACY_REMOVE:BOOL=1compile the shim out, soitk::Math::absno longer resolves and these translation units fail withno member named 'abs' in namespace 'itk::Math'.itk::Math::Absoluteis the non-deprecated function the shim forwards to. For thedoublearguments 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.cxxuses 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-Universalcache locally (ITK_LEGACY_REMOVE=1,ITK_FUTURE_LEGACY_REMOVE=1, universal Debug).ITKDisplacementFieldGTestDriver+ITKMetricsv4TestDriver: 0 compile errors.InverseDisplacementFieldImageFilterGTest: 8/8 cases pass (including the two whosemaxErrorassertions use the changed lines).itkJointHistogramMutualInformationImageToImageMetricv4Test: passes.pre-commit run --all-files: clean.