Skip to content

Commit cb42a3c

Browse files
Chuan1937seismanyvonnefroehlich
authored
Add a note/warning that PS_CONVERT is not supported (#4342)
Co-authored-by: Dongdong Tian <[email protected]> Co-authored-by: Yvonne Fröhlich <[email protected]>
1 parent 8ce833d commit cb42a3c

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

pygmt/src/config.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
config - Change GMT default settings globally or locally.
33
"""
44

5+
import warnings
56
from inspect import Parameter, Signature
67
from typing import ClassVar
78

@@ -22,6 +23,12 @@ class config: # noqa: N801
2223
...
2324
2425
Full GMT defaults list at :gmt-docs:`gmt.conf.html`.
26+
27+
.. note::
28+
29+
:gmt-term:`PS_CONVERT` is not supported.
30+
To configure conversion options, please pass parameters to
31+
:meth:`pygmt.Figure.savefig` or :meth:`pygmt.Figure.show` instead.
2532
"""
2633

2734
# Manually set the __signature__ attribute to enable tab autocompletion
@@ -135,7 +142,7 @@ class config: # noqa: N801
135142
"PS_CHAR_ENCODING",
136143
"PS_COLOR_MODEL",
137144
"PS_COMMENTS",
138-
"PS_CONVERT",
145+
# "PS_CONVERT", # Not supported; use parameters of Figure.savefig/show instead
139146
"PS_IMAGE_COMPRESS",
140147
"PS_LINE_CAP",
141148
"PS_LINE_JOIN",
@@ -188,6 +195,16 @@ class config: # noqa: N801
188195
)
189196

190197
def __init__(self, **kwargs):
198+
if "PS_CONVERT" in kwargs:
199+
warnings.warn(
200+
message="Parameter 'PS_CONVERT' is not supported. "
201+
"To configure conversion options, please pass parameters to "
202+
"pygmt.Figure.savefig or pygmt.Figure.show instead.",
203+
category=SyntaxWarning,
204+
stacklevel=2,
205+
)
206+
kwargs.pop("PS_CONVERT")
207+
191208
# Save values so that we can revert to their initial values
192209
self.old_defaults = {}
193210
with Session() as lib:

pygmt/tests/test_config.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,20 @@ def test_config_map_tick_pen():
198198
fig.shift_origin(yshift=-3)
199199
fig.basemap(frame=["pa1Hg", "sa45mg45m", "nwSE"], verbose="error")
200200
return fig
201+
202+
203+
def test_config_ps_convert():
204+
"""
205+
Test that Parameter 'PS_CONVERT' is not supported.
206+
"""
207+
# Check that PS_CONVERT is removed from the autocomplete list
208+
assert "PS_CONVERT" not in config._keywords
209+
210+
# Check that a warning is raised when PS_CONVERT is used in config
211+
msg = (
212+
"Parameter 'PS_CONVERT' is not supported. "
213+
"To configure conversion options, please pass parameters to "
214+
"pygmt.Figure.savefig or pygmt.Figure.show instead."
215+
)
216+
with pytest.warns(SyntaxWarning, match=msg):
217+
config(PS_CONVERT="C")

0 commit comments

Comments
 (0)