##// END OF EJS Templates
Merge branch 'glut-rebased' of git://github.com/fperez/ipython into glut...
Merge branch 'glut-rebased' of git://github.com/fperez/ipython into glut * 'glut-rebased' of git://github.com/fperez/ipython: Added the command line option Fix code in disable_glut which was not tested and quite buggy Tried to fix the CTRL-C problem (https://github.com/ipython/ipython/pull/742) and take other comments/typos into account Replaced deprecated raise call Fixed typos in comments Canceled window reshape to 1x1 since the idea is now for the user to use this window as the main one because of weird seg-faults problem after user creates its own window (any subsequent gl error would lead to a segfault, even a simple one line requiring a non existent function Event loop integration example Added code for the GLUT interactive session

File last commit:

r4637:d919e2ec
r4818:89161a5b merge
Show More
taskmap.ipynb
70 lines | 3.2 KiB | text/plain | TextLexer

Load balanced map and parallel function decorator

In [4]:
from IPython.parallel import Client
In [5]:
rc = Client()
v = rc.load_balanced_view()
In [6]:
result = v.map(lambda x: 2*x, range(10))
print "Simple, default map: ", list(result)
Simple, default map:  [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
In [7]:
ar = v.map_async(lambda x: 2*x, range(10))
print "Submitted tasks, got ids: ", ar.msg_ids
result = ar.get()
print "Using a mapper: ", result
Submitted tasks, got ids:  ['2a25ff3f-f0d0-4428-909a-3fe808ca61f9', 'edd42168-fac2-4b3f-a696-ce61b37aa71d', '8a548908-7812-44e6-a8b1-68e941bee608', '26435a77-fe86-49b6-b59f-de864d59c99f', '6750c7b4-2168-49ec-bcc4-feb1e17c5e53', '117240d1-5dfc-4783-948f-e9523b2b2f6a', '6de16d46-f2e2-49bd-8180-e43d1d875529', '3d372b84-0c68-4315-92c8-a080c68478b7', '43acedae-e35c-4a17-87f0-9e5e672500f7', 'eb71dd1f-9500-4375-875d-c2c42999848c']
Using a mapper:  [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
In [8]:
@v.parallel(block=True)
def f(x): return 2*x

result = f.map(range(10))
print "Using a parallel function: ", result
Using a parallel function:  [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]