Skip to content

Conversation

Copy link

Copilot AI commented Feb 12, 2026

Parameter ordering was inconsistent across PyGMT functions, with common parameters appearing in different sequences in different files. This created cognitive overhead when navigating the codebase and made the API harder to learn.

Changes

Established canonical ordering:

  • Uppercase: projectionzscalezsizeregionframeverbose
  • Lowercase: alphabetically by GMT flag (a, b, c, d, e, f, g, h, i, l, n, o, p, r, s, t, w)

Updated 29 files:

  • Function signatures: reordered parameters to match canonical sequence
  • Docstrings: moved common parameters to end, ordered canonically
  • Special case: basemap.py keeps projection/region/frame at start (primary parameters)

Example

Before:

def plot(
    projection: str | None = None,
    frame: str | bool = False,          # wrong position
    region: str | None = None,
    verbose: bool = False,
    transparency: float | None = None,  # t before p
    perspective: float | bool = False,
):

After:

def plot(
    projection: str | None = None,
    region: str | None = None,
    frame: str | bool = False,          # ✓
    verbose: bool = False,
    panel: int | bool = False,          # c
    perspective: float | bool = False,  # p
    transparency: float | None = None,  # t ✓
):

All 57 files with common parameters now follow canonical ordering.

Original prompt

This section details on the original issue you should resolve

<issue_title>Consistently list all common options alphabetically at the end of docstrings</issue_title>
<issue_description>GMT modules share many common options (e.g., -J, -R), and most PyGMT methods/functions provide corresponding common aliases (e.g., projection, region). At present, these aliases are listed inconsistently in docstrings and are often placed at the very beginning. I believe it would make more sense to group them at the end instead.

The reasons are:

  • Upper-case GMT options (-B, -J, -R, -V) are not central to most individual modules. In typical plotting workflows, only the first plotting command needs to specify -J, -R, and -B.
  • Users are generally already familiar with these common options and are more interested in learning about the parameters that are unique to a given function or method.

So, I propose the following:

  • List all common options alphabetically at the end of docstrings, rather than interleaving them with module-specific parameters.
  • Add a dedicated subsection (e.g., “Common Parameters”) to clearly separate shared options from parameters that are unique to each function or method. [Depending on if it looks better or worse]

This structure would improve readability, make docstrings more consistent across PyGMT, and help users focus on the parameters that matter most for a given module.
</issue_description>

<agent_instructions>There is already a PR #4286. Can you continue that PR?
</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@yvonnefroehlich > List all common options alphabetically at the end of docstrings, rather than interleaving them with module-specific parameters.

Agree on having a more consistent structure for the alias list, with focus on the function / method specific aliases and placing those at the beginning. For me it sounds good to group the common options and add them at the end.

Add a dedicated subsection (e.g., “Common Parameters”) to clearly separate shared options from parameters that are unique to each function or method. [Depending on if it looks better or worse]

we can just try it with one method and see how it looks.

@seisman > > Add a dedicated subsection (e.g., “Common Parameters”) to clearly separate shared options from parameters that are unique to each function or method. [Depending on if it looks better or worse] > > we can just try it with one method and see how it looks.

I've tried in PR #4286. It works well, but the type hints are not shown correctly.

Image</comment_new>
<comment_new>@seisman
For uppercase option flags, sorting the aliases by their corresponding single-letter option flags would give the order frame (-B), projection (-J), region (-R), and verbose (-V). However, I find it more intuitive to order them as projection (plus zscale/zsize for some methods), region, frame, and verbose.

I would suggest projection->region->frame->verbose for these uppercase option flags, and sort other common parameters by the alphabetical order of their corresponding lowercase option flags.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits February 12, 2026 14:22
Co-authored-by: seisman <3974108+seisman@users.noreply.github.com>
Co-authored-by: seisman <3974108+seisman@users.noreply.github.com>
Co-authored-by: seisman <3974108+seisman@users.noreply.github.com>
Copilot AI changed the title [WIP] Consistently list common options alphabetically in docstrings Reorganize common parameters to end of docstrings Feb 12, 2026
Copilot AI requested a review from seisman February 12, 2026 14:38
…dview)

Co-authored-by: seisman <3974108+seisman@users.noreply.github.com>
…ication

Co-authored-by: seisman <3974108+seisman@users.noreply.github.com>
Copilot AI changed the title Reorganize common parameters to end of docstrings Standardize parameter ordering: uppercase params by spec, lowercase alphabetically by GMT flag Feb 12, 2026
…emap, fix registration ordering in binstats

Co-authored-by: seisman <3974108+seisman@users.noreply.github.com>
Co-authored-by: seisman <3974108+seisman@users.noreply.github.com>
Copilot AI changed the title Standardize parameter ordering: uppercase params by spec, lowercase alphabetically by GMT flag Standardize parameter ordering across all PyGMT functions Feb 12, 2026
@seisman seisman added the maintenance Boring but important stuff for the core devs label Feb 12, 2026
@seisman seisman added skip-changelog Skip adding Pull Request to changelog needs review This PR has higher priority and needs review. labels Feb 12, 2026
@seisman seisman added this to the 0.19.0 milestone Feb 12, 2026
@seisman seisman changed the title Standardize parameter ordering across all PyGMT functions Standardize parameter ordering in function signature and docstrings for common options Feb 12, 2026
@seisman seisman marked this pull request as ready for review February 12, 2026 15:59
@seisman seisman 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 Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

final review call This PR requires final review and approval from a second reviewer maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consistently list all common options alphabetically at the end of docstrings

2 participants