Skip to content

Histogram.plot's type docstring doesn't match its actual accepted values #39

Description

@petercorke

Found 2026-07-30 while adding type annotations to Histogram.plot
(ImageWholeFeatures.py:1200). The docstring says type accepts
'frequency' [default], 'cdf', or 'ncdf'. The actual dispatch logic
in the method body accepts a different, larger set:
'frequency', 'pdf'/'probability', 'cf'/'cumulative',
'cdf'/'normalized' — and does not handle 'ncdf' at all (it
would fall through to the else: raise ValueError("unknown type")
branch). Left type annotated as plain str rather than a Literal
enum for this reason — using Literal would mean either copying the
stale docstring's wrong values or silently fixing behavior/docs as a
drive-by, both out of scope for an annotations-only pass.

Fix

Reconcile the docstring with the real accepted values (or vice versa,
if 'ncdf' was meant to work and was dropped by accident — check git
blame). Once settled, type can become
Literal["frequency", "pdf", "probability", "cf", "cumulative", "cdf", "normalized"].

Metadata

Metadata

Assignees

No one assigned

    Labels

    tech-debtKnown technical debt / deferred cleanup, not a live bug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions