Show More
@@ -1,770 +1,605 b'' | |||||
1 | { |
|
1 | { | |
2 | "metadata": { |
|
2 | "metadata": { | |
|
3 | "kernelspec": { | |||
|
4 | "codemirror_mode": { | |||
|
5 | "name": "ipython", | |||
|
6 | "version": 3 | |||
|
7 | }, | |||
|
8 | "display_name": "IPython (Python 3)", | |||
|
9 | "language": "python", | |||
|
10 | "name": "python3" | |||
|
11 | }, | |||
3 | "name": "", |
|
12 | "name": "", | |
4 | "signature": "sha256:6d8c7c51322c4911e478068e8fa8e897bd72c614096f5df110ed86d01d66001c" |
|
13 | "signature": "sha256:1bbd16f32ec50ec64d4dd646cd6868aeace8091cac989107f2026fc688ca3701" | |
5 | }, |
|
14 | }, | |
6 | "nbformat": 3, |
|
15 | "nbformat": 3, | |
7 | "nbformat_minor": 0, |
|
16 | "nbformat_minor": 0, | |
8 | "worksheets": [ |
|
17 | "worksheets": [ | |
9 | { |
|
18 | { | |
10 | "cells": [ |
|
19 | "cells": [ | |
11 | { |
|
20 | { | |
12 | "cell_type": "heading", |
|
21 | "cell_type": "heading", | |
13 | "level": 1, |
|
22 | "level": 1, | |
14 | "metadata": {}, |
|
23 | "metadata": {}, | |
15 | "source": [ |
|
24 | "source": [ | |
16 | "Using Interact" |
|
25 | "Using Interact" | |
17 | ] |
|
26 | ] | |
18 | }, |
|
27 | }, | |
19 | { |
|
28 | { | |
20 | "cell_type": "markdown", |
|
29 | "cell_type": "markdown", | |
21 | "metadata": {}, |
|
30 | "metadata": {}, | |
22 | "source": [ |
|
31 | "source": [ | |
23 | "The `interact` function (`IPython.html.widgets.interact`) automatically creates user interface (UI) controls for exploring code and data interactively. It is the easiest way to get started using IPython's widgets." |
|
32 | "The `interact` function (`IPython.html.widgets.interact`) automatically creates user interface (UI) controls for exploring code and data interactively. It is the easiest way to get started using IPython's widgets." | |
24 | ] |
|
33 | ] | |
25 | }, |
|
34 | }, | |
26 | { |
|
35 | { | |
27 | "cell_type": "code", |
|
36 | "cell_type": "code", | |
28 | "collapsed": false, |
|
37 | "collapsed": false, | |
29 | "input": [ |
|
38 | "input": [ | |
|
39 | "from __future__ import print_function\n", | |||
30 | "from IPython.html.widgets import interact, interactive, fixed\n", |
|
40 | "from IPython.html.widgets import interact, interactive, fixed\n", | |
31 | "from IPython.html import widgets" |
|
41 | "from IPython.html import widgets" | |
32 | ], |
|
42 | ], | |
33 | "language": "python", |
|
43 | "language": "python", | |
34 | "metadata": {}, |
|
44 | "metadata": {}, | |
35 |
"outputs": [] |
|
45 | "outputs": [] | |
36 | "prompt_number": 1 |
|
|||
37 | }, |
|
46 | }, | |
38 | { |
|
47 | { | |
39 | "cell_type": "markdown", |
|
48 | "cell_type": "markdown", | |
40 | "metadata": {}, |
|
49 | "metadata": {}, | |
41 | "source": [ |
|
50 | "source": [ | |
42 | "<div class=\"alert alert-success\">\n", |
|
51 | "<div class=\"alert alert-success\">\n", | |
43 | "As of IPython 2.0, the widgets in this notebook won't show up on http://nbviewer.ipython.org. To view the widgets and interact with them, you will need to download this notebook and run it with an IPython Notebook server.\n", |
|
52 | "As of IPython 2.0, the widgets in this notebook won't show up on http://nbviewer.ipython.org. To view the widgets and interact with them, you will need to download this notebook and run it with an IPython Notebook server.\n", | |
44 | "</div>" |
|
53 | "</div>" | |
45 | ] |
|
54 | ] | |
46 | }, |
|
55 | }, | |
47 | { |
|
56 | { | |
48 | "cell_type": "heading", |
|
57 | "cell_type": "heading", | |
49 | "level": 2, |
|
58 | "level": 2, | |
50 | "metadata": {}, |
|
59 | "metadata": {}, | |
51 | "source": [ |
|
60 | "source": [ | |
52 | "Basic `interact`" |
|
61 | "Basic `interact`" | |
53 | ] |
|
62 | ] | |
54 | }, |
|
63 | }, | |
55 | { |
|
64 | { | |
56 | "cell_type": "markdown", |
|
65 | "cell_type": "markdown", | |
57 | "metadata": {}, |
|
66 | "metadata": {}, | |
58 | "source": [ |
|
67 | "source": [ | |
59 | "At the most basic level, `interact` autogenerates UI controls for function arguments, and then calls the function with those arguments when you manipulate the controls interactively. To use `interact`, you need to define a function that you want to explore. Here is a function that prints its only argument `x`." |
|
68 | "At the most basic level, `interact` autogenerates UI controls for function arguments, and then calls the function with those arguments when you manipulate the controls interactively. To use `interact`, you need to define a function that you want to explore. Here is a function that prints its only argument `x`." | |
60 | ] |
|
69 | ] | |
61 | }, |
|
70 | }, | |
62 | { |
|
71 | { | |
63 | "cell_type": "code", |
|
72 | "cell_type": "code", | |
64 | "collapsed": false, |
|
73 | "collapsed": false, | |
65 | "input": [ |
|
74 | "input": [ | |
66 | "def f(x):\n", |
|
75 | "def f(x):\n", | |
67 |
" print |
|
76 | " print(x)" | |
68 | ], |
|
77 | ], | |
69 | "language": "python", |
|
78 | "language": "python", | |
70 | "metadata": {}, |
|
79 | "metadata": {}, | |
71 |
"outputs": [] |
|
80 | "outputs": [] | |
72 | "prompt_number": 2 |
|
|||
73 | }, |
|
81 | }, | |
74 | { |
|
82 | { | |
75 | "cell_type": "markdown", |
|
83 | "cell_type": "markdown", | |
76 | "metadata": {}, |
|
84 | "metadata": {}, | |
77 | "source": [ |
|
85 | "source": [ | |
78 | "When you pass this function as the first argument to `interact` along with an integer keyword argument (`x=10`), a slider is generated and bound to the function." |
|
86 | "When you pass this function as the first argument to `interact` along with an integer keyword argument (`x=10`), a slider is generated and bound to the function." | |
79 | ] |
|
87 | ] | |
80 | }, |
|
88 | }, | |
81 | { |
|
89 | { | |
82 | "cell_type": "code", |
|
90 | "cell_type": "code", | |
83 | "collapsed": false, |
|
91 | "collapsed": false, | |
84 | "input": [ |
|
92 | "input": [ | |
85 | "interact(f, x=10);" |
|
93 | "interact(f, x=10);" | |
86 | ], |
|
94 | ], | |
87 | "language": "python", |
|
95 | "language": "python", | |
88 | "metadata": {}, |
|
96 | "metadata": {}, | |
89 | "outputs": [ |
|
97 | "outputs": [] | |
90 | { |
|
|||
91 | "output_type": "stream", |
|
|||
92 | "stream": "stdout", |
|
|||
93 | "text": [ |
|
|||
94 | "9\n" |
|
|||
95 | ] |
|
|||
96 | } |
|
|||
97 | ], |
|
|||
98 | "prompt_number": 3 |
|
|||
99 | }, |
|
98 | }, | |
100 | { |
|
99 | { | |
101 | "cell_type": "markdown", |
|
100 | "cell_type": "markdown", | |
102 | "metadata": {}, |
|
101 | "metadata": {}, | |
103 | "source": [ |
|
102 | "source": [ | |
104 | "When you move the slider, the function is called and the current value of `x` is printed.\n", |
|
103 | "When you move the slider, the function is called and the current value of `x` is printed.\n", | |
105 | "\n", |
|
104 | "\n", | |
106 | "If you pass `True` or `False`, `interact` will generate a checkbox:" |
|
105 | "If you pass `True` or `False`, `interact` will generate a checkbox:" | |
107 | ] |
|
106 | ] | |
108 | }, |
|
107 | }, | |
109 | { |
|
108 | { | |
110 | "cell_type": "code", |
|
109 | "cell_type": "code", | |
111 | "collapsed": false, |
|
110 | "collapsed": false, | |
112 | "input": [ |
|
111 | "input": [ | |
113 | "interact(f, x=True);" |
|
112 | "interact(f, x=True);" | |
114 | ], |
|
113 | ], | |
115 | "language": "python", |
|
114 | "language": "python", | |
116 | "metadata": {}, |
|
115 | "metadata": {}, | |
117 | "outputs": [ |
|
116 | "outputs": [] | |
118 | { |
|
|||
119 | "output_type": "stream", |
|
|||
120 | "stream": "stdout", |
|
|||
121 | "text": [ |
|
|||
122 | "True\n" |
|
|||
123 | ] |
|
|||
124 | } |
|
|||
125 | ], |
|
|||
126 | "prompt_number": 4 |
|
|||
127 | }, |
|
117 | }, | |
128 | { |
|
118 | { | |
129 | "cell_type": "markdown", |
|
119 | "cell_type": "markdown", | |
130 | "metadata": {}, |
|
120 | "metadata": {}, | |
131 | "source": [ |
|
121 | "source": [ | |
132 | "If you pass a string, `interact` will generate a text area." |
|
122 | "If you pass a string, `interact` will generate a text area." | |
133 | ] |
|
123 | ] | |
134 | }, |
|
124 | }, | |
135 | { |
|
125 | { | |
136 | "cell_type": "code", |
|
126 | "cell_type": "code", | |
137 | "collapsed": false, |
|
127 | "collapsed": false, | |
138 | "input": [ |
|
128 | "input": [ | |
139 | "interact(f, x='Hi there!');" |
|
129 | "interact(f, x='Hi there!');" | |
140 | ], |
|
130 | ], | |
141 | "language": "python", |
|
131 | "language": "python", | |
142 | "metadata": {}, |
|
132 | "metadata": {}, | |
143 | "outputs": [ |
|
133 | "outputs": [] | |
144 | { |
|
|||
145 | "output_type": "stream", |
|
|||
146 | "stream": "stdout", |
|
|||
147 | "text": [ |
|
|||
148 | "Hi there!\n" |
|
|||
149 | ] |
|
|||
150 | } |
|
|||
151 | ], |
|
|||
152 | "prompt_number": 5 |
|
|||
153 | }, |
|
134 | }, | |
154 | { |
|
135 | { | |
155 | "cell_type": "markdown", |
|
136 | "cell_type": "markdown", | |
156 | "metadata": {}, |
|
137 | "metadata": {}, | |
157 | "source": [ |
|
138 | "source": [ | |
158 | "`interact` can also be used as a decorator. This allows you to define a function and interact with it in a single shot. As this example shows, `interact` also works with functions that have multiple arguments." |
|
139 | "`interact` can also be used as a decorator. This allows you to define a function and interact with it in a single shot. As this example shows, `interact` also works with functions that have multiple arguments." | |
159 | ] |
|
140 | ] | |
160 | }, |
|
141 | }, | |
161 | { |
|
142 | { | |
162 | "cell_type": "code", |
|
143 | "cell_type": "code", | |
163 | "collapsed": false, |
|
144 | "collapsed": false, | |
164 | "input": [ |
|
145 | "input": [ | |
165 | "@interact(x=True, y=1.0)\n", |
|
146 | "@interact(x=True, y=1.0)\n", | |
166 | "def g(x, y):\n", |
|
147 | "def g(x, y):\n", | |
167 |
" print |
|
148 | " print(x, y)" | |
168 | ], |
|
149 | ], | |
169 | "language": "python", |
|
150 | "language": "python", | |
170 | "metadata": {}, |
|
151 | "metadata": {}, | |
171 | "outputs": [ |
|
152 | "outputs": [] | |
172 | { |
|
|||
173 | "output_type": "stream", |
|
|||
174 | "stream": "stdout", |
|
|||
175 | "text": [ |
|
|||
176 | "True 1.0\n" |
|
|||
177 | ] |
|
|||
178 | } |
|
|||
179 | ], |
|
|||
180 | "prompt_number": 6 |
|
|||
181 | }, |
|
153 | }, | |
182 | { |
|
154 | { | |
183 | "cell_type": "heading", |
|
155 | "cell_type": "heading", | |
184 | "level": 2, |
|
156 | "level": 2, | |
185 | "metadata": {}, |
|
157 | "metadata": {}, | |
186 | "source": [ |
|
158 | "source": [ | |
187 | "Fixing arguments using `fixed`" |
|
159 | "Fixing arguments using `fixed`" | |
188 | ] |
|
160 | ] | |
189 | }, |
|
161 | }, | |
190 | { |
|
162 | { | |
191 | "cell_type": "markdown", |
|
163 | "cell_type": "markdown", | |
192 | "metadata": {}, |
|
164 | "metadata": {}, | |
193 | "source": [ |
|
165 | "source": [ | |
194 | "There are times when you may want to explore a function using `interact`, but fix one or more of its arguments to specific values. This can be accomplished by wrapping values with the `fixed` function." |
|
166 | "There are times when you may want to explore a function using `interact`, but fix one or more of its arguments to specific values. This can be accomplished by wrapping values with the `fixed` function." | |
195 | ] |
|
167 | ] | |
196 | }, |
|
168 | }, | |
197 | { |
|
169 | { | |
198 | "cell_type": "code", |
|
170 | "cell_type": "code", | |
199 | "collapsed": false, |
|
171 | "collapsed": false, | |
200 | "input": [ |
|
172 | "input": [ | |
201 | "def h(p, q):\n", |
|
173 | "def h(p, q):\n", | |
202 |
" print |
|
174 | " print(p, q)" | |
203 | ], |
|
175 | ], | |
204 | "language": "python", |
|
176 | "language": "python", | |
205 | "metadata": {}, |
|
177 | "metadata": {}, | |
206 |
"outputs": [] |
|
178 | "outputs": [] | |
207 | "prompt_number": 7 |
|
|||
208 | }, |
|
179 | }, | |
209 | { |
|
180 | { | |
210 | "cell_type": "markdown", |
|
181 | "cell_type": "markdown", | |
211 | "metadata": {}, |
|
182 | "metadata": {}, | |
212 | "source": [ |
|
183 | "source": [ | |
213 | "When we call `interact`, we pass `fixed(20)` for q to hold it fixed at a value of `20`." |
|
184 | "When we call `interact`, we pass `fixed(20)` for q to hold it fixed at a value of `20`." | |
214 | ] |
|
185 | ] | |
215 | }, |
|
186 | }, | |
216 | { |
|
187 | { | |
217 | "cell_type": "code", |
|
188 | "cell_type": "code", | |
218 | "collapsed": false, |
|
189 | "collapsed": false, | |
219 | "input": [ |
|
190 | "input": [ | |
220 | "interact(h, p=5, q=fixed(20));" |
|
191 | "interact(h, p=5, q=fixed(20));" | |
221 | ], |
|
192 | ], | |
222 | "language": "python", |
|
193 | "language": "python", | |
223 | "metadata": {}, |
|
194 | "metadata": {}, | |
224 | "outputs": [ |
|
195 | "outputs": [] | |
225 | { |
|
|||
226 | "output_type": "stream", |
|
|||
227 | "stream": "stdout", |
|
|||
228 | "text": [ |
|
|||
229 | "5 20\n" |
|
|||
230 | ] |
|
|||
231 | } |
|
|||
232 | ], |
|
|||
233 | "prompt_number": 8 |
|
|||
234 | }, |
|
196 | }, | |
235 | { |
|
197 | { | |
236 | "cell_type": "markdown", |
|
198 | "cell_type": "markdown", | |
237 | "metadata": {}, |
|
199 | "metadata": {}, | |
238 | "source": [ |
|
200 | "source": [ | |
239 | "Notice that a slider is only produced for `p` as the value of `q` is fixed." |
|
201 | "Notice that a slider is only produced for `p` as the value of `q` is fixed." | |
240 | ] |
|
202 | ] | |
241 | }, |
|
203 | }, | |
242 | { |
|
204 | { | |
243 | "cell_type": "heading", |
|
205 | "cell_type": "heading", | |
244 | "level": 2, |
|
206 | "level": 2, | |
245 | "metadata": {}, |
|
207 | "metadata": {}, | |
246 | "source": [ |
|
208 | "source": [ | |
247 | "Widget abbreviations" |
|
209 | "Widget abbreviations" | |
248 | ] |
|
210 | ] | |
249 | }, |
|
211 | }, | |
250 | { |
|
212 | { | |
251 | "cell_type": "markdown", |
|
213 | "cell_type": "markdown", | |
252 | "metadata": {}, |
|
214 | "metadata": {}, | |
253 | "source": [ |
|
215 | "source": [ | |
254 | "When you pass an integer valued keyword argument (`x=10`) to `interact`, it generates an integer valued slider control with a range of $[-10,+3\\times10]$. In this case `10` is an *abbreviation* for an actual slider widget:\n", |
|
216 | "When you pass an integer valued keyword argument (`x=10`) to `interact`, it generates an integer valued slider control with a range of $[-10,+3\\times10]$. In this case `10` is an *abbreviation* for an actual slider widget:\n", | |
255 | "\n", |
|
217 | "\n", | |
256 | "```python\n", |
|
218 | "```python\n", | |
257 | "IntSliderWidget(min=-10,max=30,step=1,value=10)\n", |
|
219 | "IntSliderWidget(min=-10,max=30,step=1,value=10)\n", | |
258 | "```\n", |
|
220 | "```\n", | |
259 | "\n", |
|
221 | "\n", | |
260 | "In fact, we can get the same result if we pass this `IntSliderWidget` as the keyword argument for `x`:" |
|
222 | "In fact, we can get the same result if we pass this `IntSliderWidget` as the keyword argument for `x`:" | |
261 | ] |
|
223 | ] | |
262 | }, |
|
224 | }, | |
263 | { |
|
225 | { | |
264 | "cell_type": "code", |
|
226 | "cell_type": "code", | |
265 | "collapsed": false, |
|
227 | "collapsed": false, | |
266 | "input": [ |
|
228 | "input": [ | |
267 | "interact(f, x=widgets.IntSliderWidget(min=-10,max=30,step=1,value=10));" |
|
229 | "interact(f, x=widgets.IntSliderWidget(min=-10,max=30,step=1,value=10));" | |
268 | ], |
|
230 | ], | |
269 | "language": "python", |
|
231 | "language": "python", | |
270 | "metadata": {}, |
|
232 | "metadata": {}, | |
271 | "outputs": [ |
|
233 | "outputs": [] | |
272 | { |
|
|||
273 | "output_type": "stream", |
|
|||
274 | "stream": "stdout", |
|
|||
275 | "text": [ |
|
|||
276 | "10\n" |
|
|||
277 | ] |
|
|||
278 | } |
|
|||
279 | ], |
|
|||
280 | "prompt_number": 9 |
|
|||
281 | }, |
|
234 | }, | |
282 | { |
|
235 | { | |
283 | "cell_type": "markdown", |
|
236 | "cell_type": "markdown", | |
284 | "metadata": {}, |
|
237 | "metadata": {}, | |
285 | "source": [ |
|
238 | "source": [ | |
286 | "This examples clarifies how `interact` proceses its keyword arguments:\n", |
|
239 | "This examples clarifies how `interact` proceses its keyword arguments:\n", | |
287 | "\n", |
|
240 | "\n", | |
288 | "1. If the keyword argument is `Widget` instance with a `value` attribute, that widget is used. Any widget with a `value` attribute can be used, even custom ones.\n", |
|
241 | "1. If the keyword argument is `Widget` instance with a `value` attribute, that widget is used. Any widget with a `value` attribute can be used, even custom ones.\n", | |
289 | "2. Otherwise, the value is treated as a *widget abbreviation* that is converted to a widget before it is used.\n", |
|
242 | "2. Otherwise, the value is treated as a *widget abbreviation* that is converted to a widget before it is used.\n", | |
290 | "\n", |
|
243 | "\n", | |
291 | "The following table gives an overview of different widget abbreviations:\n", |
|
244 | "The following table gives an overview of different widget abbreviations:\n", | |
292 | "\n", |
|
245 | "\n", | |
293 | "<table class=\"table table-condensed table-bordered\">\n", |
|
246 | "<table class=\"table table-condensed table-bordered\">\n", | |
294 | " <tr><td><strong>Keyword argument</strong></td><td><strong>Widget</strong></td></tr> \n", |
|
247 | " <tr><td><strong>Keyword argument</strong></td><td><strong>Widget</strong></td></tr> \n", | |
295 | " <tr><td>`True` or `False`</td><td>CheckboxWiget</td></tr> \n", |
|
248 | " <tr><td>`True` or `False`</td><td>CheckboxWiget</td></tr> \n", | |
296 | " <tr><td>`'Hi there'`</td><td>TextareaWidget</td></tr>\n", |
|
249 | " <tr><td>`'Hi there'`</td><td>TextareaWidget</td></tr>\n", | |
297 | " <tr><td>`value` or `(min,max)` or `(min,max,step)` if integers are passed</td><td>IntSliderWidget</td></tr>\n", |
|
250 | " <tr><td>`value` or `(min,max)` or `(min,max,step)` if integers are passed</td><td>IntSliderWidget</td></tr>\n", | |
298 | " <tr><td>`value` or `(min,max)` or `(min,max,step)` if floats are passed</td><td>FloatSliderWidget</td></tr>\n", |
|
251 | " <tr><td>`value` or `(min,max)` or `(min,max,step)` if floats are passed</td><td>FloatSliderWidget</td></tr>\n", | |
299 | " <tr><td>`('orange','apple')` or `{'one':1,'two':2}`</td><td>DropdownWidget</td></tr>\n", |
|
252 | " <tr><td>`('orange','apple')` or `{'one':1,'two':2}`</td><td>DropdownWidget</td></tr>\n", | |
300 | "</table>" |
|
253 | "</table>" | |
301 | ] |
|
254 | ] | |
302 | }, |
|
255 | }, | |
303 | { |
|
256 | { | |
304 | "cell_type": "markdown", |
|
257 | "cell_type": "markdown", | |
305 | "metadata": {}, |
|
258 | "metadata": {}, | |
306 | "source": [ |
|
259 | "source": [ | |
307 | "You have seen how the checkbox and textarea widgets work above. Here, more details about the different abbreviations for sliders and dropdowns are given.\n", |
|
260 | "You have seen how the checkbox and textarea widgets work above. Here, more details about the different abbreviations for sliders and dropdowns are given.\n", | |
308 | "\n", |
|
261 | "\n", | |
309 | "If a 2-tuple of integers is passed `(min,max)` a integer valued slider is produced with those minimum and maximum (inclusive) values. In this case, the default step size of `1` is used." |
|
262 | "If a 2-tuple of integers is passed `(min,max)` a integer valued slider is produced with those minimum and maximum (inclusive) values. In this case, the default step size of `1` is used." | |
310 | ] |
|
263 | ] | |
311 | }, |
|
264 | }, | |
312 | { |
|
265 | { | |
313 | "cell_type": "code", |
|
266 | "cell_type": "code", | |
314 | "collapsed": false, |
|
267 | "collapsed": false, | |
315 | "input": [ |
|
268 | "input": [ | |
316 | "interact(f, x=(0,4));" |
|
269 | "interact(f, x=(0,4));" | |
317 | ], |
|
270 | ], | |
318 | "language": "python", |
|
271 | "language": "python", | |
319 | "metadata": {}, |
|
272 | "metadata": {}, | |
320 | "outputs": [ |
|
273 | "outputs": [] | |
321 | { |
|
|||
322 | "output_type": "stream", |
|
|||
323 | "stream": "stdout", |
|
|||
324 | "text": [ |
|
|||
325 | "2\n" |
|
|||
326 | ] |
|
|||
327 | } |
|
|||
328 | ], |
|
|||
329 | "prompt_number": 10 |
|
|||
330 | }, |
|
274 | }, | |
331 | { |
|
275 | { | |
332 | "cell_type": "markdown", |
|
276 | "cell_type": "markdown", | |
333 | "metadata": {}, |
|
277 | "metadata": {}, | |
334 | "source": [ |
|
278 | "source": [ | |
335 | "If a 3-tuple of integers is passed `(min,max,step)` the step size can also be set." |
|
279 | "If a 3-tuple of integers is passed `(min,max,step)` the step size can also be set." | |
336 | ] |
|
280 | ] | |
337 | }, |
|
281 | }, | |
338 | { |
|
282 | { | |
339 | "cell_type": "code", |
|
283 | "cell_type": "code", | |
340 | "collapsed": false, |
|
284 | "collapsed": false, | |
341 | "input": [ |
|
285 | "input": [ | |
342 | "interact(f, x=(0,8,2));" |
|
286 | "interact(f, x=(0,8,2));" | |
343 | ], |
|
287 | ], | |
344 | "language": "python", |
|
288 | "language": "python", | |
345 | "metadata": {}, |
|
289 | "metadata": {}, | |
346 | "outputs": [ |
|
290 | "outputs": [] | |
347 | { |
|
|||
348 | "output_type": "stream", |
|
|||
349 | "stream": "stdout", |
|
|||
350 | "text": [ |
|
|||
351 | "4\n" |
|
|||
352 | ] |
|
|||
353 | } |
|
|||
354 | ], |
|
|||
355 | "prompt_number": 11 |
|
|||
356 | }, |
|
291 | }, | |
357 | { |
|
292 | { | |
358 | "cell_type": "markdown", |
|
293 | "cell_type": "markdown", | |
359 | "metadata": {}, |
|
294 | "metadata": {}, | |
360 | "source": [ |
|
295 | "source": [ | |
361 | "A float valued slider is produced if the elements of the tuples are floats. Here the minimum is `0.0`, the maximum is `10.0` and step size is `0.1` (the default)." |
|
296 | "A float valued slider is produced if the elements of the tuples are floats. Here the minimum is `0.0`, the maximum is `10.0` and step size is `0.1` (the default)." | |
362 | ] |
|
297 | ] | |
363 | }, |
|
298 | }, | |
364 | { |
|
299 | { | |
365 | "cell_type": "code", |
|
300 | "cell_type": "code", | |
366 | "collapsed": false, |
|
301 | "collapsed": false, | |
367 | "input": [ |
|
302 | "input": [ | |
368 | "interact(f, x=(0.0,10.0));" |
|
303 | "interact(f, x=(0.0,10.0));" | |
369 | ], |
|
304 | ], | |
370 | "language": "python", |
|
305 | "language": "python", | |
371 | "metadata": {}, |
|
306 | "metadata": {}, | |
372 | "outputs": [ |
|
307 | "outputs": [] | |
373 | { |
|
|||
374 | "output_type": "stream", |
|
|||
375 | "stream": "stdout", |
|
|||
376 | "text": [ |
|
|||
377 | "5.0\n" |
|
|||
378 | ] |
|
|||
379 | } |
|
|||
380 | ], |
|
|||
381 | "prompt_number": 12 |
|
|||
382 | }, |
|
308 | }, | |
383 | { |
|
309 | { | |
384 | "cell_type": "markdown", |
|
310 | "cell_type": "markdown", | |
385 | "metadata": {}, |
|
311 | "metadata": {}, | |
386 | "source": [ |
|
312 | "source": [ | |
387 | "The step size can be changed by passing a 3rd element in the tuple." |
|
313 | "The step size can be changed by passing a 3rd element in the tuple." | |
388 | ] |
|
314 | ] | |
389 | }, |
|
315 | }, | |
390 | { |
|
316 | { | |
391 | "cell_type": "code", |
|
317 | "cell_type": "code", | |
392 | "collapsed": false, |
|
318 | "collapsed": false, | |
393 | "input": [ |
|
319 | "input": [ | |
394 | "interact(f, x=(0.0,10.0,0.01));" |
|
320 | "interact(f, x=(0.0,10.0,0.01));" | |
395 | ], |
|
321 | ], | |
396 | "language": "python", |
|
322 | "language": "python", | |
397 | "metadata": {}, |
|
323 | "metadata": {}, | |
398 | "outputs": [ |
|
324 | "outputs": [] | |
399 | { |
|
|||
400 | "output_type": "stream", |
|
|||
401 | "stream": "stdout", |
|
|||
402 | "text": [ |
|
|||
403 | "4.99\n" |
|
|||
404 | ] |
|
|||
405 | } |
|
|||
406 | ], |
|
|||
407 | "prompt_number": 13 |
|
|||
408 | }, |
|
325 | }, | |
409 | { |
|
326 | { | |
410 | "cell_type": "markdown", |
|
327 | "cell_type": "markdown", | |
411 | "metadata": {}, |
|
328 | "metadata": {}, | |
412 | "source": [ |
|
329 | "source": [ | |
413 | "For both integer and float valued sliders, you can pick the initial value of the widget by passing a default keyword argument to the underlying Python function. Here we set the initial value of a float slider to `5.5`." |
|
330 | "For both integer and float valued sliders, you can pick the initial value of the widget by passing a default keyword argument to the underlying Python function. Here we set the initial value of a float slider to `5.5`." | |
414 | ] |
|
331 | ] | |
415 | }, |
|
332 | }, | |
416 | { |
|
333 | { | |
417 | "cell_type": "code", |
|
334 | "cell_type": "code", | |
418 | "collapsed": false, |
|
335 | "collapsed": false, | |
419 | "input": [ |
|
336 | "input": [ | |
420 | "@interact(x=(0.0,20.0,0.5))\n", |
|
337 | "@interact(x=(0.0,20.0,0.5))\n", | |
421 | "def h(x=5.5):\n", |
|
338 | "def h(x=5.5):\n", | |
422 |
" print |
|
339 | " print(x)" | |
423 | ], |
|
340 | ], | |
424 | "language": "python", |
|
341 | "language": "python", | |
425 | "metadata": {}, |
|
342 | "metadata": {}, | |
426 | "outputs": [ |
|
343 | "outputs": [] | |
427 | { |
|
|||
428 | "output_type": "stream", |
|
|||
429 | "stream": "stdout", |
|
|||
430 | "text": [ |
|
|||
431 | "5.5\n" |
|
|||
432 | ] |
|
|||
433 | } |
|
|||
434 | ], |
|
|||
435 | "prompt_number": 14 |
|
|||
436 | }, |
|
344 | }, | |
437 | { |
|
345 | { | |
438 | "cell_type": "markdown", |
|
346 | "cell_type": "markdown", | |
439 | "metadata": {}, |
|
347 | "metadata": {}, | |
440 | "source": [ |
|
348 | "source": [ | |
441 | "Dropdown menus can be produced by passing a tuple of strings. In this case, the strings are both used as the names in the dropdown menu UI and passed to the underlying Python function." |
|
349 | "Dropdown menus can be produced by passing a tuple of strings. In this case, the strings are both used as the names in the dropdown menu UI and passed to the underlying Python function." | |
442 | ] |
|
350 | ] | |
443 | }, |
|
351 | }, | |
444 | { |
|
352 | { | |
445 | "cell_type": "code", |
|
353 | "cell_type": "code", | |
446 | "collapsed": false, |
|
354 | "collapsed": false, | |
447 | "input": [ |
|
355 | "input": [ | |
448 | "interact(f, x=('apples','oranges'));" |
|
356 | "interact(f, x=('apples','oranges'));" | |
449 | ], |
|
357 | ], | |
450 | "language": "python", |
|
358 | "language": "python", | |
451 | "metadata": {}, |
|
359 | "metadata": {}, | |
452 | "outputs": [ |
|
360 | "outputs": [] | |
453 | { |
|
|||
454 | "output_type": "stream", |
|
|||
455 | "stream": "stdout", |
|
|||
456 | "text": [ |
|
|||
457 | "apples\n" |
|
|||
458 | ] |
|
|||
459 | } |
|
|||
460 | ], |
|
|||
461 | "prompt_number": 15 |
|
|||
462 | }, |
|
361 | }, | |
463 | { |
|
362 | { | |
464 | "cell_type": "markdown", |
|
363 | "cell_type": "markdown", | |
465 | "metadata": {}, |
|
364 | "metadata": {}, | |
466 | "source": [ |
|
365 | "source": [ | |
467 | "If you want a dropdown menu that passes non-string values to the Python function, you can pass a dictionary. The keys in the dictionary are used for the names in the dropdown menu UI and the values are the arguments that are passed to the underlying Python function." |
|
366 | "If you want a dropdown menu that passes non-string values to the Python function, you can pass a dictionary. The keys in the dictionary are used for the names in the dropdown menu UI and the values are the arguments that are passed to the underlying Python function." | |
468 | ] |
|
367 | ] | |
469 | }, |
|
368 | }, | |
470 | { |
|
369 | { | |
471 | "cell_type": "code", |
|
370 | "cell_type": "code", | |
472 | "collapsed": false, |
|
371 | "collapsed": false, | |
473 | "input": [ |
|
372 | "input": [ | |
474 | "interact(f, x={'one': 10, 'two': 20});" |
|
373 | "interact(f, x={'one': 10, 'two': 20});" | |
475 | ], |
|
374 | ], | |
476 | "language": "python", |
|
375 | "language": "python", | |
477 | "metadata": {}, |
|
376 | "metadata": {}, | |
478 | "outputs": [ |
|
377 | "outputs": [] | |
479 | { |
|
|||
480 | "output_type": "stream", |
|
|||
481 | "stream": "stdout", |
|
|||
482 | "text": [ |
|
|||
483 | "20\n" |
|
|||
484 | ] |
|
|||
485 | } |
|
|||
486 | ], |
|
|||
487 | "prompt_number": 16 |
|
|||
488 | }, |
|
378 | }, | |
489 | { |
|
379 | { | |
490 | "cell_type": "heading", |
|
380 | "cell_type": "heading", | |
491 | "level": 2, |
|
381 | "level": 2, | |
492 | "metadata": {}, |
|
382 | "metadata": {}, | |
493 | "source": [ |
|
383 | "source": [ | |
494 | "Using function annotations with `interact`" |
|
384 | "Using function annotations with `interact`" | |
495 | ] |
|
385 | ] | |
496 | }, |
|
386 | }, | |
497 | { |
|
387 | { | |
498 | "cell_type": "markdown", |
|
388 | "cell_type": "markdown", | |
499 | "metadata": {}, |
|
389 | "metadata": {}, | |
500 | "source": [ |
|
390 | "source": [ | |
501 | "If you are using Python 3, you can also specify widget abbreviations using [function annotations](https://docs.python.org/3/tutorial/controlflow.html#function-annotations). This is a convenient approach allows the widget abbreviations to be defined with a function.\n", |
|
391 | "If you are using Python 3, you can also specify widget abbreviations using [function annotations](https://docs.python.org/3/tutorial/controlflow.html#function-annotations). This is a convenient approach allows the widget abbreviations to be defined with a function.\n", | |
502 | "\n", |
|
392 | "\n", | |
503 | "Define a function with an checkbox widget abbreviation for the argument `x`." |
|
393 | "Define a function with an checkbox widget abbreviation for the argument `x`." | |
504 | ] |
|
394 | ] | |
505 | }, |
|
395 | }, | |
506 | { |
|
396 | { | |
507 | "cell_type": "code", |
|
397 | "cell_type": "code", | |
508 | "collapsed": false, |
|
398 | "collapsed": false, | |
509 | "input": [ |
|
399 | "input": [ | |
510 | "def f(x:True):\n", |
|
400 | "def f(x:True):\n", | |
511 |
" print |
|
401 | " print(x)" | |
512 | ], |
|
402 | ], | |
513 | "language": "python", |
|
403 | "language": "python", | |
514 | "metadata": {}, |
|
404 | "metadata": {}, | |
515 | "outputs": [] |
|
405 | "outputs": [] | |
516 | }, |
|
406 | }, | |
517 | { |
|
407 | { | |
518 | "cell_type": "markdown", |
|
408 | "cell_type": "markdown", | |
519 | "metadata": {}, |
|
409 | "metadata": {}, | |
520 | "source": [ |
|
410 | "source": [ | |
521 | "Then, because the widget abbreviation has already been defined, you can call `interact` with a single argument." |
|
411 | "Then, because the widget abbreviation has already been defined, you can call `interact` with a single argument." | |
522 | ] |
|
412 | ] | |
523 | }, |
|
413 | }, | |
524 | { |
|
414 | { | |
525 | "cell_type": "code", |
|
415 | "cell_type": "code", | |
526 | "collapsed": false, |
|
416 | "collapsed": false, | |
527 | "input": [ |
|
417 | "input": [ | |
528 | "interact(f);" |
|
418 | "interact(f);" | |
529 | ], |
|
419 | ], | |
530 | "language": "python", |
|
420 | "language": "python", | |
531 | "metadata": {}, |
|
421 | "metadata": {}, | |
532 | "outputs": [] |
|
422 | "outputs": [] | |
533 | }, |
|
423 | }, | |
534 | { |
|
424 | { | |
535 | "cell_type": "markdown", |
|
425 | "cell_type": "markdown", | |
536 | "metadata": {}, |
|
426 | "metadata": {}, | |
537 | "source": [ |
|
427 | "source": [ | |
538 | "If you are running Python 2, function annotations can be defined using the `@annotate` function." |
|
428 | "If you are running Python 2, function annotations can be defined using the `@annotate` function." | |
539 | ] |
|
429 | ] | |
540 | }, |
|
430 | }, | |
541 | { |
|
431 | { | |
542 | "cell_type": "code", |
|
432 | "cell_type": "code", | |
543 | "collapsed": false, |
|
433 | "collapsed": false, | |
544 | "input": [ |
|
434 | "input": [ | |
545 | "from IPython.utils.py3compat import annotate" |
|
435 | "from IPython.utils.py3compat import annotate" | |
546 | ], |
|
436 | ], | |
547 | "language": "python", |
|
437 | "language": "python", | |
548 | "metadata": {}, |
|
438 | "metadata": {}, | |
549 |
"outputs": [] |
|
439 | "outputs": [] | |
550 | "prompt_number": 50 |
|
|||
551 | }, |
|
440 | }, | |
552 | { |
|
441 | { | |
553 | "cell_type": "code", |
|
442 | "cell_type": "code", | |
554 | "collapsed": false, |
|
443 | "collapsed": false, | |
555 | "input": [ |
|
444 | "input": [ | |
556 | "@annotate(x=True)\n", |
|
445 | "@annotate(x=True)\n", | |
557 | "def f(x):\n", |
|
446 | "def f(x):\n", | |
558 |
" print |
|
447 | " print(x)" | |
559 | ], |
|
448 | ], | |
560 | "language": "python", |
|
449 | "language": "python", | |
561 | "metadata": {}, |
|
450 | "metadata": {}, | |
562 |
"outputs": [] |
|
451 | "outputs": [] | |
563 | "prompt_number": 51 |
|
|||
564 | }, |
|
452 | }, | |
565 | { |
|
453 | { | |
566 | "cell_type": "code", |
|
454 | "cell_type": "code", | |
567 | "collapsed": false, |
|
455 | "collapsed": false, | |
568 | "input": [ |
|
456 | "input": [ | |
569 | "interact(f);" |
|
457 | "interact(f);" | |
570 | ], |
|
458 | ], | |
571 | "language": "python", |
|
459 | "language": "python", | |
572 | "metadata": {}, |
|
460 | "metadata": {}, | |
573 | "outputs": [ |
|
461 | "outputs": [] | |
574 | { |
|
|||
575 | "output_type": "stream", |
|
|||
576 | "stream": "stdout", |
|
|||
577 | "text": [ |
|
|||
578 | "True\n" |
|
|||
579 | ] |
|
|||
580 | } |
|
|||
581 | ], |
|
|||
582 | "prompt_number": 52 |
|
|||
583 | }, |
|
462 | }, | |
584 | { |
|
463 | { | |
585 | "cell_type": "heading", |
|
464 | "cell_type": "heading", | |
586 | "level": 2, |
|
465 | "level": 2, | |
587 | "metadata": {}, |
|
466 | "metadata": {}, | |
588 | "source": [ |
|
467 | "source": [ | |
589 | "`interactive`" |
|
468 | "`interactive`" | |
590 | ] |
|
469 | ] | |
591 | }, |
|
470 | }, | |
592 | { |
|
471 | { | |
593 | "cell_type": "markdown", |
|
472 | "cell_type": "markdown", | |
594 | "metadata": {}, |
|
473 | "metadata": {}, | |
595 | "source": [ |
|
474 | "source": [ | |
596 | "In addition to `interact` IPython provides another function, `interactive`, that is useful when you want to reuse the widget that are produced or access the data that is bound to the UI controls." |
|
475 | "In addition to `interact` IPython provides another function, `interactive`, that is useful when you want to reuse the widget that are produced or access the data that is bound to the UI controls." | |
597 | ] |
|
476 | ] | |
598 | }, |
|
477 | }, | |
599 | { |
|
478 | { | |
600 | "cell_type": "markdown", |
|
479 | "cell_type": "markdown", | |
601 | "metadata": {}, |
|
480 | "metadata": {}, | |
602 | "source": [ |
|
481 | "source": [ | |
603 | "Here is a function that returns the sum of its two arguments." |
|
482 | "Here is a function that returns the sum of its two arguments." | |
604 | ] |
|
483 | ] | |
605 | }, |
|
484 | }, | |
606 | { |
|
485 | { | |
607 | "cell_type": "code", |
|
486 | "cell_type": "code", | |
608 | "collapsed": false, |
|
487 | "collapsed": false, | |
609 | "input": [ |
|
488 | "input": [ | |
610 | "def f(a, b):\n", |
|
489 | "def f(a, b):\n", | |
611 | " return a+b" |
|
490 | " return a+b" | |
612 | ], |
|
491 | ], | |
613 | "language": "python", |
|
492 | "language": "python", | |
614 | "metadata": {}, |
|
493 | "metadata": {}, | |
615 |
"outputs": [] |
|
494 | "outputs": [] | |
616 | "prompt_number": 18 |
|
|||
617 | }, |
|
495 | }, | |
618 | { |
|
496 | { | |
619 | "cell_type": "markdown", |
|
497 | "cell_type": "markdown", | |
620 | "metadata": {}, |
|
498 | "metadata": {}, | |
621 | "source": [ |
|
499 | "source": [ | |
622 | "Unlike `interact`, `interactive` returns a `Widget` instance rather than immediately displaying the widget." |
|
500 | "Unlike `interact`, `interactive` returns a `Widget` instance rather than immediately displaying the widget." | |
623 | ] |
|
501 | ] | |
624 | }, |
|
502 | }, | |
625 | { |
|
503 | { | |
626 | "cell_type": "code", |
|
504 | "cell_type": "code", | |
627 | "collapsed": false, |
|
505 | "collapsed": false, | |
628 | "input": [ |
|
506 | "input": [ | |
629 | "w = interactive(f, a=10, b=20)" |
|
507 | "w = interactive(f, a=10, b=20)" | |
630 | ], |
|
508 | ], | |
631 | "language": "python", |
|
509 | "language": "python", | |
632 | "metadata": {}, |
|
510 | "metadata": {}, | |
633 |
"outputs": [] |
|
511 | "outputs": [] | |
634 | "prompt_number": 19 |
|
|||
635 | }, |
|
512 | }, | |
636 | { |
|
513 | { | |
637 | "cell_type": "markdown", |
|
514 | "cell_type": "markdown", | |
638 | "metadata": {}, |
|
515 | "metadata": {}, | |
639 | "source": [ |
|
516 | "source": [ | |
640 |
"The widget is a ` |
|
517 | "The widget is a `Box`, which is a container for other widgets." | |
641 | ] |
|
518 | ] | |
642 | }, |
|
519 | }, | |
643 | { |
|
520 | { | |
644 | "cell_type": "code", |
|
521 | "cell_type": "code", | |
645 | "collapsed": false, |
|
522 | "collapsed": false, | |
646 | "input": [ |
|
523 | "input": [ | |
647 | "type(w)" |
|
524 | "type(w)" | |
648 | ], |
|
525 | ], | |
649 | "language": "python", |
|
526 | "language": "python", | |
650 | "metadata": {}, |
|
527 | "metadata": {}, | |
651 | "outputs": [ |
|
528 | "outputs": [] | |
652 | { |
|
|||
653 | "metadata": {}, |
|
|||
654 | "output_type": "pyout", |
|
|||
655 | "prompt_number": 20, |
|
|||
656 | "text": [ |
|
|||
657 | "IPython.html.widgets.widget_container.ContainerWidget" |
|
|||
658 | ] |
|
|||
659 | } |
|
|||
660 | ], |
|
|||
661 | "prompt_number": 20 |
|
|||
662 | }, |
|
529 | }, | |
663 | { |
|
530 | { | |
664 | "cell_type": "markdown", |
|
531 | "cell_type": "markdown", | |
665 | "metadata": {}, |
|
532 | "metadata": {}, | |
666 | "source": [ |
|
533 | "source": [ | |
667 |
"The children of the ` |
|
534 | "The children of the `Box` are two integer valued sliders produced by the widget abbreviations above." | |
668 | ] |
|
535 | ] | |
669 | }, |
|
536 | }, | |
670 | { |
|
537 | { | |
671 | "cell_type": "code", |
|
538 | "cell_type": "code", | |
672 | "collapsed": false, |
|
539 | "collapsed": false, | |
673 | "input": [ |
|
540 | "input": [ | |
674 | "w.children" |
|
541 | "w.children" | |
675 | ], |
|
542 | ], | |
676 | "language": "python", |
|
543 | "language": "python", | |
677 | "metadata": {}, |
|
544 | "metadata": {}, | |
678 | "outputs": [ |
|
545 | "outputs": [] | |
679 | { |
|
|||
680 | "metadata": {}, |
|
|||
681 | "output_type": "pyout", |
|
|||
682 | "prompt_number": 21, |
|
|||
683 | "text": [ |
|
|||
684 | "(<IPython.html.widgets.widget_int.IntSliderWidget at 0x10557ee90>,\n", |
|
|||
685 | " <IPython.html.widgets.widget_int.IntSliderWidget at 0x10616ebd0>)" |
|
|||
686 | ] |
|
|||
687 | } |
|
|||
688 | ], |
|
|||
689 | "prompt_number": 21 |
|
|||
690 | }, |
|
546 | }, | |
691 | { |
|
547 | { | |
692 | "cell_type": "markdown", |
|
548 | "cell_type": "markdown", | |
693 | "metadata": {}, |
|
549 | "metadata": {}, | |
694 | "source": [ |
|
550 | "source": [ | |
695 | "To actually display the widgets, you can use IPython's `display` function." |
|
551 | "To actually display the widgets, you can use IPython's `display` function." | |
696 | ] |
|
552 | ] | |
697 | }, |
|
553 | }, | |
698 | { |
|
554 | { | |
699 | "cell_type": "code", |
|
555 | "cell_type": "code", | |
700 | "collapsed": false, |
|
556 | "collapsed": false, | |
701 | "input": [ |
|
557 | "input": [ | |
702 | "from IPython.display import display\n", |
|
558 | "from IPython.display import display\n", | |
703 | "display(w)" |
|
559 | "display(w)" | |
704 | ], |
|
560 | ], | |
705 | "language": "python", |
|
561 | "language": "python", | |
706 | "metadata": {}, |
|
562 | "metadata": {}, | |
707 |
"outputs": [] |
|
563 | "outputs": [] | |
708 | "prompt_number": 22 |
|
|||
709 | }, |
|
564 | }, | |
710 | { |
|
565 | { | |
711 | "cell_type": "markdown", |
|
566 | "cell_type": "markdown", | |
712 | "metadata": {}, |
|
567 | "metadata": {}, | |
713 | "source": [ |
|
568 | "source": [ | |
714 | "At this point, the UI controls work just like they would if `interact` had been used. You can manipulate them interactively and the function will be called. However, the widget instance returned by `interactive` also give you access to the current keyword arguments and return value of the underlying Python function.\n", |
|
569 | "At this point, the UI controls work just like they would if `interact` had been used. You can manipulate them interactively and the function will be called. However, the widget instance returned by `interactive` also give you access to the current keyword arguments and return value of the underlying Python function.\n", | |
715 | "\n", |
|
570 | "\n", | |
716 | "Here are the current keyword arguments. If you rerun this cell after manipulating the sliders, the values will have changed." |
|
571 | "Here are the current keyword arguments. If you rerun this cell after manipulating the sliders, the values will have changed." | |
717 | ] |
|
572 | ] | |
718 | }, |
|
573 | }, | |
719 | { |
|
574 | { | |
720 | "cell_type": "code", |
|
575 | "cell_type": "code", | |
721 | "collapsed": false, |
|
576 | "collapsed": false, | |
722 | "input": [ |
|
577 | "input": [ | |
723 | "w.kwargs" |
|
578 | "w.kwargs" | |
724 | ], |
|
579 | ], | |
725 | "language": "python", |
|
580 | "language": "python", | |
726 | "metadata": {}, |
|
581 | "metadata": {}, | |
727 | "outputs": [ |
|
582 | "outputs": [] | |
728 | { |
|
|||
729 | "metadata": {}, |
|
|||
730 | "output_type": "pyout", |
|
|||
731 | "prompt_number": 23, |
|
|||
732 | "text": [ |
|
|||
733 | "{u'a': 10, u'b': 20}" |
|
|||
734 | ] |
|
|||
735 | } |
|
|||
736 | ], |
|
|||
737 | "prompt_number": 23 |
|
|||
738 | }, |
|
583 | }, | |
739 | { |
|
584 | { | |
740 | "cell_type": "markdown", |
|
585 | "cell_type": "markdown", | |
741 | "metadata": {}, |
|
586 | "metadata": {}, | |
742 | "source": [ |
|
587 | "source": [ | |
743 | "Here is the current return value of the function." |
|
588 | "Here is the current return value of the function." | |
744 | ] |
|
589 | ] | |
745 | }, |
|
590 | }, | |
746 | { |
|
591 | { | |
747 | "cell_type": "code", |
|
592 | "cell_type": "code", | |
748 | "collapsed": false, |
|
593 | "collapsed": false, | |
749 | "input": [ |
|
594 | "input": [ | |
750 | "w.result" |
|
595 | "w.result" | |
751 | ], |
|
596 | ], | |
752 | "language": "python", |
|
597 | "language": "python", | |
753 | "metadata": {}, |
|
598 | "metadata": {}, | |
754 | "outputs": [ |
|
599 | "outputs": [] | |
755 | { |
|
|||
756 | "metadata": {}, |
|
|||
757 | "output_type": "pyout", |
|
|||
758 | "prompt_number": 24, |
|
|||
759 | "text": [ |
|
|||
760 | "30" |
|
|||
761 | ] |
|
|||
762 | } |
|
|||
763 | ], |
|
|||
764 | "prompt_number": 24 |
|
|||
765 | } |
|
600 | } | |
766 | ], |
|
601 | ], | |
767 | "metadata": {} |
|
602 | "metadata": {} | |
768 | } |
|
603 | } | |
769 | ] |
|
604 | ] | |
770 | } No newline at end of file |
|
605 | } |
General Comments 0
You need to be logged in to leave comments.
Login now