##// END OF EJS Templates
Ported the IPython Sphinx directive to 0.11....
Ported the IPython Sphinx directive to 0.11. This was originally written by John Hunter for the 0.10 API, now it works with 0.11. We still need to automate its test suite, but at least now it runs and the script itself can be executed as a test that produces screen output and figures in a subdir.

File last commit:

r1606:a579fd1d
r2439:858c6e09
Show More
rmt.ipy
57 lines | 1.6 KiB | text/plain | TextLexer
#-------------------------------------------------------------------------------
# Driver code that the client runs.
#-------------------------------------------------------------------------------
# To run this code start a controller and engines using:
# ipcluster -n 2
# Then run the scripts by doing irunner rmt.ipy or by starting ipython and
# doing run rmt.ipy.
from rmtkernel import *
from IPython.kernel import client
def wignerDistribution(s):
"""Returns (s, rho(s)) for the Wigner GOE distribution."""
return (numpy.pi*s/2.0) * numpy.exp(-numpy.pi*s**2/4.)
def generateWignerData():
s = numpy.linspace(0.0,4.0,400)
rhos = wignerDistribution(s)
return s, rhos
def serialDiffs(num, N):
diffs = ensembleDiffs(num, N)
normalizedDiffs = normalizeDiffs(diffs)
return normalizedDiffs
def parallelDiffs(rc, num, N):
nengines = len(rc.get_ids())
num_per_engine = num/nengines
print "Running with", num_per_engine, "per engine."
rc.push(dict(num_per_engine=num_per_engine, N=N))
rc.execute('diffs = ensembleDiffs(num_per_engine, N)')
# gather blocks always for now
pr = rc.gather('diffs')
return pr.r
# Main code
if __name__ == '__main__':
rc = client.MultiEngineClient()
print "Distributing code to engines..."
r = rc.run('rmtkernel.py')
rc.block = False
# Simulation parameters
nmats = 100
matsize = 30
%timeit -n1 -r1 serialDiffs(nmats,matsize)
%timeit -n1 -r1 parallelDiffs(rc, nmats, matsize)
# Uncomment these to plot the histogram
# import pylab
# pylab.hist(parallelDiffs(rc,matsize,matsize))