-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pygmt.set_display: Fix the bug that method=None
doesn't reset to the default display method
#3396
Conversation
method=None
doesn't reset to the default display method
Need to wait for #3418. |
5bc1392
to
a570ce2
Compare
a570ce2
to
7ea264e
Compare
Ping @GenericMappingTools/pygmt-maintainers for final review. |
def test_figure_set_display_invalid(): | ||
class TestSetDisplay: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't often use classes for the pytest unit tests, is there a reason to use it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to group multiple tests so that it is easier to find all tests for testing a specific function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, it looks like we're using TestGetDefaultDisplayMethod
below also, so ok with this.
Description of proposed changes
pygmt.set_display(method=None)
should revert the display method to the default value, but it doens't work. Here is a minimal example to reproduce the issue:In the last
fig.show()
call, the image should be displayed, but it doesn't. It's becausemethod=None
is ignored inpygmt.set_display
.This PR fixes the bug and does some refactorings.
_get_default_display_method
function so that the same logic of codes can be called whenmethod=None
is used.set_display
to fix the bug.Ideally, we should add a test to check if
SHOW_CONFIG["method"]
matches the value inpygmt.set_display(method="XXX")
. However,SHOW_CONFIG
is a global variable, changing its value will affect other tests. So, no test is added.