Skip to content

Commit fdc5b4a

Browse files
authored
Merge pull request InsightSoftwareConsortium#5752 from InsightSoftwareConsortium/remove-long-double-support
COMP: Remove undefined long double swig wrapping
2 parents e7b45a5 + 0fb11a2 commit fdc5b4a

File tree

10 files changed

+22
-19
lines changed

10 files changed

+22
-19
lines changed

Documentation/docs/migration_guides/itk_6_migration_guide.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,22 @@ reoriented_image = itk.orient_image_filter(
171171
),
172172
)
173173
```
174+
175+
Remove support for Python wrapped `long double` types
176+
-----------------------------------------------------
177+
178+
The swig wrapping of `long double` types into python
179+
resulted in implicit type conversions to `double`,
180+
which results in silent loss of precision.
181+
182+
There has never been an option for "ITK_WRAP_long_double"
183+
configuration, and manually wrapped functions in vnl for
184+
for long double were never needed by ITK based functions.
185+
186+
Given the undefined behavior of wrapping long double types
187+
with swig, and given that there is no use case for long double
188+
support directly from the wrapped ITK API, these manual vnl
189+
wrappings could not be reached from ITK interfaces.
190+
191+
The handful of manually wrapped long double functions were
192+
removed from python wrapping.

Modules/Core/Common/wrapping/itkNumericTraits.wrap

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ foreach(
3030
SL
3131
F
3232
D
33-
LD
3433
B)
3534
itk_wrap_template("${ITKM_${t}}" "${ITKT_${t}}")
3635
endforeach()
@@ -51,7 +50,6 @@ foreach(
5150
SL
5251
F
5352
D
54-
LD
5553
B)
5654
itk_wrap_template("${ITKM_${t}}" "${ITKT_${t}}")
5755
endforeach()

Modules/Core/Common/wrapping/vnl_c_vector.wrap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ itk_wrap_template("${ITKM_F}" "${ITKT_F}")
1010
itk_wrap_template("${ITKM_SI}" "${ITKT_SI}")
1111
itk_wrap_template("${ITKM_SL}" "${ITKT_SL}")
1212
itk_wrap_template("${ITKM_SLL}" "${ITKT_SLL}")
13-
itk_wrap_template("${ITKM_LD}" "${ITKT_LD}")
1413
itk_wrap_template("${ITKM_SC}" "${ITKT_SC}")
1514
itk_wrap_template("${ITKM_UC}" "un${ITKT_SC}")
1615
itk_wrap_template("${ITKM_UI}" "un${ITKT_SI}")

Modules/Core/Common/wrapping/vnl_diag_matrix.wrap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ itk_wrap_class("vnl_diag_matrix" EXPLICIT_SPECIALIZATION)
88
itk_wrap_template("${ITKM_D}" "${ITKT_D}")
99
itk_wrap_template("${ITKM_F}" "${ITKT_F}")
1010
itk_wrap_template("${ITKM_SI}" "${ITKT_SI}")
11-
itk_wrap_template("${ITKM_LD}" "${ITKT_LD}")
1211
foreach(t ${WRAP_ITK_COMPLEX_REAL})
1312
itk_wrap_template("${ITKM_${t}}" "${ITKT_${t}}")
1413
endforeach()

Modules/Core/Common/wrapping/vnl_matrix.wrap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ itk_wrap_template("${ITKM_F}" "${ITKT_F}")
1111
itk_wrap_template("${ITKM_SI}" "${ITKT_SI}")
1212
itk_wrap_template("${ITKM_SL}" "${ITKT_SL}")
1313
itk_wrap_template("${ITKM_SLL}" "${ITKT_SLL}")
14-
itk_wrap_template("${ITKM_LD}" "${ITKT_LD}")
1514
itk_wrap_template("${ITKM_SC}" "${ITKT_SC}")
1615
itk_wrap_template("${ITKM_UC}" "un${ITKT_SC}")
1716
itk_wrap_template("${ITKM_UI}" "un${ITKT_SI}")

Modules/Core/Common/wrapping/vnl_vector.wrap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ itk_wrap_include("vnl/vnl_matrix.h")
66
itk_wrap_include("vnl/vnl_vector.h")
77

88
itk_wrap_class("vnl_vector" EXPLICIT_SPECIALIZATION)
9-
unique(vector_types "D;F;SI;SL;SLL;LD;SC;UC;US;UI;UL;ULL;${ITKM_IT};${ITKM_OT};${WRAP_ITK_SCALAR}")
9+
unique(vector_types "D;F;SI;SL;SLL;SC;UC;US;UI;UL;ULL;${ITKM_IT};${ITKM_OT};${WRAP_ITK_SCALAR}")
1010
foreach(t ${vector_types})
1111
itk_wrap_template("${ITKM_${t}}" "${ITKT_${t}}")
1212
endforeach()

Modules/Core/Common/wrapping/vnl_vector_ref.wrap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(WRAPPER_AUTO_INCLUDE_HEADERS OFF)
44
itk_wrap_include("vnl/vnl_vector_ref.h")
55

66
itk_wrap_class("vnl_vector_ref" EXPLICIT_SPECIALIZATION)
7-
unique(vector_types "D;F;SI;SL;SLL;LD;SC;UC;US;UI;UL;ULL;${WRAP_ITK_SCALAR}")
7+
unique(vector_types "D;F;SI;SL;SLL;SC;UC;US;UI;UL;ULL;${WRAP_ITK_SCALAR}")
88
foreach(t ${vector_types})
99
itk_wrap_template("${ITKM_${t}}" "${ITKT_${t}}")
1010
endforeach()

Wrapping/Generators/Python/itk/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
UI,
3737
UL,
3838
SL,
39-
LD,
4039
ULL,
4140
SC,
4241
SS,

Wrapping/Generators/Python/itk/support/types.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,21 +127,16 @@ def initialize_c_types_once() -> (
127127
if os.name == "nt":
128128
_UL: "itkCType" = itkCType("unsigned long", "UL", np.dtype(np.uint32))
129129
_SL: "itkCType" = itkCType("signed long", "SL", np.dtype(np.int32))
130-
_LD: "itkCType" = itkCType("long double", "LD")
131130
else:
132131
_UL: "itkCType" = itkCType("unsigned long", "UL", np.dtype(np.uint64))
133132
_SL: "itkCType" = itkCType("signed long", "SL", np.dtype(np.int64))
134-
if hasattr(np, "float128"):
135-
_LD: "itkCType" = itkCType("long double", "LD", np.dtype(np.float128))
136-
else:
137-
_LD: "itkCType" = itkCType("long double", "LD")
138133
_ULL: "itkCType" = itkCType("unsigned long long", "ULL", np.dtype(np.uint64))
139134
_SC: "itkCType" = itkCType("signed char", "SC", np.dtype(np.int8))
140135
_SS: "itkCType" = itkCType("signed short", "SS", np.dtype(np.int16))
141136
_SI: "itkCType" = itkCType("signed int", "SI", np.dtype(np.int32))
142137
_SLL: "itkCType" = itkCType("signed long long", "SLL", np.dtype(np.int64))
143138
_B: "itkCType" = itkCType("bool", "B", np.dtype(np.bool_))
144-
return _F, _D, _UC, _US, _UI, _UL, _SL, _LD, _ULL, _SC, _SS, _SI, _SLL, _B
139+
return _F, _D, _UC, _US, _UI, _UL, _SL, _ULL, _SC, _SS, _SI, _SLL, _B
145140

146141

147142
# Define typing hints
@@ -152,7 +147,6 @@ def initialize_c_types_once() -> (
152147
UI: itkCType
153148
UL: itkCType
154149
SL: itkCType
155-
LD: itkCType
156150
ULL: itkCType
157151
SC: itkCType
158152
SS: itkCType
@@ -168,7 +162,6 @@ def initialize_c_types_once() -> (
168162
UI,
169163
UL,
170164
SL,
171-
LD,
172165
ULL,
173166
SC,
174167
SS,

Wrapping/WrapBasicTypes.cmake

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ set(ITKM_F "F") # Mangle
3939
set(ITKT_D "double") # Type
4040
set(ITKM_D "D") # Mangle
4141

42-
set(ITKT_LD "long double") # Type
43-
set(ITKM_LD "LD") # Mangle
44-
4542
set(ITKT_B "bool") # Type
4643
set(ITKM_B "B") # Mangle
4744

0 commit comments

Comments
 (0)