-
Notifications
You must be signed in to change notification settings - Fork 235
AliasSystem: Support adding a suffix to a value and simplify Figure.wiggle #4259
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
seisman
wants to merge
13
commits into
main
Choose a base branch
from
AliasSystem/suffix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+68
−65
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5d81d2a
AliasSystem: Support adding a suffix to a value and simplify Figure.w…
seisman 9c4dde4
Return a list of values if Alias has suffix
seisman a8f9851
Merge branch 'main' into AliasSystem/suffix
seisman 2b94c3c
Merge branch 'main' into AliasSystem/suffix
seisman fdf2c1a
Merge branch 'main' into AliasSystem/suffix
seisman 51dee3c
Merge branch 'main' into AliasSystem/suffix
seisman 1647476
Merge branch 'main' into AliasSystem/suffix
seisman f380b6d
Merge branch 'main' into AliasSystem/suffix
seisman 7c81056
Merge branch 'main' into AliasSystem/suffix
seisman 12e451c
Add type hints to wiggle
seisman 7ceea09
Improve docstrings for AliasSysytem
seisman b920d4a
Improve doctests
seisman 51c4dc2
Merge branch 'main' into AliasSystem/suffix
seisman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,33 +13,6 @@ | |
| from pygmt.src._common import _parse_position | ||
|
|
||
|
|
||
| def _parse_fills(positive_fill, negative_fill): | ||
| """ | ||
| Parse the positive_fill and negative_fill parameters. | ||
|
|
||
| >>> _parse_fills("red", "blue") | ||
| ['red+p', 'blue+n'] | ||
| >>> _parse_fills(None, "blue") | ||
| 'blue+n' | ||
| >>> _parse_fills("red", None) | ||
| 'red+p' | ||
| >>> _parse_fills(None, None) | ||
| """ | ||
| _fills = [] | ||
| if positive_fill is not None: | ||
| _fills.append(positive_fill + "+p") | ||
| if negative_fill is not None: | ||
| _fills.append(negative_fill + "+n") | ||
|
|
||
| match len(_fills): | ||
| case 0: | ||
| return None | ||
| case 1: | ||
| return _fills[0] | ||
| case 2: | ||
| return _fills | ||
|
|
||
|
|
||
| @fmt_docstring | ||
| # TODO(PyGMT>=0.20.0): Remove the deprecated 'fillpositive' parameter. | ||
| # TODO(PyGMT>=0.20.0): Remove the deprecated 'fillnegative' parameter. | ||
|
|
@@ -71,8 +44,8 @@ def wiggle( # noqa: PLR0913 | |
| length: float | str | None = None, | ||
| label: str | None = None, | ||
| label_alignment: Literal["left", "right"] | None = None, | ||
| positive_fill=None, | ||
| negative_fill=None, | ||
| positive_fill: str | None = None, | ||
| negative_fill: str | None = None, | ||
| projection: str | None = None, | ||
| region: Sequence[float | str] | str | None = None, | ||
| frame: str | Sequence[str] | bool = False, | ||
|
|
@@ -115,7 +88,6 @@ def wiggle( # noqa: PLR0913 | |
| $table_classes. | ||
| Use parameter ``incols`` to choose which columns are x, y, z, | ||
| respectively. | ||
|
|
||
| position | ||
| Position of the vertical scale on the plot. It can be specified in multiple | ||
| ways: | ||
|
|
@@ -174,8 +146,6 @@ def wiggle( # noqa: PLR0913 | |
| kwdict={"length": length, "label": label, "label_alignment": label_alignment}, | ||
| ) | ||
|
|
||
| _fills = _parse_fills(positive_fill, negative_fill) | ||
|
|
||
| aliasdict = AliasSystem( | ||
| D=[ | ||
| Alias(position, name="position"), | ||
|
|
@@ -188,7 +158,10 @@ def wiggle( # noqa: PLR0913 | |
| ), | ||
| Alias(label, name="label", prefix="+l"), | ||
| ], | ||
| G=Alias(_fills, name="positive_fill/negative_fill"), | ||
| G=[ | ||
| Alias(positive_fill, name="positive_fill", suffix="+p"), | ||
| Alias(negative_fill, name="negative_fill", suffix="+n"), | ||
|
Comment on lines
+162
to
+163
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe take this opportunity to update the type-hint of
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 12e451c |
||
| ], | ||
| ).add_common( | ||
| B=frame, | ||
| J=projection, | ||
|
|
||
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.
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.
Would it be confusing if we allowed both
prefixandsuffixwhen value is True? E.g. at #4234 (comment), we usedprefix, but it could also besuffix.Or I guess it doesn't matter, and we should just be consistent that every if-branch in this
_to_stringfunction handles prefix and suffix.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.
prefixandsuffixcannot coexist. This function does do the check to avoid too much function overhead. It's our responsibility to pass the correctprefix/suffixvalues.