Skip to content

Commit

Permalink
Protecting pyvista: static, trame,...
Browse files Browse the repository at this point in the history
  • Loading branch information
anaegel committed Jun 14, 2024
1 parent fd7824f commit 9f1fb76
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
24 changes: 18 additions & 6 deletions content/tutorial-solver/example01-smoothers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,24 @@
}
],
"source": [
"import pyvista\n",
"#pyvista.start_xvfb()\n",
"#pyvista.set_jupyter_backend('static')\n",
"pyvista.set_jupyter_backend('trame')\n",
"result = pyvista.read( \"Error_gs.vtu\")\n",
"result.plot(scalars=\"u\", show_edges=True, cmap='jet')"
"try:\n",
" import pyvista\n",
"except ModuleNotFoundError:\n",
" print(\"pyvista is required for this demo\")\n",
" exit(0)\n",
"\n",
"try: \n",
" # Activate the following lines binder, colab etc.\n",
" pyvista.start_xvfb()\n",
" pyvista.set_jupyter_backend('static')\n",
"\n",
" # Activate locally, if trame exists.\n",
" # pyvista.set_jupyter_backend('trame')\n",
" \n",
" result = pyvista.read( \"Error_gs.vtu\")\n",
" result.plot(scalars=\"u\", show_edges=True, cmap='jet')\n",
"except:\n",
" print(\"Plotting failed.\")"
]
},
{
Expand Down
17 changes: 12 additions & 5 deletions content/tutorial-solver/example01-smoothers.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,18 @@ def PlotResults(history, title):
print("pyvista is required for this demo")
exit(0)

#pyvista.start_xvfb()
#pyvista.set_jupyter_backend('static')
pyvista.set_jupyter_backend('trame')
result = pyvista.read( "Error_gs.vtu")
result.plot(scalars="u", show_edges=True, cmap='jet')
try:
# Activate the following lines binder, colab etc.
pyvista.start_xvfb()
pyvista.set_jupyter_backend('static')

# Activate locally, if trame exists.
# pyvista.set_jupyter_backend('trame')

result = pyvista.read( "Error_gs.vtu")
result.plot(scalars="u", show_edges=True, cmap='jet')
except:
print("Plotting failed.")


# In[ ]:
Expand Down

0 comments on commit 9f1fb76

Please sign in to comment.