Skip to content

BUG: Wrap types that Strain and IsotropicWavelets wrappings refer to - #7230

Merged
hjmjohnson merged 2 commits into
InsightSoftwareConsortium:mainfrom
dzenanz:wrap-strain-isotropicwavelets-types
Nov 25, 2026
Merged

hjmjohnson merged 2 commits into
InsightSoftwareConsortium:mainfrom
dzenanz:wrap-strain-isotropicwavelets-types

Conversation

@dzenanz

@dzenanz dzenanz commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

igenerator reported ITK type not wrapped for Strain and IsotropicWavelets in wheel and default builds. Both now wrap the types their wrapped methods use; complex itk::Matrix is no longer wrapped, and float StrainImageFilter is wrapped only when float Vector and CovariantVector images are.

Warnings and fixes
Module Unwrapped type Configurations Fix
Strain ImageToImageFilter<Image<Vector<double,d>,d>, Image<CovariantVector<double,d>,d>> (VectorGradientFilterType) default, wheels Wrapped unless ITKCommon already wraps that vector pair
Strain ImageToImageFilter from float images to Image<CovariantVector<float,d>,d> (GradientFilterType, VectorGradientFilterType) ITK_WRAP_covariant_vector_float=OFF Wrap float Strain only when float Vector and CovariantVector images are wrapped
IsotropicWavelets complex Vector, Point, CovariantVector used by Matrix<std::complex<T>,d,d> default, wheels Stop wrapping complex Matrix
IsotropicWavelets Array<std::complex<T>> used by complex VariableSizeMatrix default, wheels Wrap Array for the same types, plus vnl_vector<std::complex<double>> when complex double wrapping is off
IsotropicWavelets GaussianImageSource<Image<double,d>> returned by RieszStructureTensorImageFilter::GetGaussianSource() default Wrap it and its three superclasses when double wrapping is off
  • Complex Vector and Point cannot be instantiated: Normalize, GetNorm and the barycentric combinations do not compile for std::complex. No IsotropicWavelets class uses a complex Matrix, so itk.Matrix[itk.complex[...], 2|3, 2|3] is removed from Python rather than left with unusable methods.
  • SWIG runs with -Werror, so Array<std::complex<double>> needs its vnl_vector base wrapped too; ITKCommon wraps complex vnl_vector only for WRAP_ITK_COMPLEX_REAL, while VariableSizeMatrix always includes CD for RieszRotationMatrix (3cf52eb).
  • Double Vector and CovariantVector images are always wrapped, float ones only when enabled. With ITK_WRAP_vector_float=OFF, float Strain referred to undefined image types and generated invalid C++; with ITK_WRAP_covariant_vector_float=OFF, its gradient filter types were not wrapped. Float StrainImageFilter is now absent from Python in those configurations; double is always available.
Testing

Windows, CMake 4.5.1, Ninja, MSVC 14.44. Minimal builds with ITK_WRAP_PYTHON=ON:

  • ITKPath, Strain and IsotropicWavelets, together with BUG: Refresh wrapping docstrings when Doxygen reruns #7229's branch, with the default wrap types (ITK_WRAP_IMAGE_DIMS=2;3, no double) and with the wheel's types (double, complex double, dims 2;3;4): no ITK type not wrapped warning in either.
    • ctest -R "Python|Strain|Wavelet|Riesz|Path": 214 of 215 and 219 of 220 pass; PythonLazyImportTime also fails with the 6.0b3 wheels.
    • New itkRieszStructureTensorImageFilterGaussianSourcePythonTest checks that GetGaussianSource() returns a wrapped GaussianImageSource[itk.Image[itk.D, 2]], and itkArrayComplexPythonTest constructs itk.Array[itk.complex[itk.D]].
    • From Python, the Strain vector gradient filter type and itk.Array[itk.complex[itk.F]] also instantiate, and importing with itkConfig.LazyLoading = False loads all modules without duplicate-wrapping warnings.
  • Strain alone with ITK_WRAP_covariant_vector_float=OFF: before the Strain fix, the generated CastXML input held itk::ImageToImageFilter< itk::Image< itk::Vector< float,2 >,2 >, >; now the full build has no ITK type not wrapped warning and all 26 Strain tests pass.
  • Strain alone with ITK_WRAP_vector_float=OFF, configure only: only double Strain templates are generated.
  • The Strain wrapping generated for the default and wheel types is byte-identical with and without the float filter.
AI assistance

Claude Code (Opus 5.5) attributed the warnings in a wheel build log to their modules, checked which types core wrapping provides, compiled a complex Vector/Point instantiation test, wrote the changes and tests, and ran the builds above.

🤖 Generated with Claude Code

@github-actions github-actions Bot added type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots area:Python wrapping Python bindings for a class area:Filtering Issues affecting the Filtering module labels Nov 23, 2026
@dzenanz
dzenanz marked this pull request as ready for review November 23, 2026 16:50
@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5 Tier: plus

[Medium impact] The changes affect Python wrapper types in two bounded ITK modules.

Fix the Strain build failure before merging.

Findings

  1. P1 Disabled covariant wrapping breaks builds ▶
  2. P2 New bindings lack regression tests ▶

Summary

Adds missing Python bindings used by Strain and IsotropicWavelets.

  • Strain exposes its vector-gradient filter type in more Python builds.
  • IsotropicWavelets no longer exports complex matrices to Python.
  • Complex variable-size matrices now have their storage arrays in Python.
  • Riesz filters return a wrapped Gaussian source in builds without double wrappers.

Reviews (1) · Last reviewed commit: "BUG: Wrap the types that IsotropicWavele..." · Reviewed by Greptile

StrainImageFilter::VectorGradientFilterType is an ImageToImageFilter
from a Vector image to a CovariantVector image. ITKCommon wraps that
pair only for enabled vector and covariant vector types, so for double
Strain types igenerator reported it as not wrapped.

Float Strain types are now wrapped only when float Vector and
CovariantVector images are. Without them, the gradient filter types were
reported as not wrapped, or the input image type was undefined.
igenerator reported types that wrapped IsotropicWavelets methods use
but that nothing wraps:
- Matrix<std::complex> methods take complex Vector, Point and
  CovariantVector, which do not compile for complex values. No
  IsotropicWavelets class uses a complex Matrix, so it is not wrapped.
- VariableSizeMatrix<std::complex> uses Array<std::complex>, now wrapped
  along with vnl_vector<std::complex<double>> when complex double
  wrapping is off.
- RieszStructureTensorImageFilter::GetGaussianSource() returns a
  GaussianImageSource of double images, now wrapped with its
  superclasses when double wrapping is off.

Python expression tests cover GetGaussianSource() and complex Array.
@dzenanz
dzenanz force-pushed the wrap-strain-isotropicwavelets-types branch from 7b0a2dd to 7c49a35 Compare November 23, 2026 21:32
@hjmjohnson
hjmjohnson merged commit c9b71ff into InsightSoftwareConsortium:main Nov 25, 2026
19 checks passed
@dzenanz
dzenanz deleted the wrap-strain-isotropicwavelets-types branch November 25, 2026 17:52
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:Python wrapping Python bindings for a class type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants