##// END OF EJS Templates
Merge pull request #4305 from minrk/even-more-ways-to-get-ifaces...
Merge pull request #4305 from minrk/even-more-ways-to-get-ifaces Add even more ways to populate localinterfaces use netifaces for faster IPython.utils.localinterfaces when availlable, Parse subprocess output from ifconfig / ip addr / ipconfig. Lower priority than netifaces, but still higher priority than socket.gethostbyname. Fallback to gethostname otherwise. Should be much faster in worst case scenario where machine are badly configurred and can wait up to ~30s to start ipython. Slighly slower in other cases.

File last commit:

r9190:20a102a5
r12911:aeeb7f5a merge
Show More
parallel_pylab.ipy
49 lines | 1.2 KiB | text/plain | TextLexer
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337 """Example of how to use pylab to plot parallel data.
The idea here is to run matplotlib is the same IPython session
MinRK
translate last remaining old parallel examples
r3690 as an ipython parallel Client. That way matplotlib
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337 can be used to plot parallel data that is gathered using
MinRK
translate last remaining old parallel examples
r3690 a DirectView.
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337
To run this example, first start the IPython controller and 4
engines::
ipcluster -n 4
Then start ipython in pylab mode::
ipython -pylab
Then a simple "run parallel_pylab.ipy" in IPython will run the
example.
"""
import numpy as N
from pylab import *
MinRK
translate last remaining old parallel examples
r3690 from IPython.parallel import Client
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337
MinRK
translate last remaining old parallel examples
r3690 # load the parallel magic
%load_ext parallelmagic
# Get an IPython Client
rc = Client()
v = rc[:]
v.activate()
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337
# Create random arrays on the engines
# This is to simulate arrays that you have calculated in parallel
# on the engines.
# Anymore that length 10000 arrays, matplotlib starts to be slow
%px import numpy as N
%px x = N.random.standard_normal(10000)
%px y = N.random.standard_normal(10000)
MinRK
translate last remaining old parallel examples
r3690 print v.apply_async(lambda : x[0:10]).get_dict()
print v.apply_async(lambda : y[0:10]).get_dict()
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337
# Bring back the data
MinRK
translate last remaining old parallel examples
r3690 x_local = v.gather('x', block=True)
y_local = v.gather('y', block=True)
Brian E Granger
Adding examples from ipython1-dev to docs/examples/kernel. These ...
r1337
# Make a scatter plot of the gathered data
plot(x_local, y_local,'ro')