GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — pygmt.set_display: Fix the bug that `method=None` doesn't reset to the default display method by seisman · Pull Request #3396 · GenericMappingTools/pygmt

Conversation

@seisman

@seisman seisman commented Aug 13, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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 [1]: import pygmt
In [2]: fig = pygmt.Figure()
In [3]: fig.basemap(region=[0, 10, 0, 10], projection="X4c/4c", frame=True)
In [4]: fig.show()  # Display the image in an external viewer
In [5]: pygmt.set_display(method="none")  # Disable image preview 
In [6]: fig.show()  # Image is not displayed
In [7]: pygmt.set_display(method=None)   # Should revert to the default display method
In [8]: fig.show()  # Image is not displayed. WRONG!

In the last fig.show() call, the image should be displayed, but it doesn't. It's because method=None is ignored in pygmt.set_display.

This PR fixes the bug and does some refactorings.

  • 2409284: Add the _get_default_display_method function so that the same logic of codes can be called when method=None is used.
  • 6bd742e: Refactor set_display to fix the bug.

Ideally, we should add a test to check if SHOW_CONFIG["method"] matches the value in pygmt.set_display(method="XXX"). However, SHOW_CONFIG is a global variable, changing its value will affect other tests. So, no test is added.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@seisman seisman added bug Something isn't working needs review This PR has higher priority and needs review. labels Aug 13, 2024
@seisman seisman added this to the 0.13.0 milestone Aug 13, 2024
seisman
seisman commented Aug 13, 2024
View reviewed changes
Comment thread pygmt/figure.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@seisman seisman changed the title Refactor and add the _get_default_display_method function pygmt.set_display: Fix the bug that method=None doesn't reset to the default display method Aug 13, 2024
michaelgrund
michaelgrund reviewed Aug 28, 2024
View reviewed changes
Comment thread pygmt/figure.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@seisman seisman mentioned this pull request Aug 28, 2024
The dynamically generated images are not shown in the documentation #3416
Closed
seisman and others added 5 commits August 28, 2024 19:06
@seisman
Refactor and add the _get_default_display_method function
28412d2
@seisman @michaelgrund
Update pygmt/figure.py
9468ec8
Co-authored-by: Michael Grund <[email protected]>
@seisman
PYGMT_USE_EXTERNAL_DISPLAY should only affect external display
4d6b46b
@seisman
Refactor to init the display method at import time
e328092
@seisman
Add some tests
334e9c4
@seisman seisman mentioned this pull request Aug 28, 2024
PYGMT_USE_EXTERNAL_DISPLAY should NOT disable image display in Jupyter notebook environment #3418
Merged
seisman added 4 commits August 28, 2024 19:42
@seisman
Fix tests
20d49ba
@seisman
Update comments
d28a25d
@seisman
Improve _get_default_display_method docstrings
77b378d
@seisman
Improve test comments
9afb724
@seisman

seisman commented Aug 28, 2024

Copy link
Copy Markdown
Member Author

Need to wait for #3418.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@seisman seisman removed the needs review This PR has higher priority and needs review. label Aug 28, 2024
@seisman
Merge branch 'main' into bug/external-display
a63f0da
@seisman
seisman force-pushed the refactor/default_display branch from 5bc1392 to a570ce2 Compare August 29, 2024 12:17
@seisman
seisman changed the base branch from main to bug/external-display August 29, 2024 14:20
seisman added 5 commits August 29, 2024 23:35
@seisman
Merge branch 'main' into bug/external-display
21f2b89
@seisman
Simplify the code block for checking IPython kernels
83288c3
@seisman
Merge branch 'main' into bug/external-display
aa4a2ba
@seisman
pygmt.set_display: Fix a bug when setting method=None, add type hin…
0045fa5
…ts and refactor
@seisman
Add one test
7ea264e
@seisman
seisman force-pushed the refactor/default_display branch from a570ce2 to 7ea264e Compare August 30, 2024 00:15
@seisman
Improve tests
f6bce0a
Base automatically changed from bug/external-display to main September 1, 2024 06:56
seisman added 4 commits September 1, 2024 15:00
@seisman
Merge branch 'main' into refactor/default_display
4729697
@seisman
Merge branch 'main' into refactor/default_display
625a1ca
@seisman
Merge branch 'main' into refactor/default_display
3ea2cd4
@seisman
Merge branch 'main' into refactor/default_display
42443fb
@seisman seisman added the final review call This PR requires final review and approval from a second reviewer label Sep 2, 2024
@seisman

seisman commented Sep 2, 2024

Copy link
Copy Markdown
Member Author

Ping @GenericMappingTools/pygmt-maintainers for final review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

weiji14
weiji14 approved these changes Sep 2, 2024
View reviewed changes
Comment thread pygmt/tests/test_figure.py


def test_figure_set_display_invalid():
class TestSetDisplay:

@weiji14 weiji14 Sep 2, 2024

Copy link
Copy Markdown
Member

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?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@seisman seisman Sep 2, 2024

Copy link
Copy Markdown
Member Author

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@weiji14 weiji14 Sep 2, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@seisman
seisman merged commit f9cf17c into main Sep 3, 2024
@seisman
seisman deleted the refactor/default_display branch September 3, 2024 02:59
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@michaelgrund michaelgrund michaelgrund left review comments
@weiji14 weiji14 weiji14 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

bug Something isn't working

Projects

None yet

Milestone

0.13.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@seisman @michaelgrund @weiji14
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.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.