Repository navigation
fix: Image[...] with a list of planes raises, and a plane index works on a greyscale image - #309
Open
petercorke wants to merge 3 commits into
Open
petercorke wants to merge 3 commits into
petercorke wants to merge 3 commits into
Conversation
… on a greyscale image img[[0, 2]] returned a 1x1 image, because a list was read as a pair of keys. It now raises ValueError and points to plane(). An int key goes through plane(), so a greyscale image accepts img[0] and an out-of-range index raises ValueError, not NumPy's IndexError. NumPy integers are accepted, a negative index still counts from the last plane, and True and False are refused. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 20 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This branch has not been deployed
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.
Problems found while documenting
Image.__getitem__:img[[0, 2]]returned a 1x1 image with no error, because a list was read as the pair of keys(0, 2). It now raisesValueErrorand points toplane().g[0]gave "bad ndarray passed to Image constructor"). An int key now goes throughplane(), sog[0]returns the image.IndexError; it now raisesValueError, asplane()does.np.int64(1)are accepted.TrueandFalseare refused, not read as planes 1 and 0.img[-1]works as before.Behavior change to be aware of:
img[[0, 2]]and an out-of-rangeimg[5]now raiseValueError. The first used to give a wrong answer.Nine new tests in
tests/test_image_core.py. The full suite passes (2418 passed, 17 skipped) and mypy is clean.An AI assistant (Claude Code) wrote this change.
🤖 Generated with Claude Code