Skip to content

Commit 6e8e36d

Browse files
committed
modified tutorial 4
1 parent 2a92869 commit 6e8e36d

File tree

3 files changed

+137
-58
lines changed

3 files changed

+137
-58
lines changed

tutorials/tutorial3/tutorial-3-rbf.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"import os\n",
6161
"from pygem import RBF\n",
6262
"\n",
63-
"# Try to locate the parameter file robustly\n",
63+
"# find the possible path of the parameter file depending on the working directory\n",
6464
"possible_paths = [\n",
6565
" \"../tests/test_datasets/parameters_rbf_cube.prm\", # when run from tutorial3/\n",
6666
" \"tests/test_datasets/parameters_rbf_cube.prm\", # when run from tutorials/\n",

tutorials/tutorial4/tutorial-4-idw.ipynb

Lines changed: 117 additions & 53 deletions
Large diffs are not rendered by default.

tutorials/tutorial4/tutorial-4-idw.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,29 @@
1010

1111
# In[1]:
1212

13+
import sys
14+
import platform
15+
print(f"Python Version: {sys.version}")
16+
print(f"Platform: {sys.platform}")
17+
print(f"System: {platform.system()} {platform.release()}")
18+
19+
try:
20+
import pygem
21+
print(f"PyGeM version: {pygem.__version__}")
22+
except ImportError:
23+
print(f"PyGeM not found. Installing...")
24+
import subprocess
25+
subprocess.check_call([sys.executable, "-m", "pip", "install", "-e", ".[tut]"])
26+
import pygem
27+
print(f"PyGeM version: {pygem.__version__}")
1328

14-
get_ipython().run_line_magic("matplotlib", "inline")
1529
import numpy as np
30+
np.random.seed(42)
1631
import matplotlib.pyplot as plt
17-
1832
from pygem import IDW
1933

2034

35+
2136
# We need to set the deformation parameters: we can set manually, by editing the `IDW` attributes, or we can read them by parsing a file. We remark that it is possible to save the parameters (for example, after set them manually) to a file in order to edit this for the future deformations.
2237

2338
# In[2]:
@@ -34,8 +49,8 @@
3449
# In[3]:
3550

3651

37-
get_ipython().run_line_magic("cat", "'../tests/test_datasets/parameters_idw_cube.prm'")
38-
52+
import subprocess
53+
subprocess.run(["cat", "../tests/test_datasets/parameters_idw_cube.prm"])
3954

4055
# Here we create a $10 \times 10 \times 10$ lattice to mimic a cube.
4156

0 commit comments

Comments
 (0)