1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,80 +0,0 @@ |
1 |
-{ |
|
2 |
- "cells": [ |
|
3 |
- { |
|
4 |
- "cell_type": "markdown", |
|
5 |
- "metadata": {}, |
|
6 |
- "source": [ |
|
7 |
- "# Timing" |
|
8 |
- ] |
|
9 |
- }, |
|
10 |
- { |
|
11 |
- "cell_type": "code", |
|
12 |
- "execution_count": null, |
|
13 |
- "metadata": {}, |
|
14 |
- "outputs": [], |
|
15 |
- "source": [ |
|
16 |
- "import holoviews as hv\n", |
|
17 |
- "hv.notebook_extension()" |
|
18 |
- ] |
|
19 |
- }, |
|
20 |
- { |
|
21 |
- "cell_type": "code", |
|
22 |
- "execution_count": null, |
|
23 |
- "metadata": {}, |
|
24 |
- "outputs": [], |
|
25 |
- "source": [ |
|
26 |
- "import numpy as np\n", |
|
27 |
- "import learner\n", |
|
28 |
- "from time import time" |
|
29 |
- ] |
|
30 |
- }, |
|
31 |
- { |
|
32 |
- "cell_type": "code", |
|
33 |
- "execution_count": null, |
|
34 |
- "metadata": {}, |
|
35 |
- "outputs": [], |
|
36 |
- "source": [ |
|
37 |
- "times = []\n", |
|
38 |
- "xs = np.random.random((1000, 1000))\n", |
|
39 |
- "ys = np.random.random((1000, 1000))\n", |
|
40 |
- "for (i, (x, y)) in enumerate(zip(xs, ys)):\n", |
|
41 |
- " learner = learner.Learner1D(x[:i+2], y[:i+2])\n", |
|
42 |
- " start = time()\n", |
|
43 |
- " learner.choose_points(n=1)\n", |
|
44 |
- " stop = time()\n", |
|
45 |
- " times.append(stop-start)" |
|
46 |
- ] |
|
47 |
- }, |
|
48 |
- { |
|
49 |
- "cell_type": "code", |
|
50 |
- "execution_count": null, |
|
51 |
- "metadata": {}, |
|
52 |
- "outputs": [], |
|
53 |
- "source": [ |
|
54 |
- "hv.Curve(times)" |
|
55 |
- ] |
|
56 |
- } |
|
57 |
- ], |
|
58 |
- "metadata": { |
|
59 |
- "anaconda-cloud": {}, |
|
60 |
- "kernelspec": { |
|
61 |
- "display_name": "Python [conda env:py36]", |
|
62 |
- "language": "python", |
|
63 |
- "name": "conda-env-py36-py" |
|
64 |
- }, |
|
65 |
- "language_info": { |
|
66 |
- "codemirror_mode": { |
|
67 |
- "name": "ipython", |
|
68 |
- "version": 3 |
|
69 |
- }, |
|
70 |
- "file_extension": ".py", |
|
71 |
- "mimetype": "text/x-python", |
|
72 |
- "name": "python", |
|
73 |
- "nbconvert_exporter": "python", |
|
74 |
- "pygments_lexer": "ipython3", |
|
75 |
- "version": "3.6.0" |
|
76 |
- } |
|
77 |
- }, |
|
78 |
- "nbformat": 4, |
|
79 |
- "nbformat_minor": 1 |
|
80 |
-} |
81 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,132 +0,0 @@ |
1 |
-{ |
|
2 |
- "cells": [ |
|
3 |
- { |
|
4 |
- "cell_type": "markdown", |
|
5 |
- "metadata": {}, |
|
6 |
- "source": [ |
|
7 |
- "# Adaptive" |
|
8 |
- ] |
|
9 |
- }, |
|
10 |
- { |
|
11 |
- "cell_type": "code", |
|
12 |
- "execution_count": null, |
|
13 |
- "metadata": {}, |
|
14 |
- "outputs": [], |
|
15 |
- "source": [ |
|
16 |
- "import holoviews as hv\n", |
|
17 |
- "hv.notebook_extension()" |
|
18 |
- ] |
|
19 |
- }, |
|
20 |
- { |
|
21 |
- "cell_type": "code", |
|
22 |
- "execution_count": null, |
|
23 |
- "metadata": {}, |
|
24 |
- "outputs": [], |
|
25 |
- "source": [ |
|
26 |
- "import numpy as np\n", |
|
27 |
- "import learner\n", |
|
28 |
- "import importlib\n", |
|
29 |
- "importlib.reload(learner)\n", |
|
30 |
- "\n", |
|
31 |
- "def func(x):\n", |
|
32 |
- " \"\"\"Function with a sharp peak on a smooth background\"\"\"\n", |
|
33 |
- " x = np.asarray(x)\n", |
|
34 |
- " a = 0.01\n", |
|
35 |
- " return x + a**2/(a**2 + x**2)\n", |
|
36 |
- "\n", |
|
37 |
- "def plot(learner, nan_is_zero=False, interpolation=False):\n", |
|
38 |
- " if interpolation:\n", |
|
39 |
- " learner.interpolate()\n", |
|
40 |
- " d = learner.interp_data\n", |
|
41 |
- " else:\n", |
|
42 |
- " d = learner.data\n", |
|
43 |
- "\n", |
|
44 |
- " xy = [(k, d[k]) for k in sorted(d)]\n", |
|
45 |
- " x, y = np.array(xy, dtype=float).T\n", |
|
46 |
- "\n", |
|
47 |
- " if nan_is_zero:\n", |
|
48 |
- " y = np.nan_to_num(y)\n", |
|
49 |
- " return hv.Scatter((x, y))" |
|
50 |
- ] |
|
51 |
- }, |
|
52 |
- { |
|
53 |
- "cell_type": "markdown", |
|
54 |
- "metadata": {}, |
|
55 |
- "source": [ |
|
56 |
- "# With direct results" |
|
57 |
- ] |
|
58 |
- }, |
|
59 |
- { |
|
60 |
- "cell_type": "code", |
|
61 |
- "execution_count": null, |
|
62 |
- "metadata": {}, |
|
63 |
- "outputs": [], |
|
64 |
- "source": [ |
|
65 |
- "hm = {}\n", |
|
66 |
- "xs = np.linspace(-1, 1, 5)\n", |
|
67 |
- "ys = func(xs)\n", |
|
68 |
- "learner = learner.Learner1D(xs, ys)\n", |
|
69 |
- "hm[0] = plot(learner)\n", |
|
70 |
- "\n", |
|
71 |
- "for i in range(1, 30):\n", |
|
72 |
- " xs = learner.choose_points(n=1, add_to_data=True)\n", |
|
73 |
- " ys = func(xs)\n", |
|
74 |
- " learner.add_data(xs, ys)\n", |
|
75 |
- " hm[i] = plot(learner, nan_is_zero=True)\n", |
|
76 |
- " \n", |
|
77 |
- "hv.HoloMap(hm)" |
|
78 |
- ] |
|
79 |
- }, |
|
80 |
- { |
|
81 |
- "cell_type": "markdown", |
|
82 |
- "metadata": {}, |
|
83 |
- "source": [ |
|
84 |
- "# With `concurrent.futures`\n", |
|
85 |
- "\n", |
|
86 |
- "It's plotting the points without a result at zero" |
|
87 |
- ] |
|
88 |
- }, |
|
89 |
- { |
|
90 |
- "cell_type": "code", |
|
91 |
- "execution_count": null, |
|
92 |
- "metadata": {}, |
|
93 |
- "outputs": [], |
|
94 |
- "source": [ |
|
95 |
- "hm = {}\n", |
|
96 |
- "xs = np.linspace(-1, 1, 5)\n", |
|
97 |
- "ys = func(xs)\n", |
|
98 |
- "learner = learner.Learner1D(xs, ys)\n", |
|
99 |
- "hm[0] = plot(learner)\n", |
|
100 |
- "\n", |
|
101 |
- "for i in range(1, 20):\n", |
|
102 |
- " xs = learner.choose_points(n=1)\n", |
|
103 |
- " # Do not calculate ys here (as if it's a `concurrent.futures`)\n", |
|
104 |
- " hm[i] = plot(learner, interpolation=True)\n", |
|
105 |
- " \n", |
|
106 |
- "hv.HoloMap(hm)" |
|
107 |
- ] |
|
108 |
- } |
|
109 |
- ], |
|
110 |
- "metadata": { |
|
111 |
- "anaconda-cloud": {}, |
|
112 |
- "kernelspec": { |
|
113 |
- "display_name": "Python [conda env:py36]", |
|
114 |
- "language": "python", |
|
115 |
- "name": "conda-env-py36-py" |
|
116 |
- }, |
|
117 |
- "language_info": { |
|
118 |
- "codemirror_mode": { |
|
119 |
- "name": "ipython", |
|
120 |
- "version": 3 |
|
121 |
- }, |
|
122 |
- "file_extension": ".py", |
|
123 |
- "mimetype": "text/x-python", |
|
124 |
- "name": "python", |
|
125 |
- "nbconvert_exporter": "python", |
|
126 |
- "pygments_lexer": "ipython3", |
|
127 |
- "version": "3.6.0" |
|
128 |
- } |
|
129 |
- }, |
|
130 |
- "nbformat": 4, |
|
131 |
- "nbformat_minor": 1 |
|
132 |
-} |
133 | 0 |
similarity index 95% |
134 | 1 |
rename from Learner-parallel-plotter.ipynb |
135 | 2 |
rename to learner.ipynb |
... | ... |
@@ -10,7 +10,9 @@ |
10 | 10 |
{ |
11 | 11 |
"cell_type": "code", |
12 | 12 |
"execution_count": null, |
13 |
- "metadata": {}, |
|
13 |
+ "metadata": { |
|
14 |
+ "collapsed": true |
|
15 |
+ }, |
|
14 | 16 |
"outputs": [], |
15 | 17 |
"source": [ |
16 | 18 |
"import adaptive\n", |
... | ... |
@@ -42,6 +44,7 @@ |
42 | 44 |
"cell_type": "code", |
43 | 45 |
"execution_count": null, |
44 | 46 |
"metadata": { |
47 |
+ "collapsed": true, |
|
45 | 48 |
"scrolled": false |
46 | 49 |
}, |
47 | 50 |
"outputs": [], |
... | ... |
@@ -54,7 +57,9 @@ |
54 | 57 |
{ |
55 | 58 |
"cell_type": "code", |
56 | 59 |
"execution_count": null, |
57 |
- "metadata": {}, |
|
60 |
+ "metadata": { |
|
61 |
+ "collapsed": true |
|
62 |
+ }, |
|
58 | 63 |
"outputs": [], |
59 | 64 |
"source": [ |
60 | 65 |
"# Same function evaluated on homogeneous grid with same amount of points\n", |
... | ... |
@@ -105,6 +110,7 @@ |
105 | 110 |
"cell_type": "code", |
106 | 111 |
"execution_count": null, |
107 | 112 |
"metadata": { |
113 |
+ "collapsed": true, |
|
108 | 114 |
"scrolled": false |
109 | 115 |
}, |
110 | 116 |
"outputs": [], |