Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,21 @@ install( FILES Code.cxx CMakeLists.txt
)

enable_testing()

set( input_image ${CMAKE_CURRENT_BINARY_DIR}/cthead1.png )
set( output_image Output.mha )

add_test( NAME LaplacianRecursiveGaussianImageFilterTest
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/LaplacianRecursiveGaussianImageFilter
${CMAKE_CURRENT_BINARY_DIR}/cthead1.png
Output.mha
${input_image}
${output_image}
)

if( ITK_WRAP_PYTHON )
string( REPLACE . "Python." output_image "${output_image}" )
add_test( NAME LaplacianRecursiveGaussianImageFilterTestPython
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Code.py
${input_image}
${output_image}
)
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python

# Copyright NumFOCUS
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import itk

if len(sys.argv) != 3:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are creating many new examples, maybe you could use CreateNewExample.py (which appears in the build directory) to start new examples, so they use the argument parser from the template:

parser = argparse.ArgumentParser(description="{{ cookiecutter.example_title }}.")
parser.add_argument("input_image")
parser.add_argument("output_image")
args = parser.parse_args()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'm just adding Python versions of existing examples, but I can follow that portion of the template. I can change the remaining PRs to fit this. The example that is created seems to be missing an import for argparse. Is this indirectly imported or should I be adding an import?
I noticed that the cookie cutter example had the Python Doc after the C++. It is preferred to have the Python code show up before the C++ in the documentation correct?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change the remaining PRs

Please do! You can also update some existing examples to this style in a separate PR.

adding an import

If it is needed, yes 😄

It is preferred to have the Python code show up before the C++ in the documentation

Correct.

print("Usage: " + sys.argv[0] + " <InputFileName> <OutputFileName>")
sys.exit(1)

image = itk.imread(sys.argv[1], pixel_type=itk.F)

image = itk.laplacian_recursive_gaussian_image_filter(image)

itk.imwrite(image, sys.argv[2])
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ Results
Code
----

Python
......

.. literalinclude:: Code.py
:language: python
:lines: 1, 16-

C++
...

Expand Down