Skip to content

STYLE: Remove ITK version guards from Python examples - #484

Draft
hjmjohnson wants to merge 1 commit into
InsightSoftwareConsortium:mainfrom
hjmjohnson:style-remove-itk-version-guards
Draft

hjmjohnson wants to merge 1 commit into
InsightSoftwareConsortium:mainfrom
hjmjohnson:style-remove-itk-version-guards

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

Remove the ITK version guards from ten Python examples. Examples require ITK 6,
so checks for ITK 4.7 through 5.2 can never fail.

What changes

Each example began with a check like:

if tuple(int(v) for v in itk.Version.GetITKVersion().split(".")) < (4, 9, 0):
    print("ITK 4.9.0 is required.")
    sys.exit(1)

The guard is removed, and so is import sys, which in every one of these files
was used only by the guard. 10 files, 40 lines deleted, nothing added.

Verification

Against ITK main with Python wrapping, all ten edited scripts import and run.

Five of the examples have Python tests that run in the full build, and all pass:
AddOffsetToIndex, StreamAPipeline, CreateACustomColormap,
SegmentBloodVessels, and SegmentBloodVesselsWithMultiScaleHessianBasedMeasure.

The other five are not exercised by ctest, for reasons unrelated to this change:

examples why no Python test runs
ConvertAnitkImageTovtkImageData, ConvertAnRGBitkImageTovtkImageData no Python test is registered
ApplyGradientRecursiveGaussian, ApplyGradientRecursiveGaussianWithVectorInput ImageGradient is in Filtering_MODULES_IGNORED ("TODO: Fix ImageGradient examples and re-enable")
Perform2DTranslationRegistrationWithMeanSquares gated behind ITKV4_COMPATIBILITY

pre-commit run --all-files passes.

The examples require ITK 6, so checks for ITK 4.7 through 5.2 can never
fail. Drop them, along with the sys import they alone used.
@github-actions github-actions Bot added area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:Registration Issues affecting the Registration module type:Style Style changes: no logic impact (indentation, comments, naming) area:Bridge Issues affecting the Bridge module area:Nonunit Issues affecting the Nonunit module language:Python Changes to Python examples labels Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Bridge Issues affecting the Bridge module area:Core Issues affecting the Core module area:Filtering Issues affecting the Filtering module area:Nonunit Issues affecting the Nonunit module area:Registration Issues affecting the Registration module language:Python Changes to Python examples 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