-
-
Notifications
You must be signed in to change notification settings - Fork 671
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG: Specify itk package in SWIG Python modules
This consistently sets the __package__ for `itk` package modules and functions. This addresses Windows import failures. Swig's c-module import statements changed with Swig 4.0. For the new syntax, __package__ must be set and consistent on the imported modules. To simplify things, Linux and macOS are also updated to Swig 4.0. itk.FloatingPointExceptions, itk.AdaptiveHistogramEqualizationImageFilter is disabled because it on macOs, Linux with Swig 4.0.1. The library outputs in the build tree are changed to be consistent with the package layout. We use the standard API for ImageDuplicator invocation in the NumPy bridge. For the embedded submodules on the C side, we update the module name to include `itk.` We also use a single PyImport_GetModuleDict statement for simplicity and performance. For imports of submodules in Python, we now use the full path. The "swig" attribute is now a dict used as a namespace instead of a types.ModuleType. Overriding the `.New()` is moved from pyBase.i to igenerator.py. It is only added to classes that define a .New() and have .AddObserver(), i.e. not abstract base classes. itk.PyCommand is excluded to prevent .AddObserver recursion that blows the stack. The lazy module creation uses Python 3.5 tooling to create a module with __package__ set and load it lazily. i.e. importlib.util.spec_from_file_location importlib.util.module_from_spec module.__loader__.exec_module Loaded modules now have the package path in their name.
- Loading branch information
Showing
16 changed files
with
197 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,8 +125,8 @@ | |
imageView = itkPyBuffer@[email protected](ndarr, is_vector) | ||
|
||
# Duplicate the image to let it manage its own memory buffer | ||
duplicator = itkImageDuplicator@[email protected]() | ||
duplicator.SetInputImage(imageView) | ||
import itk | ||
duplicator = itk.ImageDuplicator.New(imageView) | ||
duplicator.Update() | ||
return duplicator.GetOutput() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) | ||
itk_wrap_include("itkFloatingPointExceptions.h") | ||
itk_wrap_simple_class("itk::FloatingPointExceptions") | ||
itk_wrap_simple_class("itk::FloatingPointExceptionsEnums") | ||
#itk_wrap_simple_class("itk::FloatingPointExceptions") | ||
#itk_wrap_simple_class("itk::FloatingPointExceptionsEnums") |
64 changes: 32 additions & 32 deletions
64
Modules/Filtering/ImageStatistics/wrapping/itkAdaptiveHistogramEqualizationImageFilter.wrap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
itk_wrap_class("itk::KernelImageFilter" POINTER) | ||
foreach(t ${WRAP_ITK_SCALAR}) | ||
foreach(d ${ITK_WRAP_IMAGE_DIMS}) | ||
itk_wrap_template("${ITKM_I${t}${d}}${ITKM_I${t}${d}}Neighborhood" "${ITKT_I${t}${d}}, ${ITKT_I${t}${d}}, itk::Neighborhood< bool, ${d} >") | ||
endforeach() | ||
endforeach() | ||
itk_end_wrap_class() | ||
#itk_wrap_class("itk::KernelImageFilter" POINTER) | ||
#foreach(t ${WRAP_ITK_SCALAR}) | ||
#foreach(d ${ITK_WRAP_IMAGE_DIMS}) | ||
#itk_wrap_template("${ITKM_I${t}${d}}${ITKM_I${t}${d}}Neighborhood" "${ITKT_I${t}${d}}, ${ITKT_I${t}${d}}, itk::Neighborhood< bool, ${d} >") | ||
#endforeach() | ||
#endforeach() | ||
#itk_end_wrap_class() | ||
|
||
itk_wrap_class("itk::MovingHistogramImageFilterBase" POINTER) | ||
foreach(t ${WRAP_ITK_SCALAR}) | ||
foreach(d ${ITK_WRAP_IMAGE_DIMS}) | ||
itk_wrap_template("${ITKM_I${t}${d}}${ITKM_I${t}${d}}Neighborhood" "${ITKT_I${t}${d}}, ${ITKT_I${t}${d}}, itk::Neighborhood< bool, ${d} >") | ||
endforeach() | ||
endforeach() | ||
itk_end_wrap_class() | ||
#itk_wrap_class("itk::MovingHistogramImageFilterBase" POINTER) | ||
#foreach(t ${WRAP_ITK_SCALAR}) | ||
#foreach(d ${ITK_WRAP_IMAGE_DIMS}) | ||
#itk_wrap_template("${ITKM_I${t}${d}}${ITKM_I${t}${d}}Neighborhood" "${ITKT_I${t}${d}}, ${ITKT_I${t}${d}}, itk::Neighborhood< bool, ${d} >") | ||
#endforeach() | ||
#endforeach() | ||
#itk_end_wrap_class() | ||
|
||
set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) | ||
itk_wrap_include("itkAdaptiveEqualizationHistogram.h") | ||
itk_wrap_class("itk::Function::AdaptiveEqualizationHistogram") | ||
foreach(t ${WRAP_ITK_SCALAR}) | ||
itk_wrap_template("${ITKM_${t}}${ITKM_${t}}" "${ITKT_${t}}, ${ITKT_${t}}") | ||
endforeach() | ||
itk_end_wrap_class() | ||
set(WRAPPER_AUTO_INCLUDE_HEADERS ON) | ||
#set(WRAPPER_AUTO_INCLUDE_HEADERS OFF) | ||
#itk_wrap_include("itkAdaptiveEqualizationHistogram.h") | ||
#itk_wrap_class("itk::Function::AdaptiveEqualizationHistogram") | ||
#foreach(t ${WRAP_ITK_SCALAR}) | ||
#itk_wrap_template("${ITKM_${t}}${ITKM_${t}}" "${ITKT_${t}}, ${ITKT_${t}}") | ||
#endforeach() | ||
#itk_end_wrap_class() | ||
#set(WRAPPER_AUTO_INCLUDE_HEADERS ON) | ||
|
||
itk_wrap_class("itk::MovingHistogramImageFilter" POINTER) | ||
foreach(t ${WRAP_ITK_SCALAR}) | ||
foreach(d ${ITK_WRAP_IMAGE_DIMS}) | ||
itk_wrap_template("${ITKM_I${t}${d}}${ITKM_I${t}${d}}NeighborhoodAHE" "${ITKT_I${t}${d}}, ${ITKT_I${t}${d}}, itk::Neighborhood< bool, ${d} >, itk::Function::AdaptiveEqualizationHistogram< ${ITKT_${t}}, ${ITKT_${t}} >") | ||
endforeach() | ||
endforeach() | ||
itk_end_wrap_class() | ||
#itk_wrap_class("itk::MovingHistogramImageFilter" POINTER) | ||
#foreach(t ${WRAP_ITK_SCALAR}) | ||
#foreach(d ${ITK_WRAP_IMAGE_DIMS}) | ||
#itk_wrap_template("${ITKM_I${t}${d}}${ITKM_I${t}${d}}NeighborhoodAHE" "${ITKT_I${t}${d}}, ${ITKT_I${t}${d}}, itk::Neighborhood< bool, ${d} >, itk::Function::AdaptiveEqualizationHistogram< ${ITKT_${t}}, ${ITKT_${t}} >") | ||
#endforeach() | ||
#endforeach() | ||
#itk_end_wrap_class() | ||
|
||
itk_wrap_class("itk::AdaptiveHistogramEqualizationImageFilter" POINTER) | ||
itk_wrap_image_filter("${WRAP_ITK_SCALAR}" 1) | ||
itk_end_wrap_class() | ||
#itk_wrap_class("itk::AdaptiveHistogramEqualizationImageFilter" POINTER) | ||
#itk_wrap_image_filter("${WRAP_ITK_SCALAR}" 1) | ||
#itk_end_wrap_class() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.