Skip to content

Commit ae4584c

Browse files
authored
Consistently pass keyword arguments when using call_module() (#1910)
1 parent 4e8e4cf commit ae4584c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+96
-54
lines changed

pygmt/figure.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def _activate_figure(self):
104104
# Passing format '-' tells pygmt.end to not produce any files.
105105
fmt = "-"
106106
with Session() as lib:
107-
lib.call_module("figure", f"{self._name} {fmt}")
107+
lib.call_module(module="figure", args=f"{self._name} {fmt}")
108108

109109
def _preprocess(self, **kwargs):
110110
"""
@@ -245,7 +245,9 @@ def psconvert(self, icc_gray=False, **kwargs):
245245
raise GMTInvalidInput("The 'prefix' must be specified.") from err
246246

247247
with Session() as lib:
248-
lib.call_module("psconvert", f"{prefix_arg} {build_arg_string(kwargs)}")
248+
lib.call_module(
249+
module="psconvert", args=f"{prefix_arg} {build_arg_string(kwargs)}"
250+
)
249251

250252
def savefig(
251253
self, fname, transparent=False, crop=True, anti_alias=True, show=False, **kwargs
@@ -421,7 +423,7 @@ def shift_origin(self, xshift=None, yshift=None):
421423
args.append(f"-Y{yshift}")
422424

423425
with Session() as lib:
424-
lib.call_module("plot", " ".join(args))
426+
lib.call_module(module="plot", args=" ".join(args))
425427

426428
def _preview(self, fmt, dpi, as_bytes=False, **kwargs):
427429
"""

pygmt/session_management.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ def begin():
1414
"""
1515
prefix = "pygmt-session"
1616
with Session() as lib:
17-
lib.call_module("begin", prefix)
17+
lib.call_module(module="begin", args=prefix)
1818
# pygmt relies on GMT modern mode with GMT_COMPATIBILITY at version 6
19-
lib.call_module("set", "GMT_COMPATIBILITY 6")
19+
lib.call_module(module="set", args="GMT_COMPATIBILITY 6")
2020

2121

2222
def end():
@@ -29,4 +29,4 @@ def end():
2929
``pygmt.begin``), and bring the figures to the working directory.
3030
"""
3131
with Session() as lib:
32-
lib.call_module("end", "")
32+
lib.call_module(module="end", args="")

pygmt/src/basemap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,4 @@ def basemap(self, **kwargs):
9494
if not args_in_kwargs(args=["B", "L", "Td", "Tm", "c"], kwargs=kwargs):
9595
kwargs["B"] = True # Plotting frames if required arguments not given
9696
with Session() as lib:
97-
lib.call_module("basemap", build_arg_string(kwargs))
97+
lib.call_module(module="basemap", args=build_arg_string(kwargs))

pygmt/src/coast.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,4 +189,4 @@ def coast(self, **kwargs):
189189
lakes, land, water, rivers, borders, dcw, Q, or shorelines"""
190190
)
191191
with Session() as lib:
192-
lib.call_module("coast", build_arg_string(kwargs))
192+
lib.call_module(module="coast", args=build_arg_string(kwargs))

pygmt/src/colorbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,4 @@ def colorbar(self, **kwargs):
107107
"""
108108
kwargs = self._preprocess(**kwargs) # pylint: disable=protected-access
109109
with Session() as lib:
110-
lib.call_module("colorbar", build_arg_string(kwargs))
110+
lib.call_module(module="colorbar", args=build_arg_string(kwargs))

pygmt/src/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __init__(self, **kwargs):
5757
# call gmt set to change GMT defaults
5858
arg_str = " ".join([f'{key}="{value}"' for key, value in kwargs.items()])
5959
with Session() as lib:
60-
lib.call_module("set", arg_str)
60+
lib.call_module(module="set", args=arg_str)
6161

6262
def __enter__(self):
6363
return self
@@ -68,4 +68,4 @@ def __exit__(self, exc_type, exc_value, traceback):
6868
[f"{key}={value}" for key, value in self.old_defaults.items()]
6969
)
7070
with Session() as lib:
71-
lib.call_module("set", arg_str)
71+
lib.call_module(module="set", args=arg_str)

pygmt/src/contour.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,6 @@ def contour(self, data=None, x=None, y=None, z=None, **kwargs):
132132
check_kind="vector", data=data, x=x, y=y, z=z, required_z=True
133133
)
134134
with file_context as fname:
135-
lib.call_module("contour", build_arg_string(kwargs, infile=fname))
135+
lib.call_module(
136+
module="contour", args=build_arg_string(kwargs, infile=fname)
137+
)

pygmt/src/dimfilter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,6 @@ def dimfilter(grid, **kwargs):
139139
kwargs.update({"G": tmpfile.name})
140140
outgrid = kwargs["G"]
141141
arg_str = " ".join([infile, build_arg_string(kwargs)])
142-
lib.call_module("dimfilter", arg_str)
142+
lib.call_module(module="dimfilter", args=arg_str)
143143

144144
return load_dataarray(outgrid) if outgrid == tmpfile.name else None

pygmt/src/grd2cpt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,4 @@ def grd2cpt(grid, **kwargs):
172172
if not outfile or not isinstance(outfile, str):
173173
raise GMTInvalidInput("'output' should be a proper file name.")
174174
arg_str = build_arg_string(kwargs, infile=infile, outfile=outfile)
175-
lib.call_module("grd2cpt", arg_str)
175+
lib.call_module(module="grd2cpt", args=arg_str)

pygmt/src/grd2xyz.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ def grd2xyz(grid, output_type="pandas", outfile=None, **kwargs):
179179
if outfile is None:
180180
outfile = tmpfile.name
181181
lib.call_module(
182-
"grd2xyz", build_arg_string(kwargs, infile=infile, outfile=outfile)
182+
module="grd2xyz",
183+
args=build_arg_string(kwargs, infile=infile, outfile=outfile),
183184
)
184185

185186
# Read temporary csv output to a pandas table

0 commit comments

Comments
 (0)