Skip to content

Commit f56c922

Browse files
authored
AliasSystem: Migrate the 'frame' parameter to the new alias system (#4196)
1 parent 8e6e4f5 commit f56c922

File tree

20 files changed

+64
-28
lines changed

20 files changed

+64
-28
lines changed

pygmt/alias.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ def add_common(self, **kwargs):
307307
"""
308308
for key, value in kwargs.items():
309309
match key:
310+
case "B":
311+
alias = Alias(value, name="frame")
310312
case "J":
311313
alias = Alias(value, name="projection")
312314
case "R":

pygmt/src/basemap.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
@use_alias(
1515
Jz="zscale",
1616
JZ="zsize",
17-
B="frame",
1817
L="map_scale",
1918
F="box",
2019
Td="rose",
@@ -26,6 +25,7 @@
2625
def basemap(
2726
self,
2827
projection: str | None = None,
28+
frame: str | Sequence[str] | bool = False,
2929
region: Sequence[float | str] | str | None = None,
3030
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
3131
| bool = False,
@@ -47,6 +47,7 @@ def basemap(
4747
Full GMT docs at :gmt-docs:`basemap.html`.
4848
4949
{aliases}
50+
- B = frame
5051
- J = projection
5152
- R = region
5253
- V = verbose
@@ -98,6 +99,7 @@ def basemap(
9899
self._activate_figure()
99100

100101
aliasdict = AliasSystem().add_common(
102+
B=frame,
101103
J=projection,
102104
R=region,
103105
V=verbose,

pygmt/src/coast.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
@fmt_docstring
2424
@use_alias(
2525
A="area_thresh",
26-
B="frame",
2726
C="lakes",
2827
E="dcw",
2928
G="land",
@@ -37,11 +36,12 @@
3736
@kwargs_to_strings(p="sequence")
3837
def coast(
3938
self,
40-
projection: str | None = None,
4139
resolution: Literal[
4240
"auto", "full", "high", "intermediate", "low", "crude", None
4341
] = None,
4442
box: Box | bool = False,
43+
projection: str | None = None,
44+
frame: str | Sequence[str] | bool = False,
4545
region: Sequence[float | str] | str | None = None,
4646
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
4747
| bool = False,
@@ -69,6 +69,7 @@ def coast(
6969
Full GMT docs at :gmt-docs:`coast.html`.
7070
7171
{aliases}
72+
- B = frame
7273
- D = resolution
7374
- F = box
7475
- J = projection
@@ -223,6 +224,7 @@ def coast(
223224
),
224225
F=Alias(box, name="box"),
225226
).add_common(
227+
B=frame,
226228
J=projection,
227229
R=region,
228230
V=verbose,

pygmt/src/colorbar.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
@fmt_docstring
1717
@use_alias(
18-
B="frame",
1918
C="cmap",
2019
D="position",
2120
G="truncate",
@@ -31,6 +30,7 @@ def colorbar(
3130
shading: float | Sequence[float] | bool = False,
3231
projection: str | None = None,
3332
box: Box | bool = False,
33+
frame: str | Sequence[str] | bool = False,
3434
region: Sequence[float | str] | str | None = None,
3535
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
3636
| bool = False,
@@ -63,6 +63,7 @@ def colorbar(
6363
Full GMT docs at :gmt-docs:`colorbar.html`.
6464
6565
{aliases}
66+
- B = frame
6667
- F = box
6768
- I = shading
6869
- J = projection
@@ -167,6 +168,7 @@ def colorbar(
167168
F=Alias(box, name="box"),
168169
I=Alias(shading, name="shading", sep="/", size=2),
169170
).add_common(
171+
B=frame,
170172
J=projection,
171173
R=region,
172174
V=verbose,

pygmt/src/contour.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
@fmt_docstring
2121
@use_alias(
2222
A="annotation",
23-
B="frame",
2423
C="levels",
2524
G="label_placement",
2625
L="triangular_mesh_pen",
@@ -44,6 +43,7 @@ def contour( # noqa: PLR0913
4443
z=None,
4544
no_clip: bool = False,
4645
projection: str | None = None,
46+
frame: str | Sequence[str] | bool = False,
4747
region: Sequence[float | str] | str | None = None,
4848
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
4949
| bool = False,
@@ -62,6 +62,7 @@ def contour( # noqa: PLR0913
6262
Full GMT docs at :gmt-docs:`contour.html`.
6363
6464
{aliases}
65+
- B = frame
6566
- J = projection
6667
- N = no_clip
6768
- R = region
@@ -165,6 +166,7 @@ def contour( # noqa: PLR0913
165166
aliasdict = AliasSystem(
166167
N=Alias(no_clip, name="no_clip"),
167168
).add_common(
169+
B=frame,
168170
J=projection,
169171
R=region,
170172
V=verbose,

pygmt/src/grdcontour.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
@deprecate_parameter("interval", "levels", "v0.12.0", remove_version="v0.16.0")
2626
@use_alias(
2727
A="annotation",
28-
B="frame",
2928
C="levels",
3029
G="label_placement",
3130
L="limit",
@@ -41,6 +40,7 @@ def grdcontour(
4140
self,
4241
grid: PathLike | xr.DataArray,
4342
projection: str | None = None,
43+
frame: str | Sequence[str] | bool = False,
4444
region: Sequence[float | str] | str | None = None,
4545
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
4646
| bool = False,
@@ -56,6 +56,7 @@ def grdcontour(
5656
Full GMT docs at :gmt-docs:`grdcontour.html`.
5757
5858
{aliases}
59+
- B = frame
5960
- J = projection
6061
- R = region
6162
- V = verbose
@@ -166,6 +167,7 @@ def grdcontour(
166167
kwargs[arg] = ",".join(f"{item}" for item in kwargs[arg])
167168

168169
aliasdict = AliasSystem().add_common(
170+
B=frame,
169171
J=projection,
170172
R=region,
171173
V=verbose,

pygmt/src/grdimage.py

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

1717
@fmt_docstring
1818
@use_alias(
19-
B="frame",
2019
C="cmap",
2120
D="img_in",
2221
E="dpi",
@@ -28,12 +27,13 @@
2827
p="perspective",
2928
)
3029
@kwargs_to_strings(p="sequence")
31-
def grdimage(
30+
def grdimage( # noqa: PLR0913
3231
self,
3332
grid: PathLike | xr.DataArray,
3433
monochrome: bool = False,
3534
no_clip: bool = False,
3635
projection: str | None = None,
36+
frame: str | Sequence[str] | bool = False,
3737
region: Sequence[float | str] | str | None = None,
3838
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
3939
| bool = False,
@@ -76,6 +76,7 @@ def grdimage(
7676
Full GMT docs at :gmt-docs:`grdimage.html`.
7777
7878
{aliases}
79+
- B = frame
7980
- J = projection
8081
- M = monochrome
8182
- N = no_clip
@@ -181,6 +182,7 @@ def grdimage(
181182
M=Alias(monochrome, name="monochrome"),
182183
N=Alias(no_clip, name="no_clip"),
183184
).add_common(
185+
B=frame,
184186
J=projection,
185187
R=region,
186188
V=verbose,

pygmt/src/grdview.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
@use_alias(
1919
Jz="zscale",
2020
JZ="zsize",
21-
B="frame",
2221
C="cmap",
2322
G="drapegrid",
2423
N="plane",
@@ -36,6 +35,7 @@ def grdview(
3635
self,
3736
grid: PathLike | xr.DataArray,
3837
projection: str | None = None,
38+
frame: str | Sequence[str] | bool = False,
3939
region: Sequence[float | str] | str | None = None,
4040
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
4141
| bool = False,
@@ -55,6 +55,7 @@ def grdview(
5555
Full GMT docs at :gmt-docs:`grdview.html`.
5656
5757
{aliases}
58+
- B = frame
5859
- J = projection
5960
- R = region
6061
- V = verbose
@@ -157,6 +158,7 @@ def grdview(
157158
self._activate_figure()
158159

159160
aliasdict = AliasSystem().add_common(
161+
B=frame,
160162
J=projection,
161163
R=region,
162164
V=verbose,

pygmt/src/histogram.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
@fmt_docstring
1515
@use_alias(
1616
A="horizontal",
17-
B="frame",
1817
C="cmap",
1918
D="annotate",
2019
E="barwidth",
@@ -41,6 +40,7 @@ def histogram(
4140
self,
4241
data: PathLike | TableLike,
4342
projection: str | None = None,
43+
frame: str | Sequence[str] | bool = False,
4444
region: Sequence[float | str] | str | None = None,
4545
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
4646
| bool = False,
@@ -54,6 +54,7 @@ def histogram(
5454
Full GMT docs at :gmt-docs:`histogram.html`.
5555
5656
{aliases}
57+
- B = frame
5758
- J = projection
5859
- R = region
5960
- V = verbose
@@ -150,6 +151,7 @@ def histogram(
150151
self._activate_figure()
151152

152153
aliasdict = AliasSystem().add_common(
154+
B=frame,
153155
J=projection,
154156
R=region,
155157
V=verbose,

pygmt/src/meca.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ def _auto_offset(spec) -> bool:
118118
@fmt_docstring
119119
@use_alias(
120120
A="offset",
121-
B="frame",
122121
C="cmap",
123122
E="extensionfill",
124123
Fr="labelbox",
@@ -143,6 +142,7 @@ def meca( # noqa: PLR0913
143142
event_name: str | Sequence[str] | None = None,
144143
no_clip: bool = False,
145144
projection: str | None = None,
145+
frame: str | Sequence[str] | bool = False,
146146
region: Sequence[float | str] | str | None = None,
147147
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
148148
| bool = False,
@@ -202,6 +202,7 @@ def meca( # noqa: PLR0913
202202
Full GMT docs at :gmt-docs:`supplements/seis/meca.html`.
203203
204204
{aliases}
205+
- B = frame
205206
- J = projection
206207
- N = no_clip
207208
- R = region
@@ -374,6 +375,7 @@ def meca( # noqa: PLR0913
374375
aliasdict = AliasSystem(
375376
N=Alias(no_clip, name="no_clip"),
376377
).add_common(
378+
B=frame,
377379
J=projection,
378380
R=region,
379381
V=verbose,

0 commit comments

Comments
 (0)