Repository navigation
Add PyBuffer interface to Image (PEP 688) and numpy array conversion - #2447
Merged
Merged
Conversation
blowekamp
requested review from
dave3d and
zivy
and removed request for
zivy
November 19, 2025 19:36
Member
Author
|
@dave3d Is there a way to tell the spell checker to ignore a whole file? In the pre-commit config or else where? |
Member
You could disable spell checking within the file by putting in the comment: "// spell-check-disable" https://github.com/SimpleITK/CommentSpellCheck?tab=readme-ov-file#disabling-spell-checking or maybe adding the file name to the "exclude" line in the YAML file. |
blowekamp
force-pushed
the
add_pybuffer_image_buffer
branch
4 times, most recently
from
November 20, 2025 16:35
d8184b5 to
0db7604
Compare
zivy
approved these changes
Nov 20, 2025
zivy
left a comment
Member
There was a problem hiding this comment.
So Pythonic and makes the usage of views safer for users. Very nice work!
Some trivial spelling that can be ignored.
blowekamp
marked this pull request as ready for review
November 20, 2025 17:28
The ImageBuffer class maintains a reference the the python Image instance, which solves the dangling pointer for memory buffers with the prior _GetMemoryViewFromImage method.
Allow for implicit view as numpy arrays as read-only buffers which maintain a reference to the Python Image object. Implement PEP 688 for Python >= 3.12, by adding the __buffer__ method.
Useful functions to determine the class of pixel type. This is current in a private module and may be implemented C++ in the future. fix up for pixel types
The function was private and can be removed without deprecation.
blowekamp
force-pushed
the
add_pybuffer_image_buffer
branch
from
November 20, 2025 18:55
0db7604 to
2b99ad4
Compare
6 of 7 tasks
This was referenced Aug 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enables view and conversions to numpy arrays with the following:
References to the Python Image object are maintained.
COMPATIBILITY:
Images of vector pixel type with only 1 component now return memory views and arrays of n+1 dimensions. ( Previously the 1 size component dimension was dropped )