Skip to content

Commit 9217078

Browse files
API reference: Shorten supported argument types in docstrings (#2746)
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
1 parent f864fa9 commit 9217078

38 files changed

+83
-80
lines changed

pygmt/helpers/decorators.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
COMMON_DOCSTRINGS = {
1818
"area_thresh": r"""
19-
area_thresh : int or float or str
19+
area_thresh : float or str
2020
*min_area*\ [/*min_level*/*max_level*][**+a**\[**g**\|\ **i**]\
2121
[**s**\|\ **S**]][**+l**\|\ **r**][**+p**\ *percent*].
2222
Features with an area smaller than *min_area* in km\ :sup:`2` or of
@@ -105,7 +105,7 @@
105105
that do not match the pattern. Append **i** for case insensitive
106106
matching. This does not apply to headers or segment headers.""",
107107
"frame": r"""
108-
frame : bool or str or list
108+
frame : bool, str, or list
109109
Set map boundary
110110
:doc:`frame and axes attributes </tutorials/basics/frames>`. """,
111111
"gap": r"""
@@ -247,7 +247,7 @@
247247
used then the columns given to ``outcols`` correspond to the
248248
order after the ``incols`` selection has taken place.""",
249249
"panel": r"""
250-
panel : bool or int or list
250+
panel : bool, int, or list
251251
[*row,col*\|\ *index*].
252252
Select a specific subplot panel. Only allowed when in subplot
253253
mode. Use ``panel=True`` to advance to the next panel in the
@@ -298,7 +298,7 @@
298298
more of the columns equal NaN [Default skips record only
299299
if values in all specified *cols* equal NaN].""",
300300
"spacing": r"""
301-
spacing : int or float or str or list or tuple
301+
spacing : float, str, or list
302302
*x_inc*\ [**+e**\|\ **n**][/\ *y_inc*\ [**+e**\|\ **n**]].
303303
*x_inc* [and optionally *y_inc*] is the grid spacing.
304304
@@ -329,7 +329,7 @@
329329
the registration have already been initialized; use ``spacing`` and
330330
``registration`` to override these values.""",
331331
"transparency": r"""
332-
transparency : int or float
332+
transparency : float
333333
Set transparency level, in [0-100] percent range
334334
[Default is ``0``, i.e., opaque].
335335
Only visible when PDF or raster format output is selected.
@@ -400,7 +400,7 @@ def fmt_docstring(module_func):
400400
...
401401
... Parameters
402402
... ----------
403-
... data : str or {table-like}
403+
... data : str, {table-like}
404404
... Pass in either a file name to an ASCII data table, a 2-D
405405
... {table-classes}.
406406
... {region}
@@ -416,7 +416,7 @@ def fmt_docstring(module_func):
416416
<BLANKLINE>
417417
Parameters
418418
----------
419-
data : str or numpy.ndarray or pandas.DataFrame or xarray.Dataset or geo...
419+
data : str, numpy.ndarray, pandas.DataFrame, xarray.Dataset, or geo...
420420
Pass in either a file name to an ASCII data table, a 2-D
421421
:class:`numpy.ndarray`, a :class:`pandas.DataFrame`, an
422422
:class:`xarray.Dataset` made up of 1-D :class:`xarray.DataArray`
@@ -444,13 +444,15 @@ def fmt_docstring(module_func):
444444
aliases.append(f"- {arg} = {alias}")
445445
filler_text["aliases"] = "\n".join(aliases)
446446

447-
filler_text["table-like"] = " or ".join(
448-
[
449-
"numpy.ndarray",
450-
"pandas.DataFrame",
451-
"xarray.Dataset",
452-
"geopandas.GeoDataFrame",
453-
]
447+
filler_text["table-like"] = (
448+
", ".join(
449+
[
450+
"numpy.ndarray",
451+
"pandas.DataFrame",
452+
"xarray.Dataset",
453+
]
454+
)
455+
+ ", or geopandas.GeoDataFrame"
454456
)
455457
filler_text["table-classes"] = (
456458
":class:`numpy.ndarray`, a :class:`pandas.DataFrame`, an\n"

pygmt/src/binstats.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def binstats(data, **kwargs):
4848
4949
Parameters
5050
----------
51-
data : str or {table-like}
51+
data : str, {table-like}
5252
A file name of an ASCII data table or a 2-D
5353
{table-classes}.
5454
outgrid : str or None
@@ -78,7 +78,7 @@ def binstats(data, **kwargs):
7878
- **u** for maximum (upper)
7979
- **U** for maximum of negative values only
8080
- **z** for the sum
81-
empty : float or int
81+
empty : float
8282
Set the value assigned to empty nodes [Default is NaN].
8383
normalize : bool
8484
Normalize the resulting grid values by the area represented by the

pygmt/src/blockm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def blockmean(data=None, x=None, y=None, z=None, outfile=None, **kwargs):
105105
106106
Parameters
107107
----------
108-
data : str or {table-like}
108+
data : str, {table-like}
109109
Pass in (x, y, z) or (longitude, latitude, elevation) values by
110110
providing a file name to an ASCII data table, a 2-D
111111
{table-classes}.
@@ -201,7 +201,7 @@ def blockmedian(data=None, x=None, y=None, z=None, outfile=None, **kwargs):
201201
202202
Parameters
203203
----------
204-
data : str or {table-like}
204+
data : str, {table-like}
205205
Pass in (x, y, z) or (longitude, latitude, elevation) values by
206206
providing a file name to an ASCII data table, a 2-D
207207
{table-classes}.
@@ -288,7 +288,7 @@ def blockmode(data=None, x=None, y=None, z=None, outfile=None, **kwargs):
288288
289289
Parameters
290290
----------
291-
data : str or {table-like}
291+
data : str, {table-like}
292292
Pass in (x, y, z) or (longitude, latitude, elevation) values by
293293
providing a file name to an ASCII data table, a 2-D
294294
{table-classes}.

pygmt/src/coast.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def coast(self, **kwargs):
8181
and (**c**\ )rude.
8282
land : str
8383
Select filling or clipping of "dry" areas.
84-
rivers : int or str or list
84+
rivers : int, str, or list
8585
*river*\ [/*pen*].
8686
Draw rivers. Specify the type of rivers and [optionally] append
8787
pen attributes [Default is ``"0.25p,black,solid"``].
@@ -128,7 +128,7 @@ def coast(self, **kwargs):
128128
[**g**\|\ **j**\|\ **J**\|\ **n**\|\ **x**]\ *refpoint*\
129129
**+w**\ *length*.
130130
Draw a simple map scale centered on the reference point specified.
131-
borders : int or str or list
131+
borders : int, str, or list
132132
*border*\ [/*pen*].
133133
Draw political boundaries. Specify the type of boundary and
134134
[optionally] append pen attributes
@@ -146,7 +146,7 @@ def coast(self, **kwargs):
146146
a = All boundaries (1-3)
147147
water : str
148148
Select filling or clipping of "wet" areas.
149-
shorelines : int or str or list
149+
shorelines : int, str, or list
150150
[*level*\ /]\ *pen*.
151151
Draw shorelines [Default is no shorelines]. Append pen attributes
152152
[Default is ``"0.25p,black,solid"``] which

pygmt/src/colorbar.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ def colorbar(self, **kwargs):
9696
scale : float
9797
Multiply all z-values in the CPT by the provided scale. By default,
9898
the CPT is used as is.
99-
shading : str or list or bool
99+
shading : str, list, or bool
100100
Add illumination effects. Passing a single numerical value sets the
101101
range of intensities from -value to +value. If not specified, 1 is
102102
used. Alternatively, set ``shading=[low, high]`` to specify an
103103
asymmetric intensity range from *low* to *high*. [Default is no
104104
illumination].
105-
equalsize : int or float or str
105+
equalsize : float or str
106106
[**i**]\ [*gap*].
107107
Equal-sized color rectangles. By default, the rectangles are scaled
108108
according to the z-range in the CPT (see also ``zfile``). If *gap* is

pygmt/src/contour.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def contour(self, data=None, x=None, y=None, z=None, **kwargs):
4646
4747
Parameters
4848
----------
49-
data : str or {table-like}
49+
data : str, {table-like}
5050
Pass in (x, y, z) or (longitude, latitude, elevation) values by
5151
providing a file name to an ASCII data table, a 2-D
5252
{table-classes}.

pygmt/src/grd2cpt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def grd2cpt(grid, **kwargs):
110110
*start*, where we automatically build monotonically increasing
111111
labels from *start* (a single letter or an integer). Additionally
112112
append **-** to build ranges *start*-*start+1* as labels instead.
113-
nlevels : bool or int or str
113+
nlevels : bool, int, or str
114114
Set to ``True`` to create a linear color table by using the grid
115115
z-range as the new limits in the CPT. Alternatively, set *nlevels*
116116
to resample the color table into *nlevels* equidistant slices.

pygmt/src/grdclip.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ def grdclip(grid, **kwargs):
5656
The name of the output netCDF file with extension .nc to store the grid
5757
in.
5858
{region}
59-
above : str or list or tuple
59+
above : str or list
6060
[*high*, *above*].
6161
Set all data[i] > *high* to *above*.
62-
below : str or list or tuple
62+
below : str or list
6363
[*low*, *below*].
6464
Set all data[i] < *low* to *below*.
65-
between : str or list or tuple
65+
between : str or list
6666
[*low*, *high*, *between*].
6767
Set all data[i] >= *low* and <= *high* to *between*.
68-
new : str or list or tuple
68+
new : str or list
6969
[*old*, *new*].
7070
Set all data[i] == *old* to *new*. This is mostly useful when
7171
your data are known to be integer values.

pygmt/src/grdcontour.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def grdcontour(self, grid, **kwargs):
5353
angle (col 3).
5454
- A fixed contour interval *cont_int* or a single contour with
5555
+\ *cont_int*.
56-
annotation : str, int, or list
56+
annotation : str, int, or list
5757
Specify or disable annotated contour levels, modifies annotated
5858
contours specified in ``interval``.
5959

pygmt/src/grdcut.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def grdcut(grid, **kwargs):
5353
in.
5454
{projection}
5555
{region}
56-
extend : bool or int or float
56+
extend : bool or float
5757
Allow grid to be extended if new ``region`` exceeds existing
5858
boundaries. Give a value to initialize nodes outside current region.
5959
circ_subregion : str

0 commit comments

Comments
 (0)