Skip to content

Add a helper function to check if a parameter is given or not#4464

Open
Chuan1937 wants to merge 4 commits into
mainfrom
helper
Open

Add a helper function to check if a parameter is given or not#4464
Chuan1937 wants to merge 4 commits into
mainfrom
helper

Conversation

@Chuan1937

@Chuan1937 Chuan1937 commented Mar 21, 2026

Copy link
Copy Markdown
Member

Replace #4439
close #4355

@Chuan1937 Chuan1937 self-assigned this Mar 21, 2026
@Chuan1937 Chuan1937 added this to the 0.19.0 milestone Mar 21, 2026
@seisman seisman removed this from the 0.19.0 milestone May 23, 2026
@seisman

seisman commented Jun 22, 2026

Copy link
Copy Markdown
Member

@Chuan1937 I wonder if you would like to continue with this PR?

@Chuan1937

Copy link
Copy Markdown
Member Author

@Chuan1937 I wonder if you would like to continue with this PR?

of course

Copilot AI 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 pull request introduces a centralized is_given() helper for determining whether a PyGMT parameter should be treated as “provided” (i.e., not None and not False), and refactors multiple modules to use it for clearer and more consistent option/validation logic.

Changes:

  • Add pygmt.helpers.utils.is_given() (re-exported via pygmt.helpers) and use it in build_arg_list/args_in_kwargs.
  • Refactor parameter conflict checks across several pygmt.src.* wrappers to use is_given.
  • Update Alias string conversion and BaseParam.__repr__ to use the shared “given” predicate.

Reviewed changes

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

Show a summary per file
File Description
pygmt/helpers/utils.py Adds is_given() and updates argument-building utilities to use it.
pygmt/helpers/init.py Re-exports is_given from helpers for convenient imports.
pygmt/alias.py Uses is_given to normalize None/False handling during alias string conversion.
pygmt/src/_common.py Uses is_given in _parse_position conflict checking.
pygmt/params/base.py Uses is_given to filter fields included in BaseParam.__repr__.
pygmt/src/basemap.py Refactors deprecation-parameter checks to use is_given.
pygmt/src/colorbar.py Refactors _build_frame “old frame” and axis detection logic to use is_given.
pygmt/src/grdfill.py Uses is_given to count mutually exclusive “at least one” parameters.
pygmt/src/grdfilter.py Uses is_given for old-syntax conflict detection.
pygmt/src/grdgradient.py Uses is_given for old-syntax conflict detection.
pygmt/src/grdproject.py Uses is_given for unit/scaling mutual exclusion validation.
pygmt/src/grdview.py Uses is_given for old-syntax conflict detection.
pygmt/src/subplot.py Uses is_given in autolabel/tag conflict checks and tag_box validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@seisman seisman added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog labels Jun 23, 2026
@seisman seisman added this to the 0.19.0 milestone Jun 23, 2026
@seisman seisman added the final review call This PR requires final review and approval from a second reviewer label Jun 23, 2026

@seisman seisman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me.

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.

Add a helper function to check if a parameter is given or not

3 participants