Skip to content

Commit

Permalink
PYGMT_USE_EXTERNAL_DISPLAY should only affect external display
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Aug 28, 2024
1 parent e3428f8 commit 5bc1392
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pygmt/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def _get_default_display_method() -> Literal["external", "notebook", "none"]:
- ``"notebook"``: Inline PNG preview in the current notebook
- ``"none"``: Disable image preview
The default display method is ``"notebook"`` in the Jupyter notebook environment, and
``"external"`` in other cases.
The default display method is ``"notebook"`` in the Jupyter notebook environment,
and ``"external"`` in other cases.
Setting environment variable **PYGMT_USE_EXTERNAL_DISPLAY** to ``"false"`` can
disable image preview. It's useful when running the tests and building the
Expand All @@ -60,12 +60,12 @@ def _get_default_display_method() -> Literal["external", "notebook", "none"]:
method
The default display method.
"""
if os.environ.get("PYGMT_USE_EXTERNAL_DISPLAY", "true").lower() == "false":
return "none"
if _HAS_IPYTHON:
get_ipython = IPython.get_ipython()
if get_ipython and "IPKernelApp" in get_ipython.config:
return "notebook"

Check warning on line 66 in pygmt/figure.py

View check run for this annotation

Codecov / codecov/patch

pygmt/figure.py#L66

Added line #L66 was not covered by tests
if os.environ.get("PYGMT_USE_EXTERNAL_DISPLAY", "true").lower() == "false":
return "none"
return "external"

Check warning on line 69 in pygmt/figure.py

View check run for this annotation

Codecov / codecov/patch

pygmt/figure.py#L69

Added line #L69 was not covered by tests


Expand Down

0 comments on commit 5bc1392

Please sign in to comment.