Skip to content

Migrate the 'panel' parameter to the new alias system #4030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pygmt/src/basemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@
Td="rose",
Tm="compass",
V="verbose",
c="panel",
f="coltypes",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
def basemap(self, projection=None, **kwargs):
@kwargs_to_strings(R="sequence", p="sequence")
def basemap(self, projection=None, panel=None, **kwargs):
r"""
Plot base maps and frames.

Expand All @@ -40,6 +39,7 @@ def basemap(self, projection=None, **kwargs):

{aliases}
- J=projection
- c=panel

Parameters
----------
Expand Down Expand Up @@ -86,6 +86,7 @@ def basemap(self, projection=None, **kwargs):
self._activate_figure()
aliasdict = AliasSystem(
J=Alias(projection, name="projection"),
c=Alias(panel, name="panel", sep=",", size=2),
Copy link
Member Author

@seisman seisman Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm considering if we should define a function like:

def common_alias(value, name):
    match name:
        case "projection":
            return Alias(value, name="projection")
        case "panel":
            return Alias(value, name="panel", sep=",", size=2)

then in wrappers, we can use it like:

from pygmt.alias import common_alias
aliasdict = AliasSystem(
    J=common_alias(projection, name="projection"),
    c=common_alias(panel, name="panel"),
)

so that we don't have to repeat alias(panel, name="panel", sep=",", size=2), in all wrappers.

).merge(kwargs)
with Session() as lib:
lib.call_module(module="basemap", args=build_arg_list(aliasdict))
6 changes: 4 additions & 2 deletions pygmt/src/coast.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@
S="water",
V="verbose",
W="shorelines",
c="panel",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
@kwargs_to_strings(R="sequence", p="sequence")
def coast(
self,
projection=None,
resolution: Literal[
"auto", "full", "high", "intermediate", "low", "crude", None
] = None,
panel=None,
**kwargs,
):
r"""
Expand All @@ -69,6 +69,7 @@ def coast(

{aliases}
- J=projection
- c=panel

Parameters
----------
Expand Down Expand Up @@ -218,6 +219,7 @@ def coast(

aliasdict = AliasSystem(
J=Alias(projection, name="projection"),
c=Alias(panel, name="panel", sep=",", size=2),
).merge(kwargs)

with Session() as lib:
Expand Down
9 changes: 4 additions & 5 deletions pygmt/src/colorbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,11 @@
V="verbose",
W="scale",
Z="zfile",
c="panel",
p="perspective",
t="transparency",
)
@kwargs_to_strings(
R="sequence", G="sequence", I="sequence", c="sequence_comma", p="sequence"
)
def colorbar(self, projection=None, **kwargs):
@kwargs_to_strings(R="sequence", G="sequence", I="sequence", p="sequence")
def colorbar(self, projection=None, panel=None, **kwargs):
r"""
Plot gray scale or color scale bar.

Expand All @@ -46,6 +43,7 @@ def colorbar(self, projection=None, **kwargs):

{aliases}
- J=projection
- c=panel

Parameters
----------
Expand Down Expand Up @@ -149,6 +147,7 @@ def colorbar(self, projection=None, **kwargs):

aliasdict = AliasSystem(
J=Alias(projection, name="projection"),
c=Alias(panel, name="panel", sep=",", size=2),
).merge(kwargs)
with Session() as lib:
lib.call_module(module="colorbar", args=build_arg_list(aliasdict))
6 changes: 4 additions & 2 deletions pygmt/src/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
V="verbose",
W="pen",
b="binary",
c="panel",
d="nodata",
e="find",
f="coltypes",
Expand All @@ -37,14 +36,15 @@
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", c="sequence_comma", i="sequence_comma", p="sequence")
@kwargs_to_strings(R="sequence", i="sequence_comma", p="sequence")
def contour(
self,
data: PathLike | TableLike | None = None,
x=None,
y=None,
z=None,
projection=None,
panel=None,
**kwargs,
):
r"""
Expand All @@ -59,6 +59,7 @@ def contour(

{aliases}
- J=projection
- c=panel

Parameters
----------
Expand Down Expand Up @@ -155,6 +156,7 @@ def contour(

aliasdict = AliasSystem(
J=Alias(projection, name="projection"),
c=Alias(panel, name="panel", sep=",", size=2),
).merge(kwargs)

with Session() as lib:
Expand Down
9 changes: 6 additions & 3 deletions pygmt/src/grdcontour.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@
V="verbose",
W="pen",
l="label",
c="panel",
f="coltypes",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", L="sequence", c="sequence_comma", p="sequence")
def grdcontour(self, grid: PathLike | xr.DataArray, projection=None, **kwargs):
@kwargs_to_strings(R="sequence", L="sequence", p="sequence")
def grdcontour(
self, grid: PathLike | xr.DataArray, projection=None, panel=None, **kwargs
):
r"""
Make contour map using a grid.

Expand All @@ -48,6 +49,7 @@ def grdcontour(self, grid: PathLike | xr.DataArray, projection=None, **kwargs):

{aliases}
- J=projection
- c=panel

Parameters
----------
Expand Down Expand Up @@ -154,6 +156,7 @@ def grdcontour(self, grid: PathLike | xr.DataArray, projection=None, **kwargs):

aliasdict = AliasSystem(
J=Alias(projection, name="projection"),
c=Alias(panel, name="panel", sep=",", size=2),
).merge(kwargs)

with Session() as lib:
Expand Down
9 changes: 6 additions & 3 deletions pygmt/src/grdimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@
R="region",
V="verbose",
n="interpolation",
c="panel",
f="coltypes",
p="perspective",
t="transparency",
x="cores",
)
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
def grdimage(self, grid: PathLike | xr.DataArray, projection=None, **kwargs):
@kwargs_to_strings(R="sequence", p="sequence")
def grdimage(
self, grid: PathLike | xr.DataArray, projection=None, panel=None, **kwargs
):
r"""
Project and plot grids or images.

Expand Down Expand Up @@ -74,6 +75,7 @@ def grdimage(self, grid: PathLike | xr.DataArray, projection=None, **kwargs):

{aliases}
- J=projection
- c=panel

Parameters
----------
Expand Down Expand Up @@ -169,6 +171,7 @@ def grdimage(self, grid: PathLike | xr.DataArray, projection=None, **kwargs):

aliasdict = AliasSystem(
J=Alias(projection, name="projection"),
c=Alias(panel, name="panel", sep=",", size=2),
).merge(kwargs)

with Session() as lib:
Expand Down
7 changes: 4 additions & 3 deletions pygmt/src/grdview.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,13 @@
Wf="facadepen",
I="shading",
V="verbose",
c="panel",
f="coltypes",
n="interpolation",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
def grdview(self, grid: PathLike | xr.DataArray, projection=None, **kwargs):
@kwargs_to_strings(R="sequence", p="sequence")
def grdview(self, grid: PathLike | xr.DataArray, projection=None, panel=None, **kwargs):
r"""
Create 3-D perspective image or surface mesh from a grid.

Expand All @@ -47,6 +46,7 @@ def grdview(self, grid: PathLike | xr.DataArray, projection=None, **kwargs):

{aliases}
- J=projection
- c=panel

Parameters
----------
Expand Down Expand Up @@ -145,6 +145,7 @@ def grdview(self, grid: PathLike | xr.DataArray, projection=None, **kwargs):

aliasdict = AliasSystem(
J=Alias(projection, name="projection"),
c=Alias(panel, name="panel", sep=",", size=2),
).merge(kwargs)

with Session() as lib:
Expand Down
9 changes: 4 additions & 5 deletions pygmt/src/histogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
W="pen",
Z="histtype",
b="binary",
c="panel",
d="nodata",
e="find",
h="header",
Expand All @@ -37,17 +36,16 @@
t="transparency",
w="wrap",
)
@kwargs_to_strings(
R="sequence", T="sequence", c="sequence_comma", i="sequence_comma", p="sequence"
)
def histogram(self, data: PathLike | TableLike, projection=None, **kwargs):
@kwargs_to_strings(R="sequence", T="sequence", i="sequence_comma", p="sequence")
def histogram(self, data: PathLike | TableLike, projection=None, panel=None, **kwargs):
r"""
Calculate and plot histograms.

Full GMT docs at :gmt-docs:`histogram.html`.

{aliases}
- J=projection
- c=panel

Parameters
----------
Expand Down Expand Up @@ -140,6 +138,7 @@ def histogram(self, data: PathLike | TableLike, projection=None, **kwargs):

aliasdict = AliasSystem(
J=Alias(projection, name="projection"),
c=Alias(panel, name="panel", sep=",", size=2),
).merge(kwargs)

with Session() as lib:
Expand Down
7 changes: 4 additions & 3 deletions pygmt/src/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@
M="monochrome",
R="region",
V="verbose",
c="panel",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
def image(self, imagefile: PathLike, projection=None, **kwargs):
@kwargs_to_strings(R="sequence", p="sequence")
def image(self, imagefile: PathLike, projection=None, panel=None, **kwargs):
r"""
Plot raster or EPS images.

Expand All @@ -32,6 +31,7 @@ def image(self, imagefile: PathLike, projection=None, **kwargs):

{aliases}
- J=projection
- c=panel

Parameters
----------
Expand Down Expand Up @@ -73,6 +73,7 @@ def image(self, imagefile: PathLike, projection=None, **kwargs):

aliasdict = AliasSystem(
J=Alias(projection, name="projection"),
c=Alias(panel, name="panel", sep=",", size=2),
).merge(kwargs)

with Session() as lib:
Expand Down
6 changes: 4 additions & 2 deletions pygmt/src/legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
D="position",
F="box",
V="verbose",
c="panel",
p="perspective",
t="transparency",
)
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
@kwargs_to_strings(R="sequence", p="sequence")
def legend(
self,
spec: PathLike | io.StringIO | None = None,
projection=None,
position="JTR+jTR+o0.2c",
box="+gwhite+p1p",
panel=None,
**kwargs,
):
r"""
Expand All @@ -50,6 +50,7 @@ def legend(

{aliases}
- J=projection
- c=panel

Parameters
----------
Expand Down Expand Up @@ -101,6 +102,7 @@ def legend(

aliasdict = AliasSystem(
J=Alias(projection, name="projection"),
c=Alias(panel, name="panel", sep=",", size=2),
).merge(kwargs)

with Session() as lib:
Expand Down
7 changes: 4 additions & 3 deletions pygmt/src/logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
F="box",
S="style",
V="verbose",
c="panel",
t="transparency",
)
@kwargs_to_strings(R="sequence", c="sequence_comma", p="sequence")
def logo(self, projection=None, **kwargs):
@kwargs_to_strings(R="sequence", p="sequence")
def logo(self, projection=None, panel=None, **kwargs):
r"""
Plot the GMT logo.

Expand All @@ -31,6 +30,7 @@ def logo(self, projection=None, **kwargs):

{aliases}
- J=projection
- c=panel

Parameters
----------
Expand Down Expand Up @@ -59,6 +59,7 @@ def logo(self, projection=None, **kwargs):

aliasdict = AliasSystem(
J=Alias(projection, name="projection"),
c=Alias(panel, name="panel", sep=",", size=2),
).merge(kwargs)

with Session() as lib:
Expand Down
Loading
Loading