GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — New Alias System: Add the private _to_string function by seisman · Pull Request #3986 · GenericMappingTools/pygmt

Conversation

@seisman

@seisman seisman commented Jun 21, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Part 1 of PR #3238

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@seisman seisman added this to the 0.17.0 milestone Jun 23, 2025
@seisman seisman added the enhancement Improving an existing feature label Jun 23, 2025
seisman added 2 commits June 29, 2025 15:18
@seisman
Add the _to_string function
b7019d0
@seisman
Use GMTValueError
8f5c52b
@seisman
seisman force-pushed the AliasSystem/to_string branch from 01b8267 to 8f5c52b Compare June 29, 2025 07:18
seisman
seisman commented Jul 1, 2025
View reviewed changes
Comment thread pygmt/alias.py Outdated
Comment on lines +112 to +123
match mapping:
case False:
pass
case True:
value = value[0]
case Mapping():
if value not in mapping and value not in mapping.values():
raise GMTValueError(
value,
description="value for parameter {name!r}" if name else "value",
choices=mapping.keys(),
)

@seisman seisman Jul 1, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

mapping=True means using the first letter of a long-form argument as its short-form argument. For example, resolution="high" will be mapped to resolution="h". If we don't support mapping=True, lines 112-123 can be simplified to a few lines:

                if value not in mapping and value not in mapping.values():
                    raise GMTValueError(
                        value,
                        description="value for parameter {name!r}" if name else "value",
                        choices=mapping.keys(),
                    )

but without mapping=True, we need to write something like

mapping={"full": "f", "high": "h", "intermediate": "i", "low": "l", "crude": "c"}

when calling the _to_string function.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@weiji14 weiji14 Jul 1, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think better to be explicit (use the full mapping {"key": "value"} dict), and just have one way to parse things. We can use the first letter for resolution, but for others like interpolation/-n, where the mapping is {"b-spline": "b", "bicubic": "c", "bilinear": "l", ...}, it doesn't work.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@seisman seisman Jul 2, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I've removed mapping=True in commit c499aab.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

weiji14 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@seisman
Remove the support of mapping=True
c499aab
weiji14
weiji14 reviewed Jul 2, 2025
View reviewed changes
Comment thread pygmt/alias.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread pygmt/alias.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

seisman added 3 commits July 2, 2025 10:06
@seisman
Add more docstrings
232ff52
@seisman
Improve docstrings
2dc37c3
@seisman
Merge branch 'main' into AliasSystem/to_string
f75a7ce
weiji14
weiji14 approved these changes Jul 6, 2025
View reviewed changes

@weiji14 weiji14 left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This looks ok to me, was there anything else you wanted to add?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@seisman

seisman commented Jul 7, 2025

Copy link
Copy Markdown
Member Author

This looks ok to me, was there anything else you wanted to add?

Need to wait for #3985

weiji14 reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seisman seisman added the needs review This PR has higher priority and needs review. label Jul 9, 2025
@seisman
Merge branch 'main' into AliasSystem/to_string
1b7ab63
@seisman
seisman marked this pull request as ready for review July 9, 2025 22:24
@seisman
Fix one doctest
b76ee57
@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. final review call This PR requires final review and approval from a second reviewer labels Jul 10, 2025
@seisman
seisman merged commit 7a682ff into main Jul 10, 2025
@seisman
seisman deleted the AliasSystem/to_string branch July 10, 2025 14:11
seisman added a commit that referenced this pull request Jul 16, 2025
@seisman
New Alias System: Add the private _to_string function (#3986)
71a51de
This was referenced Jul 26, 2025
POC: Implement the new alias system, general parameter classes and some refactors #3238
Closed
New alias system towards a more Pythonic interface #3239
Closed
_to_string: Fix the bug when a 2-D sequence is passed #4032
Merged
@seisman seisman mentioned this pull request Apr 11, 2026
pygmt.select: Select data table subsets based on multiple spatial criteria #4564
Closed
5 of 8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@weiji14 weiji14 weiji14 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

enhancement Improving an existing feature

Projects

None yet

Milestone

0.17.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@seisman @weiji14
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.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.