STYLE: Use itk.IT as IdentifierType in MeshArrayPixelTypeTest - #6769
Conversation
| IdentifierType = itk.IT | ||
|
|
||
| v = itk.VectorContainer[IdentifierType, PixelType].New() |
There was a problem hiding this comment.
Instead of introducing this IdentifierType alias, we might as well directly use itk.IT, as in:
v = itk.VectorContainer[itk.IT, PixelType].New()But I guess IdentifierType is more readable than itk.IT 🤷
|
| IdentifierType = itk.UL | ||
| else: | ||
| IdentifierType = itk.ULL | ||
| IdentifierType = itk.IT |
There was a problem hiding this comment.
Windows identifier types diverge
itk.IT is always exported as itk.ULL on Windows, but a build with ITK_USE_64BITS_IDS=OFF defines itk::IdentifierType as unsigned long and wraps this mesh's point-data container with an itk.UL key. This creates VectorContainer[ULL, Array.D], which does not match the VectorContainer[UL, Array.D] required by mesh.SetPointData(v), so this wrapping test fails on that supported configuration. Restore the configuration-aware UL/ULL container selection, or make itk.IT reflect the configured identifier width.
Artifacts
Focused Mesh IdentifierType selection validation script
- Authored and executed a focused Python source-contract validation for Windows with 64-bit IDs disabled; it asserts the exact C++, wrapping, Python-alias, and changed-test selection facts, with the takeaway that the selected container key types differ.
Focused validation output showing the post-change Mesh key-type mismatch
- Captured output from executing the focused validation script in `/home/user/repo`; it reports `unsigned long` for the mesh and `unsigned long long` for `itk.IT`, with the takeaway that post-change `SetPointData` container types do not match.
|
Hmmm, greptile does not like it. The definition of I don't really understand the original |
itk.IT as IdentifierType in MeshArrayPixelTypeTestitk.IT as IdentifierType in MeshArrayPixelTypeTest
Check size of |
|
Doing some AI assisted searching. |
|
Mesh already knows its own MeshType = itk.Mesh[PixelType, Dimension]
mesh = MeshType.New()
IdentifierType = itk.template(mesh.GetPointData())[1][0]
v = itk.VectorContainer[IdentifierType, PixelType].New()
Separately: Why
|
|
Thanks @hjmjohnson Instead of fixing Specifically for In practice it is rarely useful (if at all) to have multiple different index types (also known as "element identifier types") for What do you think? Anyway, I think we can abandon this PR without merging, no problem 🤷 |
|
I like Hans' AI solution. It can be done in another PR. Your last proposal can build on top of that. |
|
Correction to my comment above: the ST = uint64_t
IT = uint64_t
OT = int64_tThe conclusion is unchanged, and arguably sharper: I've opened #6772 for that, which resolves |
Note: This commit depends on `itk.IT` being properly defined as alias for IdentifierType. The definition of `itk.IT` was just fixed, by pull request InsightSoftwareConsortium#6772 commit 616eb27 "COMP: Resolve Python ST/IT/OT from the wrapped C types" Follow-up to pull request InsightSoftwareConsortium#2970 commit 7e59d1b "COMP: Use itk.ULL for windows" by Pranjal Sahu, merged on 17 Dec 2021
e0ddd0c to
fc5f03c
Compare
itk.IT as IdentifierType in MeshArrayPixelTypeTestitk.IT as IdentifierType in MeshArrayPixelTypeTest
fee22c1
into
InsightSoftwareConsortium:main
itk.ITis defined as platform-independent alias for IdentifierType.