Skip to content

Commit 1201e45

Browse files
committed
Add the .add_common method to the AliasSystem class
1 parent 01f64bf commit 1201e45

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

pygmt/alias.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,10 @@ class AliasSystem(UserDict):
226226
... ],
227227
... B=Alias(frame, name="frame"),
228228
... D=Alias(repeat, name="repeat"),
229-
... c=Alias(panel, name="panel", sep=","),
230-
... ).merge(kwargs)
229+
... ).add_common(
230+
... c=panel,
231+
... )
232+
... aliasdict.merge(kwargs)
231233
... return build_arg_list(aliasdict)
232234
>>> func(
233235
... "infile",
@@ -268,6 +270,20 @@ def __init__(self, **kwargs):
268270
kwdict[option] = aliases._value
269271
super().__init__(kwdict)
270272

273+
def add_common(self, **kwargs):
274+
"""
275+
Add common parameters to the alias dictionary.
276+
"""
277+
for key, value in kwargs.items():
278+
match key:
279+
case "c":
280+
alias = Alias(value, name="panel", sep=",", size=2)
281+
case _:
282+
raise GMTValueError(key, description="common parameter")
283+
self.aliasdict[key] = alias
284+
self[key] = alias._value
285+
return self
286+
271287
def merge(self, kwargs: Mapping[str, Any]):
272288
"""
273289
Update the dictionary with additional keyword arguments.

0 commit comments

Comments
 (0)