Skip to content

Commit 3fa32b3

Browse files
committed
modified tutorial-3-rbf.ipynb
1 parent fc52219 commit 3fa32b3

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ pygem.egg-info/
1212
# virtual environments
1313
venv_pygem/
1414
venv_pygem
15-
#virtual environments
16-
venv_pygem/
15+

tutorials/tutorial3/tutorial-3-rbf.ipynb

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,18 @@
2626
"# Standard header for all tutorials\n",
2727
"import sys\n",
2828
"import platform\n",
29+
"import numpy as np\n",
30+
"import matplotlib.pyplot as plt\n",
31+
"import pygem\n",
32+
"\n",
2933
"print(f\"Python Version: {sys.version}\")\n",
3034
"print(f\"Platform: {sys.platform}\")\n",
3135
"print(f\"System: {platform.system()} {platform.release()}\")\n",
36+
"print(f\"PyGeM version: {pygem.__version__}\")\n",
3237
"\n",
33-
"try:\n",
34-
" import pygem\n",
35-
" print(f\"PyGeM version: {pygem.__version__}\")\n",
36-
"except ImportError:\n",
37-
" print(f\"PyGeM not found. Installing...\")\n",
38-
" import subprocess\n",
39-
" subprocess.check_call([sys.executable, \"-m\", \"pip\", \"install\", \"-e\", \".[tut]\"])\n",
40-
" import pygem\n",
41-
" print(f\"PyGeM version: {pygem.__version__}\")\n",
42-
"\n",
43-
"import numpy as np\n",
4438
"np.random.seed(42)\n",
45-
"import matplotlib.pyplot as plt\n",
46-
"\n",
4739
"# Set matplotlib for notebook\n",
48-
"get_ipython().run_line_magic('matplotlib', 'inline')\n",
49-
"\n",
50-
"from pygem import RBF"
40+
"%matplotlib inline"
5141
]
5242
},
5343
{
@@ -61,14 +51,35 @@
6151
},
6252
{
6353
"cell_type": "code",
64-
"execution_count": 2,
54+
"execution_count": null,
6555
"metadata": {
6656
"scrolled": true
6757
},
6858
"outputs": [],
6959
"source": [
60+
"import os\n",
61+
"from pygem import RBF\n",
62+
"\n",
63+
"# Try to locate the parameter file robustly\n",
64+
"possible_paths = [\n",
65+
" \"../tests/test_datasets/parameters_rbf_cube.prm\", # when run from tutorial3/\n",
66+
" \"tests/test_datasets/parameters_rbf_cube.prm\", # when run from tutorials/\n",
67+
" \"../../tests/test_datasets/parameters_rbf_cube.prm\", # when run from PyGeM root\n",
68+
"]\n",
69+
"\n",
70+
"param_file = None\n",
71+
"for p in possible_paths:\n",
72+
" if os.path.isfile(p):\n",
73+
" param_file = p\n",
74+
" break\n",
75+
"\n",
76+
"if param_file is None:\n",
77+
" raise FileNotFoundError(\"Could not find parameters_rbf_cube.prm in expected locations.\")\n",
78+
"\n",
7079
"rbf = RBF()\n",
71-
"rbf.read_parameters(filename=\"../tests/test_datasets/parameters_rbf_cube.prm\")"
80+
"rbf.read_parameters(filename=param_file)\n",
81+
"\n",
82+
"print(f\"Successfully loaded parameters from: {param_file}\")\n"
7283
]
7384
},
7485
{

0 commit comments

Comments
 (0)