##// END OF EJS Templates
catch *any* exception importing qt in profile...
catch *any* exception importing qt in profile Under weird circumstances, an ImportError is not raised, but any exception should be treated the same, and prevent creating the qt config file.

File last commit:

r3670:45e272d0
r4212:9a3b6439
Show More
rmt.ipy
56 lines | 1.5 KiB | text/plain | TextLexer
MinRK
updates to docs and examples
r3670 #-------------------------------------------------------------------------------
# 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 *
MinRK
remove kernel examples already ported to newparallel
r3675 import numpy
from IPython.parallel import Client
MinRK
updates to docs and examples
r3670
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):
MinRK
remove kernel examples already ported to newparallel
r3675 nengines = len(rc.targets)
MinRK
updates to docs and examples
r3670 num_per_engine = num/nengines
print "Running with", num_per_engine, "per engine."
MinRK
remove kernel examples already ported to newparallel
r3675 ar = rc.apply_async(ensembleDiffs, num_per_engine, N)
return numpy.array(ar.get()).flatten()
MinRK
updates to docs and examples
r3670
# Main code
if __name__ == '__main__':
MinRK
remove kernel examples already ported to newparallel
r3675 rc = Client()
view = rc[:]
MinRK
updates to docs and examples
r3670 print "Distributing code to engines..."
MinRK
remove kernel examples already ported to newparallel
r3675 view.run('rmtkernel.py')
view.block = False
MinRK
updates to docs and examples
r3670
# Simulation parameters
nmats = 100
matsize = 30
MinRK
remove kernel examples already ported to newparallel
r3675 # tic = time.time()
%timeit -r1 -n1 serialDiffs(nmats,matsize)
%timeit -r1 -n1 parallelDiffs(view, nmats, matsize)
MinRK
updates to docs and examples
r3670
# Uncomment these to plot the histogram
# import pylab
# pylab.hist(parallelDiffs(rc,matsize,matsize))