Show More
@@ -67,7 +67,7 | |||
|
67 | 67 | "cell_type": "code", |
|
68 | 68 | "collapsed": false, |
|
69 | 69 | "input": [ |
|
70 |
"%px print |
|
|
70 | "%px print(a)" | |
|
71 | 71 | ], |
|
72 | 72 | "language": "python", |
|
73 | 73 | "metadata": {}, |
@@ -98,7 +98,8 | |||
|
98 | 98 | "cell_type": "code", |
|
99 | 99 | "collapsed": false, |
|
100 | 100 | "input": [ |
|
101 | "%px print >> sys.stderr, \"ERROR\"" | |
|
101 | "%px from __future__ import print_function\n", | |
|
102 | "%px print(\"ERROR\", file=sys.stderr)" | |
|
102 | 103 | ], |
|
103 | 104 | "language": "python", |
|
104 | 105 | "metadata": {}, |
@@ -208,7 +209,7 | |||
|
208 | 209 | "%%px --noblock\n", |
|
209 | 210 | "x = np.linspace(0,np.pi,1000)\n", |
|
210 | 211 | "for n in range(id,12, stride):\n", |
|
211 |
" print |
|
|
212 | " print(n)\n", | |
|
212 | 213 | " plt.plot(x,np.sin(n*x))\n", |
|
213 | 214 | "plt.title(\"Plot %i\" % id)" |
|
214 | 215 | ], |
@@ -248,7 +249,7 | |||
|
248 | 249 | "%%px --group-outputs=engine\n", |
|
249 | 250 | "x = np.linspace(0,np.pi,1000)\n", |
|
250 | 251 | "for n in range(id+1,12, stride):\n", |
|
251 |
" print |
|
|
252 | " print(n)\n", | |
|
252 | 253 | " plt.figure()\n", |
|
253 | 254 | " plt.plot(x,np.sin(n*x))\n", |
|
254 | 255 | " plt.title(\"Plot %i\" % n)" |
@@ -296,6 +297,8 | |||
|
296 | 297 | "cell_type": "code", |
|
297 | 298 | "collapsed": false, |
|
298 | 299 | "input": [ |
|
300 | "from __future__ import print_function\n", | |
|
301 | "\n", | |
|
299 | 302 | "def generate_output():\n", |
|
300 | 303 | " \"\"\"function for testing output\n", |
|
301 | 304 | " \n", |
@@ -305,13 +308,13 | |||
|
305 | 308 | " import sys,os\n", |
|
306 | 309 | " from IPython.display import display, HTML, Math\n", |
|
307 | 310 | " \n", |
|
308 |
" print |
|
|
309 |
" print |
|
|
311 | " print(\"stdout\")\n", | |
|
312 | " print(\"stderr\", file=sys.stderr)\n", | |
|
310 | 313 | " \n", |
|
311 | 314 | " display(HTML(\"<b>HTML</b>\"))\n", |
|
312 | 315 | " \n", |
|
313 |
" print |
|
|
314 |
" print |
|
|
316 | " print(\"stdout2\")\n", | |
|
317 | " print(\"stderr2\", file=sys.stderr)\n", | |
|
315 | 318 | " \n", |
|
316 | 319 | " display(Math(r\"\\alpha=\\beta\"))\n", |
|
317 | 320 | " \n", |
@@ -461,7 +464,7 | |||
|
461 | 464 | "cell_type": "markdown", |
|
462 | 465 | "metadata": {}, |
|
463 | 466 | "source": [ |
|
464 |
"As of IPython 0 |
|
|
467 | "As of IPython 1.0, you can instruct `%%px` to also execute the cell locally.\n", | |
|
465 | 468 | "This is useful for interactive definitions,\n", |
|
466 | 469 | "or if you want to load a data source everywhere,\n", |
|
467 | 470 | "not just on the engines." |
@@ -474,7 +477,7 | |||
|
474 | 477 | "%%px --local\n", |
|
475 | 478 | "import os\n", |
|
476 | 479 | "thispid = os.getpid()\n", |
|
477 |
"print |
|
|
480 | "print(thispid)" | |
|
478 | 481 | ], |
|
479 | 482 | "language": "python", |
|
480 | 483 | "metadata": {}, |
@@ -1,6 +1,6 | |||
|
1 | 1 | { |
|
2 | 2 | "metadata": { |
|
3 |
"name": " |
|
|
3 | "name": "" | |
|
4 | 4 | }, |
|
5 | 5 | "nbformat": 3, |
|
6 | 6 | "nbformat_minor": 0, |
@@ -20,6 +20,7 | |||
|
20 | 20 | "cell_type": "code", |
|
21 | 21 | "collapsed": true, |
|
22 | 22 | "input": [ |
|
23 | "from __future__ import print_function\n", | |
|
23 | 24 | "from IPython.parallel import Client" |
|
24 | 25 | ], |
|
25 | 26 | "language": "python", |
@@ -69,8 +70,8 | |||
|
69 | 70 | "cell_type": "code", |
|
70 | 71 | "collapsed": false, |
|
71 | 72 | "input": [ |
|
72 |
"print |
|
|
73 |
"print |
|
|
73 | "print(\"Submitted tasks:\", hello.msg_ids + world.msg_ids)\n", | |
|
74 | "print(hello.get(), world.get())" | |
|
74 | 75 | ], |
|
75 | 76 | "language": "python", |
|
76 | 77 | "metadata": {}, |
@@ -18,6 +18,7 | |||
|
18 | 18 | "cell_type": "code", |
|
19 | 19 | "collapsed": true, |
|
20 | 20 | "input": [ |
|
21 | "from __future__ import print_function\n", | |
|
21 | 22 | "from IPython.parallel import Client" |
|
22 | 23 | ], |
|
23 | 24 | "language": "python", |
@@ -110,7 +111,7 | |||
|
110 | 111 | "cell_type": "code", |
|
111 | 112 | "collapsed": false, |
|
112 | 113 | "input": [ |
|
113 |
"print |
|
|
114 | "print(\"a, b, c: \", ar.get())" | |
|
114 | 115 | ], |
|
115 | 116 | "language": "python", |
|
116 | 117 | "metadata": {}, |
@@ -1,6 +1,6 | |||
|
1 | 1 | { |
|
2 | 2 | "metadata": { |
|
3 |
"name": " |
|
|
3 | "name": "" | |
|
4 | 4 | }, |
|
5 | 5 | "nbformat": 3, |
|
6 | 6 | "nbformat_minor": 0, |
@@ -18,6 +18,7 | |||
|
18 | 18 | "cell_type": "code", |
|
19 | 19 | "collapsed": true, |
|
20 | 20 | "input": [ |
|
21 | "from __future__ import print_function\n", | |
|
21 | 22 | "from IPython.parallel import Client" |
|
22 | 23 | ], |
|
23 | 24 | "language": "python", |
@@ -42,7 +43,7 | |||
|
42 | 43 | "collapsed": false, |
|
43 | 44 | "input": [ |
|
44 | 45 | "result = v.map(lambda x: 2*x, range(10))\n", |
|
45 |
"print |
|
|
46 | "print(\"Simple, default map: \", list(result))" | |
|
46 | 47 | ], |
|
47 | 48 | "language": "python", |
|
48 | 49 | "metadata": {}, |
@@ -69,9 +70,9 | |||
|
69 | 70 | "collapsed": false, |
|
70 | 71 | "input": [ |
|
71 | 72 | "ar = v.map_async(lambda x: 2*x, range(10))\n", |
|
72 |
"print |
|
|
73 | "print(\"Submitted tasks, got ids: \", ar.msg_ids)\n", | |
|
73 | 74 | "result = ar.get()\n", |
|
74 |
"print |
|
|
75 | "print(\"Using a mapper: \", result)" | |
|
75 | 76 | ], |
|
76 | 77 | "language": "python", |
|
77 | 78 | "metadata": {}, |
@@ -95,7 +96,7 | |||
|
95 | 96 | "def f(x): return 2*x\n", |
|
96 | 97 | "\n", |
|
97 | 98 | "result = f.map(range(10))\n", |
|
98 |
"print |
|
|
99 | "print(\"Using a parallel function: \", result)" | |
|
99 | 100 | ], |
|
100 | 101 | "language": "python", |
|
101 | 102 | "metadata": {}, |
General Comments 0
You need to be logged in to leave comments.
Login now