~ubuntu-branches/ubuntu/raring/ipython/raring

« back to all changes in this revision

Viewing changes to docs/examples/parallel/nwmerge.py

  • Committer: Package Import Robot
  • Author(s): Julian Taylor
  • Date: 2012-06-30 15:05:32 UTC
  • mfrom: (1.2.18) (6.1.9 sid)
  • Revision ID: package-import@ubuntu.com-20120630150532-c95s7y8qek15kdbo
Tags: 0.13-1
* New upstream release
  No repackging necessary anymore, js sources available in external
  minified variants are not installed
* refresh patches, drop upstream applied full-qt-imports 
* add except-shadows-builtin-fix.patch
* drop libjs-jquery-ui dependency, use the embedded development branch
* don't compress the examples
* remove executable permissions on embedded codemirror files
* build with LC_ALL=C.UTF-8 to avoid a unicode issue in setupbase.py
* remove generated doc images in clean
* update copyright with new and removed files
* remove unreachable Stephan Peijnik from uploaders
  thank you for your work

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
"""
3
3
# Slightly modified version of:
4
4
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/511509
 
5
from __future__ import print_function
5
6
 
6
7
import heapq
7
8
from IPython.parallel.error import RemoteError
82
83
        try:
83
84
            result = view.apply_sync(lambda x: x.next(), Reference('it'+name))
84
85
        # This causes the StopIteration exception to be raised.
85
 
        except RemoteError, e:
 
86
        except RemoteError as e:
86
87
            if e.ename == 'StopIteration':
87
88
                raise StopIteration
88
89
            else:
96
97
    from IPython.parallel import Client, Reference
97
98
    rc = Client()
98
99
    view = rc[:]
99
 
    print 'Engine IDs:', rc.ids
 
100
    print('Engine IDs:', rc.ids)
100
101
 
101
102
    # Make a set of 'sorted datasets'
102
103
    a0 = range(5,20)
116
117
    aa2 = remote_iterator(rc[2],'a')
117
118
 
118
119
    # Let's merge them, both locally and remotely:
119
 
    print 'Merge the local datasets:'
120
 
    print list(mergesort([a0,a1,a2]))
 
120
    print('Merge the local datasets:')
 
121
    print(list(mergesort([a0,a1,a2])))
121
122
    
122
 
    print 'Locally merge the remote sets:'
123
 
    print list(mergesort([aa0,aa1,aa2]))
 
123
    print('Locally merge the remote sets:')
 
124
    print(list(mergesort([aa0,aa1,aa2])))