Skip to content

Commit

Permalink
ENH: ttype can be ImageType whenever (ImageType,) is accepted
Browse files Browse the repository at this point in the history
  • Loading branch information
Leengit authored and hjmjohnson committed Dec 5, 2020
1 parent 8a89d1f commit 5741f87
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Wrapping/Generators/Python/itk/support/itkTemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,14 @@ def ttype_for_input_type(keys_l, input_type_l):
# Note that the function `itk.template()` which returns the template
# arguments of an object returns tuples and its returned value
# should be usable in this context.
# However, it is easy for a user to pass a list (e.g. [ImageType, ImageType]) and
# this needs to work too.
ttype = tuple(kwargs.pop("ttype"))
# However, it is easy for a user to pass a list (e.g. [ImageType, ImageType]) or
# a type (e.g., ImageType), and these need to work too.
ttype = kwargs.pop("ttype")
if not isinstance(ttype, tuple):
if isinstance(ttype, list):
ttype = tuple(ttype)
else:
ttype = (ttype,)
# If there is not the correct number of template parameters, throw an error.
if len(ttype) != len(list(keys)[0]):
raise RuntimeError(
Expand Down

0 comments on commit 5741f87

Please sign in to comment.