Skip to content

STYLE: Use itk::Math::Absolute() instead of abs to communicate subtle implementation differences#5802

Draft
hjmjohnson wants to merge 4 commits intomainfrom
instrument-safe_abs-names
Draft

STYLE: Use itk::Math::Absolute() instead of abs to communicate subtle implementation differences#5802
hjmjohnson wants to merge 4 commits intomainfrom
instrument-safe_abs-names

Conversation

@hjmjohnson
Copy link
Member

@hjmjohnson hjmjohnson commented Feb 13, 2026

  • STYLE: Use itk::Math::Absolute() name directly

Depends on :

PR Checklist

@github-actions github-actions bot added the type:Style Style changes: no logic impact (indentation, comments, naming) label Feb 13, 2026
@hjmjohnson hjmjohnson force-pushed the instrument-safe_abs-names branch from d754a92 to 7a09873 Compare February 13, 2026 22:09
@hjmjohnson hjmjohnson force-pushed the instrument-safe_abs-names branch from 7a09873 to 189ab05 Compare February 14, 2026 16:42
@hjmjohnson hjmjohnson changed the title STYLE: Use safe_abs instead of abs to communicate subtle implementation differences STYLE: Use itk::Math::Absolute() instead of abs to communicate subtle implementation differences Feb 14, 2026
@hjmjohnson hjmjohnson force-pushed the instrument-safe_abs-names branch from 189ab05 to b4a79d8 Compare February 14, 2026 16:49
- Removed redundant definitions of `IsPrime` and `GreatestPrimeFactor`
  in `itkMath.cxx` by incorporating template-based implementations in
  `itkMath.h`.
- Improved compile-time evaluation and type safety with `constexpr` and
  `std::enable_if_t`.
- Updated tests to leverage the new `constexpr` `itk::Math` functions.
- Enhanced maintainability by consolidating code and leveraging modern C++ features.
Use GTest framework for testing the math functions.
- Updated the function name from `safe_abs` to `Absolute` in itkMath.h
  for clarity and consistency with ITK naming conventions.
- Revised function comments to reflect the name change and provide
  additional details about differences with `std::abs`.
- Modified corresponding test cases in itkMathGTest.cxx to validate the
  renamed `Absolute` function, ensuring accurate behavior and backward
  compatibility.
The itk::Math::Absolute is subtly different from
the std::abs and other typical absolute value functions,
so use the more explicit name to clearly indicate
that the behaviors are not the same as the
core c++ similarly named functions.

Use ITK_FUTURE_LEGACY_REMOVE of the itk::Math::abs
supported name.
@hjmjohnson hjmjohnson force-pushed the instrument-safe_abs-names branch from b4a79d8 to d36ba88 Compare February 14, 2026 18:29
@N-Dekker
Copy link
Contributor

N-Dekker commented Feb 15, 2026

@hjmjohnson Very nice improvements! Thank you for following my itk::Math::Absolute renaming suggestion!

In general, please try to keep pull requests a bit smaller. 🙏 As a reviewer, I find PRs of more than a thousand lines of code a bit overwhelming. (In fact, I usually cannot review PRs of 1000+ lines very carefully anymore.) A commit like "Convert itkMathTest to itkMathGTest" may be a candidate for a separate PR.

@hjmjohnson
Copy link
Member Author

@hjmjohnson Very nice improvements! Thank you for following my itk::Math::Absolute renaming suggestion!

In general, please try to keep pull requests a bit smaller. 🙏 As a reviewer, I find PRs of more than a thousand lines of code a bit overwhelming. (In fact, I usually cannot review PRs of 1000+ lines very carefully anymore.) A commit like "Convert itkMathTest to itkMathGTest" may be a candidate for a separate PR.

@hjmjohnson Very nice improvements! Thank you for following my itk::Math::Absolute renaming suggestion!

In general, please try to keep pull requests a bit smaller. 🙏 As a reviewer, I find PRs of more than a thousand lines of code a bit overwhelming. (In fact, I usually cannot review PRs of 1000+ lines very carefully anymore.) A commit like "Convert itkMathTest to itkMathGTest" may be a candidate for a separate PR.

:). That was why I kept this as a Draft and have

Depends on :

add constexpr for math operations #5798

in the PR message. Thanks for reviewing this. Once #5798 is reviewed and approved, Ill rebase and remove Draft status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:Style Style changes: no logic impact (indentation, comments, naming)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants