Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/build-test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,43 @@ jobs:
itk-module-deps: RTKConsortium/RTK@main
secrets:
pypi_password: ${{ secrets.pypi_password }}

test-python-wheel:
needs:
- python-build-workflow
runs-on: self-hosted-linux

steps:
- uses: actions/checkout@v4

- name: Download all wheel artifacts
uses: actions/download-artifact@v4
with:
path: wheels

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Test python wheel
run: |
# Find wheel for Python 3.11 dynamically
wheel=$(find wheels -name "*cp311*manylinux_2_28_x86_64.whl" -type f | head -1)

pip uninstall -y $(pip list | grep -E '^itk-') || true
echo "Installing wheel: $wheel"
pip install $wheel

pip install pytest matplotlib

# Run tests with warning detection.
# SWIG < 4.4 triggers the Py_LIMITED_API "builtin type swig…" warning when
# Python runs with -Walways; pytest enables that behavior, so we ignore it.
stderr_log=$(mktemp)
pytest $GITHUB_WORKSPACE/test/*.py -vv -s -W "ignore:builtin type swig" 2> "$stderr_log"
if grep -q "Warning" "$stderr_log"; then
echo "Warnings found in stderr, failing the build"
cat "$stderr_log"
exit 1
fi
4 changes: 3 additions & 1 deletion applications/pctfdk/pctfdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ def process(args_info: argparse.Namespace):
geometryReader.GenerateOutputInformation()

# Short scan image filter
pssf = pct.DDParkerShortScanImageFilter[ProjectionImageType].New()
pssf = pct.DDParkerShortScanImageFilter[
ProjectionImageType, ProjectionImageType
].New()
pssf.SetInput(reader.GetOutput())
pssf.SetGeometry(geometryReader.GetOutputObject())
pssf.InPlaceOff()
Expand Down
1 change: 0 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ itk_add_test(NAME pctProtonPairsToDistanceDrivenProjectionTest
if(ITK_WRAP_PYTHON)
itk_python_add_test(NAME pctPythonWrappingInstantiationTest COMMAND pctPythonWrappingInstantiationTest.py)
itk_python_add_test(NAME pctOutputArgumentWrappingTest COMMAND pctOutputArgumentWrapping.py)
itk_python_add_test(NAME pctPairProtonsTest COMMAND pctPairProtonsTest.py)
endif()

#-----------------------------------------------------------------------------
Expand Down
19 changes: 11 additions & 8 deletions test/pctOutputArgumentWrapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

from itk import PCT as pct

pos_in = [25.0, -25.0, -110.0]
pos_out = [-25.0, 25.0, 110.0]
dir_in = [0.0, 0.0, 1.0]
dir_out = [0.0, 0.0, 1.0]

mlp = pct.PolynomialMLPFunction.New()
mlp.SetPolynomialDegree(2)
mlp.Init(pos_in, pos_out, dir_in, dir_out)
def test_output_argument_wrapping():
pos_in = [25.0, -25.0, -110.0]
pos_out = [-25.0, 25.0, 110.0]
dir_in = [0.0, 0.0, 1.0]
dir_out = [0.0, 0.0, 1.0]

print(mlp.Evaluate([-50.0, 0.0, 50.0]))
mlp = pct.PolynomialMLPFunction.New()
mlp.SetPolynomialDegree(2)
mlp.Init(pos_in, pos_out, dir_in, dir_out)

result = mlp.Evaluate([-50.0, 0.0, 50.0])
print(result)
26 changes: 0 additions & 26 deletions test/pctPairProtonsTest.py

This file was deleted.

42 changes: 22 additions & 20 deletions test/pctPythonWrappingInstantiationTest.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
import itk
from itk import PCT as pct

imageType = itk.Image[itk.F, 3]
pct.FDKDDWeightProjectionFilter[imageType].New()
pct.FDKDDConeBeamReconstructionFilter[imageType].New()
pct.FDKDDBackProjectionImageFilter[imageType, imageType].New()
pct.ProtonPairsToDistanceDrivenProjection[imageType, imageType].New()
pct.SmallHoleFiller[imageType]()

imageType = itk.Image[itk.F, 4]
pct.DDParkerShortScanImageFilter[imageType, imageType].New()
pct.ProtonPairsToBackProjection[imageType, imageType].New()
pct.ZengWeightedBackProjectionImageFilter[imageType].New()
pct.SmallHoleFiller[imageType]()
def test_python_wrapping_instantiation():
imageType = itk.Image[itk.F, 3]
pct.FDKDDWeightProjectionFilter[imageType].New()
pct.FDKDDConeBeamReconstructionFilter[imageType].New()
pct.FDKDDBackProjectionImageFilter[imageType, imageType].New()
pct.ProtonPairsToDistanceDrivenProjection[imageType, imageType].New()
pct.SmallHoleFiller[imageType]()

pct.ThirdOrderPolynomialMLPFunction[itk.D].New()
pct.ThirdOrderPolynomialMLPFunction[itk.F].New()
imageType = itk.Image[itk.F, 4]
pct.DDParkerShortScanImageFilter[imageType, imageType].New()
pct.ProtonPairsToBackProjection[imageType, imageType].New()
pct.ZengWeightedBackProjectionImageFilter[imageType].New()
pct.SmallHoleFiller[imageType]()

pct.SchulteMLPFunction.New()
pct.PolynomialMLPFunction.New()
pct.ThirdOrderPolynomialMLPFunction[itk.D].New()
pct.ThirdOrderPolynomialMLPFunction[itk.F].New()

for t1 in [itk.F, itk.D]:
for t2 in [itk.F, itk.D]:
pct.EnergyStragglingFunctor[t1, t2]()
pct.BetheBlochProtonStoppingPower[t1, t2]()
pct.IntegratedBetheBlochProtonStoppingPowerInverse[t1, t2](1, 1)
pct.SchulteMLPFunction.New()
pct.PolynomialMLPFunction.New()

for t1 in [itk.F, itk.D]:
for t2 in [itk.F, itk.D]:
pct.EnergyStragglingFunctor[t1, t2]()
pct.BetheBlochProtonStoppingPower[t1, t2]()
pct.IntegratedBetheBlochProtonStoppingPowerInverse[t1, t2](1, 1)
2 changes: 1 addition & 1 deletion wrapping/pctDDParkerShortScanImageFilter.wrap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
itk_wrap_class("pct::DDParkerShortScanImageFilter" POINTER)
foreach(t ${WRAP_ITK_REAL})
itk_wrap_template("I${ITKM_${t}}4" "itk::Image<${ITKT_${t}}, 4>")
itk_wrap_template("I${ITKM_${t}}4I${ITKM_${t}}4" "itk::Image<${ITKT_${t}}, 4>, itk::Image<${ITKT_${t}}, 4>")
endforeach()
itk_end_wrap_class()
Loading