Permalink
Browse files

Merge pull request #1613 from minrk/singlemap

allow map / parallel function for single-engine views
  • Loading branch information...
2 parents 4f9b234 + b1f1d1e commit 2464446eba8597f20e947f04694cfa802f0e4969 @fperez fperez committed Apr 16, 2012
Showing with 9 additions and 0 deletions.
  1. +3 −0 IPython/parallel/client/remotefunction.py
  2. +6 −0 IPython/parallel/tests/test_view.py
@@ -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 = []
@@ -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 2464446

Please sign in to comment.