Skip to content

Accept read-only input in corner_fast, corner_moravec and corner_orientations - #8424

Merged
stefanv merged 2 commits into
scikit-image:mainfrom
darskkaa:corner-readonly
Nov 21, 2026
Merged

stefanv merged 2 commits into
scikit-image:mainfrom
darskkaa:corner-readonly

Conversation

@darskkaa

Copy link
Copy Markdown
Contributor

This fixes #8418, #8419 and #8420.

corner_fast, corner_moravec and corner_orientations raised ValueError: buffer source array is read-only for read-only arrays. Their Cython kernels only read the input, so the memoryview arguments are now const, like in util/_remap.pyx. The corners argument of corner_orientations is passed straight through, so it gets const as well.

#8423 seems to list more functions with the same problem, so I chose to keep this PR to the corner kernels. No existing test covers read-only input; I can add a regression test if you'd like one.

AI use: Claude Code wrote the const change. I reviewed it, made sure read-only input works for all three functions, and ran the existing corner and ORB tests locally.

…tions

The Cython kernels only read their inputs, but non-const memoryviews
ask for a writable buffer, so read-only arrays raised
"ValueError: buffer source array is read-only".

Assisted-by: Claude Code:claude-opus-5-5
@stefanv

stefanv commented Nov 19, 2026

Copy link
Copy Markdown
Member

Thanks you for the fix, @darskkaa! Do you also want to take a stab at the others in another PR?

@darskkaa

Copy link
Copy Markdown
Contributor Author

Thanks you for the fix, @darskkaa! Do you also want to take a stab at the others in another PR?
Thanks!!!
Yes sure, i can open some follow up for the rest, in reference to #8423

stefanv pushed a commit that referenced this pull request Nov 21, 2026
Part of #8423, follow-up to #8424.

This is the same fix as #8424. Here I made the read-only inputs `const`
in the denoise, inpaint, radon and max_tree kernels, where the inpaint
mask is `const unsigned char`, since `const char` does not accept bool
arrays. I also left out `unwrap_phase`, as it involved changing the
vendored C code.

AI usage: I used Claude Code to make the `const` changes, then reviewed
them and ran some existing tests locally.
@stefanv
stefanv merged commit b1b8748 into scikit-image:main Nov 21, 2026
35 checks passed
@github-actions github-actions Bot added this to the 0.27 milestone Nov 21, 2026
eliem08 added a commit to eliem08/scikit-image that referenced this pull request Nov 24, 2026
… pass on main

Drop the 7 new read-only tests that already pass on upstream main
(scikit-image#8424/scikit-image#8426 landed the underlying fixes); only unwrap_phase and ORB
still fail there. Keeps test_unwrap_phase_read_only,
test_unwrap_phase_read_only_nan and test_orb_read_only.

Signed-off-by: Ilyass Emssaad <[email protected]>
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.

corner_moravec rejects read-only images (buffer source array is read-only) corner_fast rejects read-only images (buffer source array is read-only)

2 participants