##// END OF EJS Templates
Fix bug where 'if 1:' was being added to comment-only code....
Fix bug where 'if 1:' was being added to comment-only code. Found by trying to paste and run this example: http://matplotlib.sourceforge.net/examples/api/collections_demo.html that happened to have indented, comment-only lines of the type: code() # comment code() In these cases, we should *not* try to prepend 'if 1:' to the user's code since that comment by itself isn't executable, and it will cause a compiler IndentationError.

File last commit:

r1337:53a3e331
r2979:63d38bdf
Show More
phistogram.py
33 lines | 985 B | text/x-python | PythonLexer
"""Parallel histogram function"""
import numpy
def phistogram(rc, a, bins=10, rng=None, normed=False):
"""Compute the histogram of a remote array a.
:Parameters:
rc
IPython RemoteController instance
a : str
String name of the remote array
bins : int
Number of histogram bins
rng : (float, float)
Tuple of min, max of the range to histogram
normed : boolean
Should the histogram counts be normalized to 1
"""
nengines = len(rc)
rc.push(dict(bins=bins, rng=rng))
rc.execute('import numpy')
rc.execute('hist, lower_edges = numpy.histogram(%s, bins, rng)' % a)
lower_edges = rc.pull('lower_edges', targets=0)
hist_array = rc.gather('hist')
hist_array.shape = (nengines,-1)
total_hist = numpy.sum(hist_array, 0)
if normed:
total_hist = total_hist/numpy.sum(total_hist,dtype=float)
return total_hist, lower_edges