Skip to content

Update typing for Resample in extra.py - #2323

Merged
blowekamp merged 1 commit into
SimpleITK:masterfrom
chris-rapson-formus:patch-1
Jun 16, 2025
Merged

blowekamp merged 1 commit into
SimpleITK:masterfrom
chris-rapson-formus:patch-1

Conversation

@chris-rapson-formus

Copy link
Copy Markdown
Contributor

I believe the typing here should be Optional[List[int]], to match VectorUInt32_Size in the signature for ResampleImageFilter_SetSize.

My IDE has been giving me typing warnings when I provide a List[Int], but the function works as expected. int is actually incorrect:

image = sitk.GetImageFromArray(np.random.random([5, 6, 7]))
resampled_image = sitk.Resample(image, size=[2, 2, 2])  # returns a valid image
resampled_image = sitk.Resample(image, size=[2])  # error
resampled_image = sitk.Resample(image, size=2)  # error

@blowekamp
blowekamp requested review from blowekamp and zivy June 16, 2025 12:37

@blowekamp blowekamp left a comment

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.

The change looks good. Thank you for your contribution.

@blowekamp
blowekamp merged commit 95149c8 into SimpleITK:master Jun 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants