Closed liamtoney closed 4 years ago
However — the command
pygmt.config(MAP_FRAME_TYPE='fancy')
works as expected. Does FONT
not have a default, usually?
I'm not very familiar with GMT's settings, but looking at https://docs.generic-mapping-tools.org/latest/gmt.conf.html#font-parameters, it says:
FONT Sets the default for all fonts, except FONT_LOGO. This setting is not included in the gmt.conf file.
so I guess that means there's no default? I think we'll need to wrap the below code around a try...except
clause to handle these cases:
Ok, so there seems to be 7 settings without default settings. Besides FONT
which influences all FONT_
related settings (except FONT_LOGO
), the other 6 seems to only control both the resulting _PRIMARY
and _SECONDARY
settings (e.g. FONT_ANNOT_PRIMARY
and FONT_ANNOT_SECONDARY
).
* FORMAT_TIME_PRIMARY_MAP, FORMAT_TIME_SECONDARY_MAP
I could do an 'allowlist' to map the 6 types above to their corresponding _PRIMARY
and _SECONDARY
settings, so that their default settings are reverted outside of the with
block, but FONT
itself will still be a bit tricky to handle. Any ideas?
Hmm, that's actually a tricky problem since we can't access FONT
programmatically (what even is the default?). I guess for now we could do a try/except or if key == 'FONT'
workaround to just not perform the error-raising lookup for the time-being?
I'm not familiar with context managers, but is there a way to raise an error if someone tries to set FONT
using the with
block? E.g. Error: Setting parameter "FONT" within a with block is not supported.
That would be better in my view since it wouldn't just silently not revert the FONT
value...
I could do an 'allowlist' to map the 6 types above to their corresponding
_PRIMARY
and_SECONDARY
settings, so that their default settings are reverted outside of thewith
block, butFONT
itself will still be a bit tricky to handle. Any ideas?
It's a good solution for me. For FONT
, we probably have to maintain a list of FONT_* parameters.
Description of the problem
The code
runs fine. But the equivalent
pygmt.config()
has trouble.Full code that generated the error
Full error message
System information
conda list
below:output of conda list