Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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
19 changes: 18 additions & 1 deletion pygmt/src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
config - Change GMT default settings globally or locally.
"""

import warnings
from inspect import Parameter, Signature
from typing import ClassVar

Expand All @@ -22,6 +23,12 @@ class config: # noqa: N801
...

Full GMT defaults list at :gmt-docs:`gmt.conf.html`.

.. note::

:gmt-term:`PS_CONVERT` is not supported.
To configure conversion options, set parameters in
:meth:`pygmt.Figure.savefig` or :meth:`pygmt.Figure.show` instead.
"""

# Manually set the __signature__ attribute to enable tab autocompletion
Expand Down Expand Up @@ -135,7 +142,7 @@ class config: # noqa: N801
"PS_CHAR_ENCODING",
"PS_COLOR_MODEL",
"PS_COMMENTS",
"PS_CONVERT",
# "PS_CONVERT", # Not supported; use Figure.savefig/show parameters instead
"PS_IMAGE_COMPRESS",
"PS_LINE_CAP",
"PS_LINE_JOIN",
Expand Down Expand Up @@ -188,6 +195,16 @@ class config: # noqa: N801
)

def __init__(self, **kwargs):
if "PS_CONVERT" in kwargs:
warnings.warn(
message="Parameter 'PS_CONVERT' is not supported. "
"To confiure conversion options, please pass parameters to "
"pygmt.Figure.savefig or pygmt.Figure.show instead.",
category=SyntaxWarning,
stacklevel=2,
)
kwargs.pop("PS_CONVERT")

# Save values so that we can revert to their initial values
self.old_defaults = {}
with Session() as lib:
Expand Down
22 changes: 22 additions & 0 deletions pygmt/tests/test_config_ps_convert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
Test that Parameter 'PS_CONVERT' is not supported.
"""

import pytest
from pygmt import config

def test_config_ps_convert():
"""
Test that Parameter 'PS_CONVERT' is not supported.
"""
# Check that PS_CONVERT is removed from the autocomplete list
assert "PS_CONVERT" not in config._keywords

# Check that a warning is raised when PS_CONVERT is used in config
msg = (
"Parameter 'PS_CONVERT' is not supported. "
"To confiure conversion options, please pass parameters to "
"pygmt.Figure.savefig or pygmt.Figure.show instead."
)
with pytest.warns(SyntaxWarning, match=msg):
config(PS_CONVERT="C")
Loading