Skip to content

Commit

Permalink
fix: resolve jumanji import crash in non-terminal and non-notebook se…
Browse files Browse the repository at this point in the history
…tting (#46)
  • Loading branch information
dluo96 authored Nov 15, 2022
1 parent f49d302 commit c90e1d9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion jumanji/environments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def is_colab() -> bool:
return "google.colab" in sys.modules


def is_notebook() -> bool:
return "ipykernel" in sys.modules


# In a notebook, force the Matplotlib backend to ngAgg in order for figures to update
# every time render is called for environments that use Matplotlib
# for rendering. Without this, only the last render result is shown per figure.
Expand All @@ -39,8 +43,10 @@ def is_colab() -> bool:

if is_colab():
backend = "inline"
else:
elif is_notebook():
backend = "notebook"
else:
backend = ""
IPython.get_ipython().run_line_magic("matplotlib", backend)

except ImportError as exc:
Expand Down

0 comments on commit c90e1d9

Please sign in to comment.