fix: Histogram.plot(type='ncdf') never actually worked, docstring lied - #85
Open
petercorke wants to merge 4 commits into
Open
fix: Histogram.plot(type='ncdf') never actually worked, docstring lied#85petercorke wants to merge 4 commits into
petercorke wants to merge 4 commits into
Conversation
plot()'s docstring claimed 'ncdf' was an accepted type value, but the
dispatch logic in _compute_plot_series() only ever handled
'frequency', 'pdf'/'probability', 'cf'/'cumulative', 'cdf'/
'normalized' -- 'ncdf' always fell through to
raise ValueError("unknown type"). Filed as tech-debt issue #39.
Resolution: 'ncdf' (normalized CDF) is what 'cdf'/'normalized'
already means today -- a real CDF is normalized by definition, so the
naming was simplified rather than the option being dropped by
accident. This matches the existing Histogram.ncdf *property*, which
is already a deprecated alias for .cdf with the same pattern.
Added 'ncdf' as a matching deprecated string alias for
type='cdf' in plot(), warning and normalizing before dispatch (same
DeprecationWarning + stacklevel=2 pattern already used for plot()'s
bar= parameter, right above it). Also fixed the docstring (both the
:param: line and the prose) to list the real accepted values, and
changed type's annotation from plain str to a Literal enumerating
them, per the tech-debt issue's own suggested resolution.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| 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 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.
Summary
Resolves #39.
plot()'s docstring claimed'ncdf'was an acceptedtypevalue, but the dispatch logic in_compute_plot_series()only ever handled'frequency','pdf'/'probability','cf'/'cumulative','cdf'/'normalized'--'ncdf'always fell through toraise ValueError("unknown type").'ncdf'(normalized CDF) is what'cdf'/'normalized'already means today -- a real CDF is normalized by definition, so the naming was simplified rather than the option being dropped by accident. This matches the existingHistogram.ncdfproperty, which is already a deprecated alias for.cdfwith the identical pattern.'ncdf'as a matching deprecated string alias fortype='cdf'inplot(), warning and normalizing before dispatch (sameDeprecationWarning+stacklevel=2pattern already used forplot()'sbar=parameter, right above it in the same method).:param:line and the prose) to list the real accepted values.type's annotation from plainstrto aLiteralenumerating the real values (including'ncdf'as a still-valid deprecated input) -- the exact resolution Histogram.plot's type docstring doesn't match its actual accepted values #39 itself suggested once the docstring/behavior mismatch was settled.Found while working through RVC3-python's chap11.ipynb, which calls
h.plot("ncdf", color="blue")per the printed book.Test plan
type='ncdf'warns (DeprecationWarning) and produces the same plot astype='cdf'; fails against pre-fix code with the originalValueError: unknown typetests/test_image_whole_features.pysuite passes (39 passed)