Skip to content

pygmt.binstats: Let the parameter 'statistic' support descriptive arguments - #3012

Merged
seisman merged 8 commits into
mainfrom
binstats/statistic
Aug 10, 2025
Merged

pygmt.binstats: Let the parameter 'statistic' support descriptive arguments#3012
seisman merged 8 commits into
mainfrom
binstats/statistic

Conversation

@seisman

@seismanseisman commented Jan 17, 2024

Copy link
Copy Markdown
Member

Description of proposed changes

Refactor using the new alias system to make the parameter statistic support long-form arguments like statistic="mean" instead of statistic="a".

Upstream documentation at https://docs.generic-mapping-tools.org/dev/gmtbinstats.html

Long-form arguments come from https://github.com/GenericMappingTools/gmt/blob/0ae77bb0ae34d6dcb331156d7ee17a747ba83c57/src/longopt/gmtbinstats_inc.h#L29

Preview: https://pygmt-dev--3012.org.readthedocs.build/en/3012/api/generated/pygmt.binstats.html

Address #1651.

@seisman
seismanforce-pushed the binstats/statistic branch 2 times, most recently from de6ffcc to 464b170CompareSeptember 29, 2024 09:27
@seismanseisman self-assigned this Oct 30, 2024
@seisman
seismanforce-pushed the binstats/statistic branch from d1bc357 to 628e69eCompareJuly 23, 2025 06:53
@seisman
seisman changed the base branch from main to AliasSystem/aliassystemJuly 23, 2025 06:53
@seisman
seismanforce-pushed the binstats/statistic branch from 628e69e to e1756bfCompareJuly 24, 2025 06:28
@seismanseisman added the enhancement Improving an existing feature label Jul 24, 2025
@seismanseisman added this to the 0.17.0 milestone Jul 24, 2025
@seismanseisman changed the title POC: pygmt.binstats: Make the 'statistic' parameter more PythonicWIP: pygmt.binstats: Make the 'statistic' parameter more PythonicJul 26, 2025
Base automatically changed from AliasSystem/aliassystem to mainJuly 29, 2025 04:09
@seisman
seismanforce-pushed the binstats/statistic branch 3 times, most recently from 7f190d8 to 8883dd8CompareAugust 3, 2025 04:16
@seisman
seismanforce-pushed the binstats/statistic branch from 8883dd8 to 6df2d83CompareAugust 3, 2025 04:19
@seisman
seisman marked this pull request as ready for review August 3, 2025 04:19
@seismanseisman changed the title WIP: pygmt.binstats: Make the 'statistic' parameter more Pythonicpygmt.binstats: Let the parameter 'statistic' support long-form argumentsAug 3, 2025
@seismanseisman added the needs review This PR has higher priority and needs review. label Aug 3, 2025
@seisman
seisman requested a review from a teamAugust 7, 2025 08:24
Comment threadpygmt/src/binstats.py Outdated
seismanand others added 2 commits August 7, 2025 20:04
Co-authored-by: Yvonne Fröhlich <94163266+yvonnefroehlich@users.noreply.github.com>
@seisman
seisman requested review from a team and CopilotAugust 8, 2025 04:09

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the pygmt.binstats function to support long-form arguments for the statistic parameter, replacing short single-letter codes with descriptive names (e.g., statistic="mean" instead of statistic="a").

Key changes:

  • Implemented an alias system to map long-form statistic names to their corresponding short-form GMT codes
  • Added type hints and explicit parameter definitions for better API usability
  • Updated tests to use the new long-form syntax

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

FileDescription
pygmt/src/binstats.pyAdds alias system, type hints, and long-form parameter support for statistic names
pygmt/tests/test_binstats.pyUpdates existing tests to use long-form statistic names and adds new quantile test

Comment threadpygmt/src/binstats.py
Comment threadpygmt/tests/test_binstats.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@seismanseisman changed the title pygmt.binstats: Let the parameter 'statistic' support long-form argumentspygmt.binstats: Let the parameter 'statistic' support descriptive argumentsAug 8, 2025
@seismanseisman added final review call This PR requires final review and approval from a second reviewer and removed needs review This PR has higher priority and needs review. labels Aug 9, 2025
@seismanseisman removed the final review call This PR requires final review and approval from a second reviewer label Aug 10, 2025
@seisman
seisman merged commit 2bc5931 into mainAug 10, 2025
23 of 24 checks passed
@seisman
seisman deleted the binstats/statistic branch August 10, 2025 05:34
@github-project-automationgithub-project-automationBot moved this from In Progress to Done in Pythonic GMT argumentsAug 10, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementImproving an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@seisman@michaelgrund@yvonnefroehlich