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 FilippoOlivo
parent 8dfc9d19db
commit 3ff9f0c9a2
51 changed files with 140529 additions and 440 deletions

View File

@@ -75,17 +75,18 @@
"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",
" # get the data\n",
" !mkdir \"data\"\n",
" !wget \"https://github.com/mathLab/PINA/raw/refs/heads/master/tutorials/tutorial7/data/pinn_solution_0.5_0.5\" -O \"data/pinn_solution_0.5_0.5\"\n",
" !wget \"https://github.com/mathLab/PINA/raw/refs/heads/master/tutorials/tutorial7/data/pts_0.5_0.5\" -O \"data/pts_0.5_0.5\"\n",
" \n",
" !pip install \"pina-mathlab\"\n",
" # get the data\n",
" !mkdir \"data\"\n",
" !wget \"https://github.com/mathLab/PINA/raw/refs/heads/master/tutorials/tutorial7/data/pinn_solution_0.5_0.5\" -O \"data/pinn_solution_0.5_0.5\"\n",
" !wget \"https://github.com/mathLab/PINA/raw/refs/heads/master/tutorials/tutorial7/data/pts_0.5_0.5\" -O \"data/pts_0.5_0.5\"\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import torch\n",
"import warnings\n",
@@ -101,7 +102,7 @@
"from lightning.pytorch import seed_everything\n",
"from lightning.pytorch.callbacks import Callback\n",
"\n",
"warnings.filterwarnings('ignore')\n",
"warnings.filterwarnings(\"ignore\")\n",
"seed_everything(883)"
]
},
@@ -152,11 +153,11 @@
}
],
"source": [
"points = data_input.extract(['x', 'y']).detach().numpy()\n",
"points = data_input.extract([\"x\", \"y\"]).detach().numpy()\n",
"truth = data_output.detach().numpy()\n",
"\n",
"plt.scatter(points[:, 0], points[:, 1], c=truth, s=8)\n",
"plt.axis('equal')\n",
"plt.axis(\"equal\")\n",
"plt.colorbar()\n",
"plt.show()"
]
@@ -255,8 +256,8 @@
" layers=[20, 20, 20],\n",
" func=torch.nn.Softplus,\n",
" output_dimensions=len(problem.output_variables),\n",
" input_dimensions=len(problem.input_variables)\n",
" )"
" input_dimensions=len(problem.input_variables),\n",
")"
]
},
{