Skip to content

Commit

Permalink
allow map / parallel function for single-engine views
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Apr 16, 2012
1 parent f57191a commit b1f1d1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions IPython/parallel/client/remotefunction.py
Expand Up @@ -182,6 +182,9 @@ def __call__(self, *sequences):
# 'all' is lazily evaluated at execution time, which is now:
if targets == 'all':
targets = client._build_targets(targets)[1]
elif isinstance(targets, int):
# single-engine view, targets must be iterable
targets = [targets]
nparts = len(targets)

msg_ids = []
Expand Down
6 changes: 6 additions & 0 deletions IPython/parallel/tests/test_view.py
Expand Up @@ -534,4 +534,10 @@ def test_reference_nameerror(self):
echo = lambda x:x
self.assertRaisesRemote(NameError, v.apply_sync, echo, r)

def test_single_engine_map(self):
e0 = self.client[self.client.ids[0]]
r = range(5)
check = [ -1*i for i in r ]
result = e0.map_sync(lambda x: -1*x, r)
self.assertEquals(result, check)

0 comments on commit b1f1d1e

Please sign in to comment.