|
26 | 26 | "# Standard header for all tutorials\n", |
27 | 27 | "import sys\n", |
28 | 28 | "import platform\n", |
| 29 | + "import numpy as np\n", |
| 30 | + "import matplotlib.pyplot as plt\n", |
| 31 | + "import pygem\n", |
| 32 | + "\n", |
29 | 33 | "print(f\"Python Version: {sys.version}\")\n", |
30 | 34 | "print(f\"Platform: {sys.platform}\")\n", |
31 | 35 | "print(f\"System: {platform.system()} {platform.release()}\")\n", |
| 36 | + "print(f\"PyGeM version: {pygem.__version__}\")\n", |
32 | 37 | "\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", |
44 | 38 | "np.random.seed(42)\n", |
45 | | - "import matplotlib.pyplot as plt\n", |
46 | | - "\n", |
47 | 39 | "# Set matplotlib for notebook\n", |
48 | | - "get_ipython().run_line_magic('matplotlib', 'inline')\n", |
49 | | - "\n", |
50 | | - "from pygem import RBF" |
| 40 | + "%matplotlib inline" |
51 | 41 | ] |
52 | 42 | }, |
53 | 43 | { |
|
61 | 51 | }, |
62 | 52 | { |
63 | 53 | "cell_type": "code", |
64 | | - "execution_count": 2, |
| 54 | + "execution_count": null, |
65 | 55 | "metadata": { |
66 | 56 | "scrolled": true |
67 | 57 | }, |
68 | 58 | "outputs": [], |
69 | 59 | "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", |
70 | 79 | "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" |
72 | 83 | ] |
73 | 84 | }, |
74 | 85 | { |
|
0 commit comments