pygmt.set_display: Fix the bug that method=None doesn't reset to the default display method#3396
Merged
pygmt.set_display: Fix the bug that method=None doesn't reset to the default display method#3396
method=None doesn't reset to the default display method#3396Conversation
seisman
commented
Aug 13, 2024
method=None doesn't reset to the default display method
Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
Member
Author
|
Need to wait for #3418. |
5bc1392 to
a570ce2
Compare
a570ce2 to
7ea264e
Compare
Member
Author
|
Ping @GenericMappingTools/pygmt-maintainers for final review. |
weiji14
approved these changes
Sep 2, 2024
|
|
||
|
|
||
| def test_figure_set_display_invalid(): | ||
| class TestSetDisplay: |
Member
There was a problem hiding this comment.
We don't often use classes for the pytest unit tests, is there a reason to use it here?
Member
Author
There was a problem hiding this comment.
Just want to group multiple tests so that it is easier to find all tests for testing a specific function.
Member
There was a problem hiding this comment.
Ok, it looks like we're using TestGetDefaultDisplayMethod below also, so ok with this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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=Noneis ignored inpygmt.set_display.This PR fixes the bug and does some refactorings.
_get_default_display_methodfunction so that the same logic of codes can be called whenmethod=Noneis used.set_displayto 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_CONFIGis a global variable, changing its value will affect other tests. So, no test is added.