Skip to content

Commit ab91134

Browse files
Merge branch 'master' into wrap-grd2cpt
2 parents ea4244b + b8385bf commit ab91134

19 files changed

+125
-61
lines changed

.github/dependabot.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Set update schedule for GitHub Actions
2+
3+
version: 2
4+
updates:
5+
6+
- package-ecosystem: "github-actions"
7+
directory: "/"
8+
schedule:
9+
# Check for updates to GitHub Actions every weekday
10+
interval: "weekly"
11+
day: "tuesday"
12+
# Allow up to 2 open pull requests at a time
13+
open-pull-requests-limit: 2
14+
# Specify labels for pull requests
15+
labels:
16+
- "maintenance"
17+
- "skip-changelog"

.github/workflows/format-command.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
ref: ${{ github.event.client_payload.pull_request.head.ref }}
2222

2323
# Setup Python environment
24-
- uses: actions/setup-python@v1
24+
- uses: actions/setup-python@v2.2.1
2525

2626
# Install formatting tools
2727
- name: Install formatting tools

.github/workflows/publish-to-pypi.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
fetch-depth: 0
2929

3030
- name: Set up Python
31-
uses: actions/setup-python@v2
31+
uses: actions/setup-python@v2.2.1
3232
with:
3333
python-version: 3.9
3434

@@ -52,13 +52,13 @@ jobs:
5252
ls -lh dist/
5353
5454
- name: Publish to Test PyPI
55-
uses: pypa/gh-action-pypi-publish@v1.4.1
55+
uses: pypa/gh-action-pypi-publish@v1.4.2
5656
with:
5757
password: ${{ secrets.test_pypi_password }}
5858
repository_url: https://test.pypi.org/legacy/
5959

6060
- name: Publish to PyPI
6161
if: startsWith(github.ref, 'refs/tags')
62-
uses: pypa/gh-action-pypi-publish@v1.4.1
62+
uses: pypa/gh-action-pypi-publish@v1.4.2
6363
with:
6464
password: ${{ secrets.pypi_password }}

.github/workflows/style_checks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020

2121
# Setup Miniconda
2222
- name: Set up Python
23-
uses: actions/setup-python@v2
23+
uses: actions/setup-python@v2.2.1
2424
with:
2525
python-version: 3.9
2626

pygmt/helpers/decorators.py

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -13,111 +13,124 @@
1313
from pygmt.helpers.utils import is_nonstr_iter
1414

1515
COMMON_OPTIONS = {
16-
"R": """\
16+
"R": r"""
1717
region : str or list
1818
*Required if this is the first plot command*.
19-
``'xmin/xmax/ymin/ymax[+r][+uunit]'``.
19+
*xmin/xmax/ymin/ymax*\ [**+r**][**+u**\ *unit*].
2020
Specify the region of interest.""",
21-
"J": """\
21+
"J": r"""
2222
projection : str
2323
*Required if this is the first plot command*.
24+
*projcode*\[*projparams*/]\ *width*.
2425
Select map projection.""",
25-
"B": """\
26-
frame : str or list
26+
"B": r"""
27+
frame : bool or str or list
2728
Set map boundary frame and axes attributes.""",
2829
"U": """\
2930
timestamp : bool or str
3031
Draw GMT time stamp logo on plot.""",
31-
"CPT": """\
32+
"CPT": r"""
3233
cmap : str
33-
File name of a CPT file or ``C='color1,color2[,color3,...]'`` to
34-
build a linear continuous CPT from those colors automatically.""",
34+
File name of a CPT file or a series of comma-separated colors
35+
(e.g., *color1*,\ *color2*,\ *color3*) to build a linear continuous
36+
CPT from those colors automatically.""",
3537
"G": """\
3638
color : str
3739
Select color or pattern for filling of symbols or polygons. Default
3840
is no fill.""",
3941
"V": """\
40-
verbose : str
41-
Select verbosity level [Default is w], which modulates the messages
42+
verbose : bool or str
43+
Select verbosity level [Default is **w**], which modulates the messages
4244
written to stderr. Choose among 7 levels of verbosity:
4345
4446
- **q** - Quiet, not even fatal error messages are produced
4547
- **e** - Error messages only
4648
- **w** - Warnings [Default]
4749
- **t** - Timings (report runtimes for time-intensive algorthms);
48-
- **i** - Informational messages (same as "verbose=True")
50+
- **i** - Informational messages (same as ``verbose=True``)
4951
- **c** - Compatibility warnings
5052
- **d** - Debugging messages""",
5153
"W": """\
5254
pen : str
5355
Set pen attributes for lines or the outline of symbols.""",
54-
"XY": """\
56+
"XY": r"""
5557
xshift : str
56-
``[a|c|f|r][xshift]``.
58+
[**a**\|\ **c**\|\ **f**\|\ **r**\][*xshift*].
5759
Shift plot origin in x-direction.
5860
yshift : str
59-
``[a|c|f|r][yshift]``.
61+
[**a**\|\ **c**\|\ **f**\|\ **r**\][*yshift*].
6062
Shift plot origin in y-direction. Full documentation is at
6163
:gmt-docs:`gmt.html#xy-full`.
6264
""",
63-
"j": """\
65+
"c": r"""
66+
panel : bool or int or list
67+
[*row,col*\|\ *index*].
68+
Selects a specific subplot panel. Only allowed when in subplot
69+
mode. Use ``panel=True`` to advance to the next panel in the
70+
selected order. Instead of *row,col* you may also give a scalar
71+
value *index* which depends on the order you set via ``autolabel``
72+
when the subplot was defined. **Note**: *row*, *col*, and *index*
73+
all start at 0.
74+
""",
75+
"j": r"""
6476
distcalc : str
65-
``e|f|g``.
77+
**e**\|\ **f**\|\ **g**.
6678
Determine how spherical distances are calculated.
6779
6880
- **e** - Ellipsoidal (or geodesic) mode
6981
- **f** - Flat Earth mode
7082
- **g** - Great circle distance [Default]
7183
7284
All spherical distance calculations depend on the current ellipsoid
73-
(PROJ_ELLIPSOID), the definition of the mean radius
74-
(PROJ_MEAN_RADIUS), and the specification of latitude type
75-
(PROJ_AUX_LATITUDE). Geodesic distance calculations is also
76-
controlled by method (PROJ_GEODESIC).""",
77-
"n": """\
85+
(:gmt-term:`PROJ_ELLIPSOID`), the definition of the mean radius
86+
(:gmt-term:`PROJ_MEAN_RADIUS`), and the specification of latitude type
87+
(:gmt-term:`PROJ_AUX_LATITUDE`). Geodesic distance calculations is also
88+
controlled by method (:gmt-term:`PROJ_GEODESIC`).""",
89+
"n": r"""
7890
interpolation : str
79-
``[b|c|l|n][+a][+bBC][+c][+tthreshold]``
91+
[**b**\|\ **c**\|\ **l**\|\ **n**][**+a**][**+b**\ *BC*][**+c**][**+t**\ *threshold*].
8092
Select interpolation mode for grids. You can select the type of
8193
spline used:
8294
83-
- 'b' for B-spline
84-
- 'c' for bicubic [Default]
85-
- 'l' for bilinear
86-
- 'n' for nearest-neighbor""",
87-
"p": """\
95+
- **b** for B-spline
96+
- **c** for bicubic [Default]
97+
- **l** for bilinear
98+
- **n** for nearest-neighbor""",
99+
"p": r"""
88100
perspective : list or str
89-
``'[x|y|z]azim[/elev[/zlevel]][+wlon0/lat0[/z0]][+vx0/y0]'``.
101+
[**x**\|\ **y**\|\ **z**]\ *azim*\[/*elev*\[/*zlevel*]]
102+
[**+w**\ *lon0*/*lat0*\[/*z0*]][**+v**\ *x0*/*y0*].
90103
Select perspective view and set the azimuth and elevation angle of
91104
the viewpoint. Default is [180, 90]. Full documentation is at
92105
:gmt-docs:`gmt.html#perspective-full`.
93106
""",
94-
"registration": """\
107+
"registration": r"""
95108
registration : str
96-
``[g|p]``
109+
**g**\|\ **p**.
97110
Force output grid to be gridline (g) or pixel (p) node registered.
98111
Default is gridline (g).""",
99112
"t": """\
100-
transparency : float
113+
transparency : int or float
101114
Set transparency level, in [0-100] percent range.
102115
Default is 0, i.e., opaque.
103116
Only visible when PDF or raster format output is selected.
104117
Only the PNG format selection adds a transparency layer
105118
in the image (for further processing). """,
106-
"x": """\
107-
cores : int
108-
``[[-]n]``.
119+
"x": r"""
120+
cores : bool or int
121+
[[**-**]\ *n*].
109122
Limit the number of cores to be used in any OpenMP-enabled
110123
multi-threaded algorithms. By default we try to use all available
111124
cores. Set a number *n* to only use n cores (if too large it will
112125
be truncated to the maximum cores available). Finally, give a
113-
negative number *-n* to select (all - n) cores (or at least 1 if
114-
n equals or exceeds all).
126+
negative number *-n* to select (all - *n*) cores (or at least 1 if
127+
*n* equals or exceeds all).
115128
""",
116129
}
117130

118131

119132
def fmt_docstring(module_func):
120-
"""
133+
r"""
121134
Decorator to insert common text into module docstrings.
122135
123136
Should be the last decorator (at the top).
@@ -173,10 +186,11 @@ def fmt_docstring(module_func):
173186
----------
174187
region : str or list
175188
*Required if this is the first plot command*.
176-
``'xmin/xmax/ymin/ymax[+r][+uunit]'``.
189+
*xmin/xmax/ymin/ymax*\ [**+r**][**+u**\ *unit*].
177190
Specify the region of interest.
178191
projection : str
179192
*Required if this is the first plot command*.
193+
*projcode*\[*projparams*/]\ *width*.
180194
Select map projection.
181195
<BLANKLINE>
182196
**Aliases:**
@@ -195,9 +209,9 @@ def fmt_docstring(module_func):
195209
filler_text["aliases"] = "\n".join(aliases)
196210

197211
for marker, text in COMMON_OPTIONS.items():
198-
# Remove the indentation from the multiline strings so that it doesn't
199-
# mess up the original docstring
200-
filler_text[marker] = textwrap.dedent(text)
212+
# Remove the indentation and the first line break from the multiline
213+
# strings so that it doesn't mess up the original docstring
214+
filler_text[marker] = textwrap.dedent(text.lstrip("\n"))
201215

202216
# Dedent the docstring to make it all match the option text.
203217
docstring = textwrap.dedent(module_func.__doc__)

pygmt/src/basemap.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@
2727
V="verbose",
2828
X="xshift",
2929
Y="yshift",
30+
c="panel",
3031
p="perspective",
3132
t="transparency",
3233
)
33-
@kwargs_to_strings(R="sequence", p="sequence")
34+
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
3435
def basemap(self, **kwargs):
3536
"""
3637
Plot base maps and frames for the figure.
@@ -66,13 +67,14 @@ def basemap(self, **kwargs):
6667
{U}
6768
{V}
6869
{XY}
70+
{c}
6971
{p}
7072
{t}
7173
"""
7274
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
73-
if not args_in_kwargs(args=["B", "L", "Td", "Tm"], kwargs=kwargs):
75+
if not args_in_kwargs(args=["B", "L", "Td", "Tm", "c"], kwargs=kwargs):
7476
raise GMTInvalidInput(
75-
"At least one of frame, map_scale, compass, or rose must be specified."
77+
"At least one of frame, map_scale, compass, rose, or panel must be specified."
7678
)
7779
with Session() as lib:
7880
lib.call_module("basemap", build_arg_string(kwargs))

pygmt/src/coast.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@
3232
V="verbose",
3333
X="xshift",
3434
Y="yshift",
35+
c="panel",
3536
p="perspective",
3637
t="transparency",
3738
)
38-
@kwargs_to_strings(R="sequence", p="sequence")
39+
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
3940
def coast(self, **kwargs):
4041
r"""
4142
Plot continents, shorelines, rivers, and borders on maps
@@ -182,6 +183,7 @@ def coast(self, **kwargs):
182183
the segment headers via **-Z**\ *code* settings.To apply different
183184
settings to different countries, pass a list of string arguments.
184185
{XY}
186+
{c}
185187
{p}
186188
{t}
187189
{V}

pygmt/src/colorbar.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@
2020
V="verbose",
2121
X="xshift",
2222
Y="yshift",
23+
c="panel",
2324
p="perspective",
2425
t="transparency",
2526
)
26-
@kwargs_to_strings(R="sequence", G="sequence", I="sequence", p="sequence")
27+
@kwargs_to_strings(
28+
R="sequence", G="sequence", I="sequence", c="sequence_comma", p="sequence"
29+
)
2730
def colorbar(self, **kwargs):
2831
"""
2932
Plot a gray or color scale-bar on maps.
@@ -94,6 +97,7 @@ def colorbar(self, **kwargs):
9497
illumination.
9598
{V}
9699
{XY}
100+
{c}
97101
{p}
98102
{t}
99103
"""

pygmt/src/contour.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@
3030
V="verbose",
3131
X="xshift",
3232
Y="yshift",
33+
c="panel",
3334
p="perspective",
3435
t="transparency",
3536
)
36-
@kwargs_to_strings(R="sequence", i="sequence_comma", p="sequence")
37+
@kwargs_to_strings(R="sequence", c="sequence_comma", i="sequence_comma", p="sequence")
3738
def contour(self, x=None, y=None, z=None, data=None, **kwargs):
3839
"""
3940
Contour table data by direct triangulation.
@@ -92,6 +93,7 @@ def contour(self, x=None, y=None, z=None, data=None, **kwargs):
9293
separator for the two labels instead.
9394
{V}
9495
{XY}
96+
{c}
9597
{p}
9698
{t}
9799
"""

pygmt/src/grdcontour.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@
3030
l="label",
3131
X="xshift",
3232
Y="yshift",
33+
c="panel",
3334
p="perspective",
3435
t="transparency",
3536
)
36-
@kwargs_to_strings(R="sequence", L="sequence", A="sequence_plus", p="sequence")
37+
@kwargs_to_strings(
38+
R="sequence", L="sequence", A="sequence_plus", c="sequence_comma", p="sequence"
39+
)
3740
def grdcontour(self, grid, **kwargs):
3841
"""
3942
Convert grids or images to contours and plot them on maps.
@@ -87,6 +90,7 @@ def grdcontour(self, grid, **kwargs):
8790
{V}
8891
{W}
8992
{XY}
93+
{c}
9094
label : str
9195
Add a legend entry for the contour being plotted. Normally, the
9296
annotated contour is selected for the legend. You can select the

0 commit comments

Comments
 (0)