Skip to content

Commit

Permalink
ENH: ST, IT, OT for SizeValueType, IdentifierType, OffsetType
Browse files Browse the repository at this point in the history
Runtime Python aliases corresponding to the build type aliases in
Wrapping/WrapBasicTypes.cmake.
  • Loading branch information
thewtex committed Jul 27, 2022
1 parent c273a53 commit 6a9aca9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Wrapping/Generators/Python/itk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
SI,
SLL,
B,
ST,
IT,
OT,
)


Expand Down
10 changes: 9 additions & 1 deletion Wrapping/Generators/Python/itk/support/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# ==========================================================================*/

from typing import Union, Optional, Tuple, TYPE_CHECKING
import os

try:
from numpy.typing import ArrayLike
Expand Down Expand Up @@ -114,7 +115,6 @@ def initialize_c_types_once() -> (
"""
This function is intended to be run only one time
"""
import os
import numpy as np

_F: "itkCType" = itkCType("float", "F", np.float32)
Expand Down Expand Up @@ -175,6 +175,14 @@ def initialize_c_types_once() -> (
B,
) = itkCType.initialize_c_types_once()

# Aliases for SizeValueType, IdentifierType, OffsetType
ST = UL
IT = UL
OT = SL
if os.name == "nt":
ST = ULL
IT = ULL
OT = SLL

# Type aliases to avoid expensive import, circular references. Use with forward references.
if TYPE_CHECKING:
Expand Down

0 comments on commit 6a9aca9

Please sign in to comment.