environment/share/doc/ipython/examples/parallel/davinci/pwordfreq.py
def pwordfreq(view, fnames):
    """Parallel word frequency counter.
    
    view - An IPython DirectView
    fnames - The filenames containing the split data.
    """
    assert len(fnames) == len(view.targets)
    view.scatter('fname', fnames, flatten=True)
    ar = view.apply(wordfreq, Reference('fname'))
    freqs_list = ar.get()
    word_set = set()
    for f in freqs_list:
        word_set.update(f.keys())
    freqs = dict(zip(word_set, repeat(0)))
    for f in freqs_list:
        for word, count in f.iteritems():
            freqs[word] += count
    return freqs
def pwordfreq(view, fnames):
    """Parallel word frequency counter.
    
    view - An IPython DirectView
    fnames - The filenames containing the split data.
    """
    assert len(fnames) == len(view.targets)
    view.scatter('fname', fnames, flatten=True)
    ar = view.apply(wordfreq, Reference('fname'))
    freqs_list = ar.get()
    word_set = set()
    for f in freqs_list:
        word_set.update(f.keys())
    freqs = dict(zip(word_set, repeat(0)))
    for f in freqs_list:
        for word, count in f.iteritems():
            freqs[word] += count
    return freqs
def pwordfreq ( view , fnames ) : assert len ( fnames ) == len ( view . targets ) view . scatter ( 'fname' , fnames , flatten = True ) ar = view . apply ( wordfreq , Reference ( 'fname' ) ) freqs_list = ar . get ( ) word_set = set ( ) for f in freqs_list : word_set . update ( f . keys ( ) ) freqs = dict ( zip ( word_set , repeat ( 0 ) ) ) for f in freqs_list : for word , count in f . iteritems ( ) : freqs [ word ] += count return freqs
Parallel word frequency counter.
    
    view - An IPython DirectView
    fnames - The filenames containing the split data.
Parallel word frequency counter . view - An IPython DirectView fnames - The filenames containing the split data .