Skip to content

Session.get_common: Fix the return values for options B/J/U/g/n/p/s and improve option checking - #4862

Merged
seisman merged 1 commit into
mainfrom
clib/get_common
Aug 26, 2026
Merged

Session.get_common: Fix the return values for options B/J/U/g/n/p/s and improve option checking#4862
seisman merged 1 commit into
mainfrom
clib/get_common

Conversation

@seisman

@seisman seisman commented Aug 25, 2026

Copy link
Copy Markdown
Member

Session.get_common checks if an option is set and returns its value if possible.

As shown below, it has bugs for some options. For examples, when -fg/-fig is used, it returns True, while -fog returns 1.

In [1]: from pygmt.clib import Session

In [2]: with Session() as lib:
   ...:     lib.call_module("basemap", ["-R0/10/0/10", "-JX10c", "-Baf", "-fg"])
   ...:     print(lib.get_common("f"))
   ...:
True

In [3]: with Session() as lib:
   ...:     lib.call_module("basemap", ["-R0/10/0/10", "-JX10c", "-Baf", "-fig"])
   ...:     print(lib.get_common("f"))
   ...:
True

In [4]: with Session() as lib:
   ...:     lib.call_module("basemap", ["-R0/10/0/10", "-JX10c", "-Baf", "-fog"])
   ...:     print(lib.get_common("f"))
   ...:
1

This PR fixes the bug. With the changes in this PR, it returns 0 or 1 when set, and False when not set.

Bugs detected and fixed by Claude, reviewed by @seisman

@seisman seisman added this to the 0.20.0 milestone Aug 25, 2026
@seisman seisman added maintenance Boring but important stuff for the core devs skip-changelog Skip adding Pull Request to changelog needs review This PR has higher priority and needs review. bug Something isn't working and removed needs review This PR has higher priority and needs review. labels Aug 25, 2026
@seisman
seisman merged commit a7b8361 into main Aug 26, 2026
29 of 30 checks passed
@seisman
seisman deleted the clib/get_common branch August 26, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working 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.

1 participant