Figure.histogram: Let parameter 'cumulative' support Pythonic arguments - #4881
Open
seisman wants to merge 6 commits into
Open
Figure.histogram: Let parameter 'cumulative' support Pythonic arguments#4881seisman wants to merge 6 commits into
seisman wants to merge 6 commits into
Conversation
37 tasks
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new parameter insertion can break positional-call compatibility and the updated behavior needs clearer docs and test coverage.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Updates pygmt.Figure.histogram to migrate the cumulative option onto the new AliasSystem, enabling a more Pythonic long-form argument (cumulative="reverse") that maps to GMT’s reverse cumulative flag.
Changes:
- Add an explicit
cumulativeparameter toFigure.histogramand wire it intoAliasSystemviaQ=Alias(..., mapping={"reverse": "r"}). - Update the docstring alias list and
cumulativeparameter documentation to reflect the new long-form usage.
File summaries
| File | Description |
|---|---|
| pygmt/src/histogram.py | Adds cumulative as an explicit parameter and maps "reverse" to GMT’s -Qr via the alias system; updates docstring alias/docs accordingly. |
Review details
Suppressed comments (2)
pygmt/src/histogram.py:118
- The updated
cumulativedocstring no longer states how to enable cumulative mode (e.g., passingTrue) and doesn’t mention that the legacy short-form value"r"is still accepted (via the alias mapping). This can confuse users migrating from the previous behavior.
cumulative
Draw a cumulative histogram. Set it to ``"reverse"`` to draw the reverse
cumulative histogram instead.
pygmt/src/histogram.py:178
- The new long-form mapping for
cumulative(including"reverse"->"r") isn’t covered by tests. Consider adding tests that exercisecumulative=True,cumulative="reverse", and (optionally) the legacycumulative="r"to prevent regressions in the alias conversion.
G=Alias(fill, name="fill"),
Q=Alias(cumulative, name="cumulative", mapping={"reverse": "r"}),
W=Alias(pen, name="pen"),
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Migrate the parameter
cumulativeto the new alias system.Previously,
cumulativecan be eitherTrueor"r". This PR lets it support more Pythonic argument, i.e.,cumulative="reverse".For comparison, here is matplotlib's
histmethod (https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.hist.html):So, matplotlib uses
cumulative=-1for reversed cumulative histogram, but I feel it's not as readable ascumulative="reverse".Preview: https://pygmt-dev--4881.org.readthedocs.build/en/4881/api/generated/pygmt.Figure.histogram.html#pygmt.Figure.histogram