Skip to content

fix: Histogram.plot(type="cf") works for a greyscale histogram - #281

Merged
petercorke merged 1 commit into
mainfrom
bug/histogram-cf-plot-single-plane
Nov 24, 2026
Merged

petercorke merged 1 commit into
mainfrom
bug/histogram-cf-plot-single-plane

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Histogram.plot(type="cf") and type="cumulative" raised IndexError for every greyscale histogram, including im.hist().plot(type="cf"). The y-axis limit was taken as y[-1, 0], which needs a 2-D array, but a greyscale histogram's cumulative frequency is 1-D. It is now np.max(y[-1]), the pixel count of a plane, which works for both. A color histogram gets the same limits as before.

Tests: greyscale cf and cumulative have the y axis topping out at the pixel count, and so does color in the stack and overlay styles. The greyscale test fails on the old code. I ran the full suite and mypy, and both are clean.

AI-assisted: written with Claude Code.

🤖 Generated with Claude Code

The y-axis limit for the cumulative frequency plot indexed y[-1, 0], which needs
two dimensions, so every single-plane histogram raised IndexError.  It now takes
the largest of the last row, which is the pixel count of a plane in both cases.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 high

Alerts:
⚠ 1 issue (≤ 0 issues of at least minor severity)

Results:
1 new issue

Category Results
ErrorProne 1 high

View in Codacy

🟢 Metrics 12 complexity · 0 duplication

Metric Results
Complexity 12
Duplication 0

View in Codacy

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.

@petercorke
petercorke merged commit aee8333 into main Nov 24, 2026
33 of 34 checks passed
@petercorke
petercorke deleted the bug/histogram-cf-plot-single-plane branch November 24, 2026 20:52
@github-actions github-actions Bot mentioned this pull request Nov 24, 2026
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.

1 participant