Skip to content

Commit 8f96038

Browse files
committed
AliasSystem: Migrate the 'incols' parameter to the new alias system
1 parent dc6fd38 commit 8f96038

File tree

16 files changed

+78
-51
lines changed

16 files changed

+78
-51
lines changed

pygmt/alias.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def __init__(self, **kwargs):
301301
kwdict[option] = aliases._value
302302
super().__init__(kwdict)
303303

304-
def add_common(self, **kwargs):
304+
def add_common(self, **kwargs): # noqa: PLR0912
305305
"""
306306
Add common parameters to the alias dictionary.
307307
"""
@@ -329,6 +329,8 @@ def add_common(self, **kwargs):
329329
)
330330
case "c":
331331
alias = Alias(value, name="panel", sep=",", size=2)
332+
case "i":
333+
alias = Alias(value, name="incols", sep=",")
332334
case "r":
333335
alias = Alias(
334336
value,

pygmt/src/binstats.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
a="aspatial",
2323
b="binary",
2424
h="header",
25-
i="incols",
2625
)
27-
@kwargs_to_strings(I="sequence", i="sequence_comma")
26+
@kwargs_to_strings(I="sequence")
2827
def binstats(
2928
data: PathLike | TableLike,
3029
outgrid: PathLike | None = None,
@@ -51,6 +50,7 @@ def binstats(
5150
registration: Literal["gridline", "pixel"] | bool = False,
5251
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
5352
| bool = False,
53+
incols: int | str | Sequence[int | str] | None = None,
5454
**kwargs,
5555
) -> xr.DataArray | None:
5656
r"""
@@ -70,6 +70,7 @@ def binstats(
7070
- C = statistic
7171
- R = region
7272
- V = verbose
73+
- i = incols
7374
- r = registration
7475
7576
Parameters
@@ -159,6 +160,7 @@ def binstats(
159160
).add_common(
160161
R=region,
161162
V=verbose,
163+
i=incols,
162164
r=registration,
163165
)
164166
aliasdict.merge(kwargs)

pygmt/src/blockm.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,10 @@ def _blockm(
8181
e="find",
8282
f="coltypes",
8383
h="header",
84-
i="incols",
8584
o="outcols",
8685
w="wrap",
8786
)
88-
@kwargs_to_strings(I="sequence", i="sequence_comma", o="sequence_comma")
87+
@kwargs_to_strings(I="sequence", o="sequence_comma")
8988
def blockmean(
9089
data: PathLike | TableLike | None = None,
9190
x=None,
@@ -97,6 +96,7 @@ def blockmean(
9796
registration: Literal["gridline", "pixel"] | bool = False,
9897
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
9998
| bool = False,
99+
incols: int | str | Sequence[int | str] | None = None,
100100
**kwargs,
101101
) -> pd.DataFrame | np.ndarray | None:
102102
r"""
@@ -116,6 +116,7 @@ def blockmean(
116116
{aliases}
117117
- R = region
118118
- V = verbose
119+
- i = incols
119120
- r = registration
120121
121122
Parameters
@@ -171,6 +172,7 @@ def blockmean(
171172
aliasdict = AliasSystem().add_common(
172173
R=region,
173174
V=verbose,
175+
i=incols,
174176
r=registration,
175177
)
176178
aliasdict.merge(kwargs)
@@ -196,11 +198,10 @@ def blockmean(
196198
e="find",
197199
f="coltypes",
198200
h="header",
199-
i="incols",
200201
o="outcols",
201202
w="wrap",
202203
)
203-
@kwargs_to_strings(I="sequence", i="sequence_comma", o="sequence_comma")
204+
@kwargs_to_strings(I="sequence", o="sequence_comma")
204205
def blockmedian(
205206
data: PathLike | TableLike | None = None,
206207
x=None,
@@ -212,6 +213,7 @@ def blockmedian(
212213
registration: Literal["gridline", "pixel"] | bool = False,
213214
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
214215
| bool = False,
216+
incols: int | str | Sequence[int | str] | None = None,
215217
**kwargs,
216218
) -> pd.DataFrame | np.ndarray | None:
217219
r"""
@@ -231,6 +233,7 @@ def blockmedian(
231233
{aliases}
232234
- R = region
233235
- V = verbose
236+
- i = incols
234237
- r = registration
235238
236239
Parameters
@@ -280,6 +283,7 @@ def blockmedian(
280283
aliasdict = AliasSystem().add_common(
281284
R=region,
282285
V=verbose,
286+
i=incols,
283287
r=registration,
284288
)
285289
aliasdict.merge(kwargs)
@@ -305,11 +309,10 @@ def blockmedian(
305309
e="find",
306310
f="coltypes",
307311
h="header",
308-
i="incols",
309312
o="outcols",
310313
w="wrap",
311314
)
312-
@kwargs_to_strings(I="sequence", i="sequence_comma", o="sequence_comma")
315+
@kwargs_to_strings(I="sequence", o="sequence_comma")
313316
def blockmode(
314317
data: PathLike | TableLike | None = None,
315318
x=None,
@@ -321,6 +324,7 @@ def blockmode(
321324
registration: Literal["gridline", "pixel"] | bool = False,
322325
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
323326
| bool = False,
327+
incols: int | str | Sequence[int | str] | None = None,
324328
**kwargs,
325329
) -> pd.DataFrame | np.ndarray | None:
326330
r"""
@@ -340,6 +344,7 @@ def blockmode(
340344
{aliases}
341345
- R = region
342346
- V = verbose
347+
- i = incols
343348
- r = registration
344349
345350
Parameters
@@ -387,6 +392,7 @@ def blockmode(
387392
aliasdict = AliasSystem().add_common(
388393
R=region,
389394
V=verbose,
395+
i=incols,
390396
r=registration,
391397
)
392398
aliasdict.merge(kwargs)

pygmt/src/contour.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
build_arg_list,
1313
fmt_docstring,
1414
is_nonstr_iter,
15-
kwargs_to_strings,
1615
use_alias,
1716
)
1817

@@ -30,10 +29,8 @@
3029
e="find",
3130
f="coltypes",
3231
h="header",
33-
i="incols",
3432
l="label",
3533
)
36-
@kwargs_to_strings(i="sequence_comma")
3734
def contour( # noqa: PLR0913
3835
self,
3936
data: PathLike | TableLike | None = None,
@@ -49,6 +46,7 @@ def contour( # noqa: PLR0913
4946
panel: int | Sequence[int] | bool = False,
5047
transparency: float | None = None,
5148
perspective: float | Sequence[float] | str | bool = False,
49+
incols: int | str | Sequence[int | str] | None = None,
5250
**kwargs,
5351
):
5452
r"""
@@ -68,6 +66,7 @@ def contour( # noqa: PLR0913
6866
- R = region
6967
- V = verbose
7068
- c = panel
69+
- i = incols
7170
- p = perspective
7271
- t = transparency
7372
@@ -172,6 +171,7 @@ def contour( # noqa: PLR0913
172171
R=region,
173172
V=verbose,
174173
c=panel,
174+
i=incols,
175175
p=perspective,
176176
t=transparency,
177177
)

pygmt/src/grdtrack.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@
4141
f="coltypes",
4242
g="gap",
4343
h="header",
44-
i="incols",
4544
j="distcalc",
4645
n="interpolation",
4746
o="outcols",
4847
s="skiprows",
4948
w="wrap",
5049
)
51-
@kwargs_to_strings(S="sequence", i="sequence_comma", o="sequence_comma")
50+
@kwargs_to_strings(S="sequence", o="sequence_comma")
5251
def grdtrack(
5352
grid: PathLike | xr.DataArray,
5453
points: PathLike | TableLike | None = None,
@@ -58,6 +57,7 @@ def grdtrack(
5857
region: Sequence[float | str] | str | None = None,
5958
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
6059
| bool = False,
60+
incols: int | str | Sequence[int | str] | None = None,
6161
**kwargs,
6262
) -> pd.DataFrame | np.ndarray | None:
6363
r"""
@@ -82,6 +82,7 @@ def grdtrack(
8282
{aliases}
8383
- R = region
8484
- V = verbose
85+
- i = incols
8586
8687
Parameters
8788
----------
@@ -317,6 +318,7 @@ def grdtrack(
317318
aliasdict = AliasSystem().add_common(
318319
R=region,
319320
V=verbose,
321+
i=incols,
320322
)
321323
aliasdict.merge(kwargs)
322324

pygmt/src/histogram.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@
3030
d="nodata",
3131
e="find",
3232
h="header",
33-
i="incols",
3433
l="label",
3534
w="wrap",
3635
)
37-
@kwargs_to_strings(T="sequence", i="sequence_comma")
36+
@kwargs_to_strings(T="sequence")
3837
def histogram(
3938
self,
4039
data: PathLike | TableLike,
@@ -46,6 +45,7 @@ def histogram(
4645
panel: int | Sequence[int] | bool = False,
4746
transparency: float | None = None,
4847
perspective: float | Sequence[float] | str | bool = False,
48+
incols: int | str | Sequence[int | str] | None = None,
4949
**kwargs,
5050
):
5151
r"""
@@ -59,6 +59,7 @@ def histogram(
5959
- R = region
6060
- V = verbose
6161
- c = panel
62+
- i = incols
6263
- p = perspective
6364
- t = transparency
6465
@@ -157,6 +158,7 @@ def histogram(
157158
R=region,
158159
V=verbose,
159160
c=panel,
161+
i=incols,
160162
p=perspective,
161163
t=transparency,
162164
)

pygmt/src/info.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
info - Get information about data tables.
33
"""
44

5+
from collections.abc import Sequence
56
from typing import Literal
67

78
import numpy as np
@@ -19,19 +20,15 @@
1920

2021
@fmt_docstring
2122
@use_alias(
22-
C="per_column",
23-
I="spacing",
24-
T="nearest_multiple",
25-
a="aspatial",
26-
f="coltypes",
27-
i="incols",
23+
C="per_column", I="spacing", T="nearest_multiple", a="aspatial", f="coltypes"
2824
)
29-
@kwargs_to_strings(I="sequence", i="sequence_comma")
25+
@kwargs_to_strings(I="sequence")
3026
def info(
3127
data: PathLike | TableLike,
3228
registration: Literal["gridline", "pixel"] | bool = False,
3329
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
3430
| bool = False,
31+
incols: int | str | Sequence[int | str] | None = None,
3532
**kwargs,
3633
) -> np.ndarray | str:
3734
r"""
@@ -54,6 +51,7 @@ def info(
5451
5552
{aliases}
5653
- V = verbose
54+
- i = incols
5755
- r = registration
5856
5957
Parameters
@@ -92,6 +90,7 @@ def info(
9290
"""
9391
aliasdict = AliasSystem().add_common(
9492
V=verbose,
93+
i=incols,
9594
r=registration,
9695
)
9796
aliasdict.merge(kwargs)

pygmt/src/nearneighbor.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727
f="coltypes",
2828
g="gap",
2929
h="header",
30-
i="incols",
3130
w="wrap",
3231
)
33-
@kwargs_to_strings(I="sequence", i="sequence_comma")
32+
@kwargs_to_strings(I="sequence")
3433
def nearneighbor(
3534
data: PathLike | TableLike | None = None,
3635
x=None,
@@ -41,6 +40,7 @@ def nearneighbor(
4140
registration: Literal["gridline", "pixel"] | bool = False,
4241
verbose: Literal["quiet", "error", "warning", "timing", "info", "compat", "debug"]
4342
| bool = False,
43+
incols: int | str | Sequence[int | str] | None = None,
4444
**kwargs,
4545
) -> xr.DataArray | None:
4646
r"""
@@ -82,6 +82,7 @@ def nearneighbor(
8282
{aliases}
8383
- R = region
8484
- V = verbose
85+
- i = incols
8586
- r = registration
8687
8788
Parameters
@@ -155,6 +156,7 @@ def nearneighbor(
155156
aliasdict = AliasSystem().add_common(
156157
R=region,
157158
V=verbose,
159+
i=incols,
158160
r=registration,
159161
)
160162
aliasdict.merge(kwargs)

0 commit comments

Comments
 (0)