Automatize Tutorials html, py files creation (#496)

* workflow to export tutorials

---------
This commit is contained in:
Dario Coscia
2025-03-15 11:01:19 +01:00
committed by Nicola Demo
parent aea24d0bee
commit 0146155c9b
51 changed files with 140529 additions and 440 deletions

View File

@@ -23,13 +23,14 @@
"source": [
"## routine needed to run the notebook on Google Colab\n",
"try:\n",
" import google.colab\n",
" IN_COLAB = True\n",
" import google.colab\n",
"\n",
" IN_COLAB = True\n",
"except:\n",
" IN_COLAB = False\n",
" IN_COLAB = False\n",
"if IN_COLAB:\n",
" !pip install \"pina-mathlab\"\n",
" \n",
" !pip install \"pina-mathlab\"\n",
"\n",
"import torch\n",
"import matplotlib.pyplot as plt\n",
"import warnings\n",
@@ -42,7 +43,7 @@
"from pina.equation import Equation, FixedValue\n",
"from pina.callback import MetricTracker\n",
"\n",
"warnings.filterwarnings('ignore')"
"warnings.filterwarnings(\"ignore\")"
]
},
{
@@ -261,7 +262,7 @@
" train_size=1.0,\n",
" val_size=0.0,\n",
" test_size=0.0,\n",
" callbacks=[MetricTracker(['train_loss', 'initial_loss','D_loss'])],\n",
" callbacks=[MetricTracker([\"train_loss\", \"initial_loss\", \"D_loss\"])],\n",
")\n",
"trainer.train()"
]
@@ -343,10 +344,10 @@
" \"True solution\": problem.solution(points),\n",
" \"Absolute Difference\": torch.abs(\n",
" solver(points) - problem.solution(points)\n",
" )\n",
" ),\n",
" }\n",
" # plot the solution\n",
" plt.suptitle(f'Solution for time {time.item()}')\n",
" plt.suptitle(f\"Solution for time {time.item()}\")\n",
" for idx, (title, field) in enumerate(data.items()):\n",
" plt.subplot(1, 3, idx + 1)\n",
" plt.title(title)\n",