@@ -131,3 +131,64 @@ def _to_string(
131131 # "prefix" and "mapping" are ignored. We can enable them when needed.
132132 _value = sequence_join (value , separator = separator , size = size , ndim = ndim , name = name )
133133 return f"{ prefix } { _value } "
134+
135+
136+ class Alias :
137+ """
138+ Class for aliasing a PyGMT parameter to a GMT option or a modifier.
139+
140+ Parameters
141+ ----------
142+ value
143+ The value of the alias.
144+ name
145+ The name of the parameter to be used in the error message.
146+ prefix
147+ The string to add as a prefix to the returned value.
148+ mapping
149+ A mapping dictionary to map PyGMT's long-form arguments to GMT's short-form.
150+ separator
151+ The separator to use if the value is a sequence.
152+ size
153+ Expected size of the 1-D sequence. It can be either an integer or a sequence
154+ of integers. If an integer, it is the expected size of the 1-D sequence.
155+ If it is a sequence, it is the allowed sizes of the 1-D sequence.
156+ ndim
157+ The expected maximum number of dimensions of the sequence.
158+
159+ Examples
160+ --------
161+ >>> par = Alias((3.0, 3.0), prefix="+o", separator="/")
162+ >>> par._value
163+ '+o3.0/3.0'
164+
165+ >>> par = Alias("mean", mapping={"mean": "a", "mad": "d", "full": "g"})
166+ >>> par._value
167+ 'a'
168+
169+ >>> par = Alias(["xaf", "yaf", "WSen"])
170+ >>> par._value
171+ ['xaf', 'yaf', 'WSen']
172+ """
173+
174+ def __init__ (
175+ self ,
176+ value : Any ,
177+ name : str | None = None ,
178+ prefix : str = "" ,
179+ mapping : Mapping | None = None ,
180+ separator : Literal ["/" , "," ] | None = None ,
181+ size : int | Sequence [int ] | None = None ,
182+ ndim : int = 1 ,
183+ ):
184+ self .name = name
185+ self .prefix = prefix
186+ self ._value = _to_string (
187+ value = value ,
188+ name = name ,
189+ prefix = prefix ,
190+ mapping = mapping ,
191+ separator = separator ,
192+ size = size ,
193+ ndim = ndim ,
194+ )
0 commit comments