Skip to content
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

Figure.grdcontour: Adjust processing of arguments passed to the "annotation" and "interval" parameters, deprecate "sequence_plus" #3116

Merged
merged 54 commits into from
Apr 27, 2024
Merged
Changes from 2 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
a3fa214
Use list instead of tuple
yvonnefroehlich Mar 16, 2024
ee143e6
Merge branch 'main' into fix-typos-63-grdcontour
yvonnefroehlich Mar 17, 2024
e59f077
Merge branch 'main' into fix-typos-63-grdcontour
yvonnefroehlich Mar 18, 2024
05b5abb
Remove list input option for annotation parameter
yvonnefroehlich Mar 19, 2024
99dc353
Merge branch 'main' into fix-typos-63-grdcontour
yvonnefroehlich Mar 19, 2024
731d014
Fix line length
yvonnefroehlich Mar 19, 2024
c8b805b
Update syntax to GMT 6.5
yvonnefroehlich Mar 19, 2024
584956e
Update allowed input data type
yvonnefroehlich Mar 19, 2024
4a7a143
Merge branch 'main' into fix-typos-63-grdcontour
yvonnefroehlich Mar 20, 2024
13360d4
Fix typo
yvonnefroehlich Mar 20, 2024
57837fb
Update docstring
yvonnefroehlich Mar 21, 2024
4f06fe4
Use sequence instead of sequence_comma
yvonnefroehlich Mar 21, 2024
311015e
Extend allow input formats
yvonnefroehlich Mar 21, 2024
560622d
Merge branch 'main' into fix-typos-63-grdcontour
yvonnefroehlich Mar 21, 2024
4ae5073
[format-command] fixes
actions-bot Mar 21, 2024
6925eca
Fix typo
yvonnefroehlich Mar 21, 2024
bbeb83c
Shorten documentation
yvonnefroehlich Mar 23, 2024
078553c
Shorten documentation
yvonnefroehlich Mar 23, 2024
1e114cf
Clearify documentation
yvonnefroehlich Mar 23, 2024
c67fcf8
Merge branch 'main' into fix-typos-63-grdcontour
yvonnefroehlich Mar 23, 2024
0cd2f0b
Update docs, Add code for list input
yvonnefroehlich Mar 25, 2024
ccd6b01
Merge branch 'main' into fix-typos-63-grdcontour
yvonnefroehlich Mar 25, 2024
581eef4
Process argument passt to "A" manually
yvonnefroehlich Mar 26, 2024
a86305c
Fix line length
yvonnefroehlich Mar 26, 2024
4c52daa
Merge branch 'main' into fix-typos-63-grdcontour
yvonnefroehlich Mar 26, 2024
c646b51
Merge branch 'main' into fix-typos-63-grdcontour
yvonnefroehlich Apr 5, 2024
6a6df2c
Merge branch 'main' into fix-typos-63-grdcontour
yvonnefroehlich Apr 11, 2024
7c3f012
Merge branch 'main' into fix-typos-63-grdcontour
yvonnefroehlich Apr 18, 2024
f2805bb
Merge branch 'main' into fix-typos-63-grdcontour
yvonnefroehlich Apr 22, 2024
d442adf
Merge branch 'main' into fix-typos-63-grdcontour
yvonnefroehlich Apr 24, 2024
11b2dac
Add tests
yvonnefroehlich Apr 24, 2024
4708483
Update pygmt/src/grdcontour.py
yvonnefroehlich Apr 25, 2024
56afbe8
Update pygmt/src/grdcontour.py
yvonnefroehlich Apr 25, 2024
c8772bf
Use for loop for A and C
yvonnefroehlich Apr 25, 2024
9a9ae49
Fix typo
yvonnefroehlich Apr 25, 2024
ad5c33e
Merge branch 'main' into fix-typos-63-grdcontour
yvonnefroehlich Apr 25, 2024
32c4f90
Update pygmt/tests/test_grdcontour.py
yvonnefroehlich Apr 25, 2024
d9c734b
Update pygmt/tests/test_grdcontour.py
yvonnefroehlich Apr 25, 2024
9f394f7
Explain code block for 'A' and 'C'
yvonnefroehlich Apr 25, 2024
557af15
Update tests
yvonnefroehlich Apr 25, 2024
e964dda
Add test_grdcontour_one_level.png into DVC
Apr 25, 2024
4501bab
Add test_grdcontour_multiple_levels.png into DVC
yvonnefroehlich Apr 25, 2024
5fa02fb
[format-command] fixes
actions-bot Apr 25, 2024
988d77e
Add period
yvonnefroehlich Apr 26, 2024
7ade301
Add periods
yvonnefroehlich Apr 26, 2024
cb6871b
Add code for backward-compatibility regarding 'sequence_plus'
yvonnefroehlich Apr 27, 2024
a4c9216
Merge branch 'main' into fix-typos-63-grdcontour
yvonnefroehlich Apr 27, 2024
e25e9ed
[format-command] fixes
actions-bot Apr 27, 2024
7fee937
Import warinings
yvonnefroehlich Apr 27, 2024
be21572
Use square instead of round brakets
yvonnefroehlich Apr 27, 2024
a05ec74
Add test for old syntax of 'annotations' parameter
yvonnefroehlich Apr 27, 2024
fedf60d
Fix keyword of 'warnings.warn' from 'catalog' to 'category'
yvonnefroehlich Apr 27, 2024
6c53454
Adjust test to reuse baseline image
yvonnefroehlich Apr 27, 2024
574c4a7
Fix typos
yvonnefroehlich Apr 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pygmt/src/grdcontour.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ def grdcontour(self, grid, **kwargs):
contours specified in ``interval``.

- Specify a fixed annotation interval *annot_int* or a
single annotation level +\ *annot_int*.
single annotation level **+**\ *annot_int*.
- Disable all annotation with **-**.
seisman marked this conversation as resolved.
Show resolved Hide resolved
- Optional label modifiers can be specified as a single string
``"[annot_int]+e"`` or with a list of arguments
``([annot_int], "e", "f10p", "gred")``.
``"annot_int+e+f10p+gred"`` or with a list of arguments
``[annot_int, "e", "f10p", "gred"]``.
Copy link
Member Author

@yvonnefroehlich yvonnefroehlich Mar 17, 2024

Choose a reason for hiding this comment

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

I am wondering whether here the squared brackets are used to indicate that annot_int should be replaced with the desired value by the user. I find this a bit misleading.

The rounded brackets should be replaced by squared brackets as we write "list of arguments".

Copy link
Member

Choose a reason for hiding this comment

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

I don't think the description is correct. In the PyGMT world, a list of arguments means the option is repeatable. For example frame=["WSen", "xaf", "yaf"] is translated to -BWSen -Bxaf -Byaf. For this parameter, it must be annot_int+e+f10+gred, not a list.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm. I tried the following code to understand the input expected by annotation. It works for passing a list and I get the same output as for passing a string.

# orientated on https://www.pygmt.org/dev/api/generated/pygmt.Figure.grdcontour.html
# last access: 2024/03/18

import pygmt

region = [-92.5, -82.5, -3, 7]

grid = pygmt.datasets.load_earth_relief(resolution="15m", region=region)

fig = pygmt.Figure()
fig.grdcontour(
    projection="M10c",
    region=region,
    grid=grid,
    # annotation="500+f10p+gred",  # string -> WORKS
    # annotation=([500], "f10p", "gred"),  # -> FAILS
    # annotation=(500, "f10p", "gred"),  # -> WORKS
    annotation=[500, "f10p", "gred"],  # list -> WORKS
    frame=True,
)
fig.show()

# fig.savefig(fname="grdcontour_A_string.png")
# fig.savefig(fname="grdcontour_A_list.png")

Output figure
grdcontour_A_list

Copy link
Member

Choose a reason for hiding this comment

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

@kwargs_to_strings(
R="sequence", L="sequence", A="sequence_plus", c="sequence_comma", p="sequence"
)

I see. It's because A is defined like above, so the list of arguments is joined by +.

Actually, this is the only parameter that sets to sequence_plus.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should disallow the syntax like annotation=[500, "f10p", "gred"], because:

  1. From a user's perspective, it's no different from passing a string like 500+f10p+gred
  2. The syntax is not well documented and is only used for this single parameter
  3. It's not Pythonic at all, and it's very likely that we won't support such syntax in the new alias system (POC: WIP: New alias system #2949 but still WIP)

So, I think we should remove A="sequence_plus" and update the documentation.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was actually also a bit wondering if we need this possibility, as such a list does not improve the readability significantly compared to the corresponding string. So, I think I am fine with removing A"sequence_plus".

limit : str or list of 2 ints
*low*/*high*.
Do no draw contours below `low` or above `high`, specify as string
Expand Down
Loading