|
13 | 13 | # As usually, at the beginning we import all the modules we need. |
14 | 14 |
|
15 | 15 | # In[1]: |
| 16 | +import sys |
| 17 | +import platform |
| 18 | +print(f"Python Version: {sys.version}") |
| 19 | +print(f"Platform: {sys.platform}") |
| 20 | +print(f"System: {platform.system()} {platform.release()}") |
| 21 | +import subprocess |
| 22 | +try: |
| 23 | + import pygem |
| 24 | + print(f"PyGeM version: {pygem.__version__}") |
| 25 | +except ImportError: |
| 26 | + print(f"PyGeM not found. Installing...") |
| 27 | + # Installing from local source. It can be replaced with github installation once pushed and merged. |
| 28 | + subprocess.check_call([sys.executable, "-m", "pip", "install", "-e", ".[tut]"]) |
| 29 | + import pygem |
| 30 | + |
| 31 | + print(f"PyGeM version: {pygem.__version__}") |
| 32 | + |
| 33 | +try: |
| 34 | + from smithers import io |
| 35 | +except ImportError: |
| 36 | + print("smithers not found. Installing from GitHub...") |
| 37 | + subprocess.check_call([sys.executable, "-m", "pip", "install", "git+https://github.com/mathLab/Smithers.git"]) |
| 38 | + from smithers import io |
16 | 39 |
|
17 | | - |
18 | | -get_ipython().run_line_magic("matplotlib", "inline") |
19 | 40 | import numpy as np |
| 41 | +np.random.seed(42) |
| 42 | + |
| 43 | + |
20 | 44 |
|
| 45 | +import matplotlib.pyplot as plt |
21 | 46 | from pygem import FFD |
22 | 47 | from smithers import io |
23 | 48 |
|
|
28 | 53 |
|
29 | 54 |
|
30 | 55 | def plot(data, color=None): |
31 | | - |
32 | 56 | from mpl_toolkits.mplot3d import Axes3D |
33 | 57 | from mpl_toolkits.mplot3d.art3d import Poly3DCollection |
34 | 58 | import matplotlib.pyplot as plt |
@@ -57,11 +81,17 @@ def plot(data, color=None): |
57 | 81 |
|
58 | 82 | # In[3]: |
59 | 83 |
|
| 84 | +import os |
| 85 | +import urllib.request |
| 86 | + |
| 87 | +if os.path.exists("cube.vtp"): |
| 88 | + os.remove("cube.vtp") |
60 | 89 |
|
61 | | -get_ipython().system("rm -rf cube.vtp") |
62 | | -get_ipython().system( |
63 | | - "wget https://raw.githubusercontent.com/mathLab/Smithers/master/tests/test_datasets/cube.vtp" |
| 90 | +urllib.request.urlretrieve( |
| 91 | + "https://raw.githubusercontent.com/mathLab/Smithers/master/tests/test_datasets/cube.vtp", |
| 92 | + "cube.vtp" |
64 | 93 | ) |
| 94 | + |
65 | 95 | vtp_filename = "cube.vtp" |
66 | 96 |
|
67 | 97 | vtp_content = io.VTPHandler.read(vtp_filename) |
@@ -112,10 +142,15 @@ def plot(data, color=None): |
112 | 142 | # In[8]: |
113 | 143 |
|
114 | 144 |
|
115 | | -get_ipython().system("rm -rf cube.stl") |
116 | | -get_ipython().system( |
117 | | - "wget https://raw.githubusercontent.com/mathLab/Smithers/master/tests/test_datasets/cube.stl" |
| 145 | +if os.path.exists("cube.stl"): |
| 146 | + os.remove("cube.stl") |
| 147 | + |
| 148 | +urllib.request.urlretrieve( |
| 149 | + "https://raw.githubusercontent.com/mathLab/Smithers/master/tests/test_datasets/cube.stl", |
| 150 | + "cube.stl" |
118 | 151 | ) |
| 152 | + |
| 153 | + |
119 | 154 | stl_filename = "cube.stl" |
120 | 155 |
|
121 | 156 | stl_content = io.STLHandler.read(stl_filename) |
|
0 commit comments