diff --git a/IPython/parallel/client/remotefunction.py b/IPython/parallel/client/remotefunction.py index 45c6264..ebf5c3b 100644 --- a/IPython/parallel/client/remotefunction.py +++ b/IPython/parallel/client/remotefunction.py @@ -1,20 +1,7 @@ -"""Remote Functions and decorators for Views. +"""Remote Functions and decorators for Views.""" -Authors: - -* Brian Granger -* Min RK -""" -#----------------------------------------------------------------------------- -# Copyright (C) 2010-2011 The IPython Development Team -# -# Distributed under the terms of the BSD License. The full license is in -# the file COPYING, distributed as part of this software. -#----------------------------------------------------------------------------- - -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. from __future__ import division @@ -203,6 +190,10 @@ class ParallelFunction(RemoteFunction): minlen = n lens.append(n) + if maxlen == 0: + # nothing to iterate over + return [] + # check that the length of sequences match if not self._mapping and minlen != maxlen: msg = 'all sequences must have equal length, but have %s' % lens diff --git a/IPython/parallel/tests/test_view.py b/IPython/parallel/tests/test_view.py index cfefb7e..44a3aa0 100644 --- a/IPython/parallel/tests/test_view.py +++ b/IPython/parallel/tests/test_view.py @@ -1,20 +1,8 @@ # -*- coding: utf-8 -*- -"""test View objects +"""test View objects""" -Authors: - -* Min RK -""" -#------------------------------------------------------------------------------- -# Copyright (C) 2011 The IPython Development Team -# -# Distributed under the terms of the BSD License. The full license is in -# the file COPYING, distributed as part of this software. -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Imports -#------------------------------------------------------------------------------- +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. import base64 import sys @@ -347,6 +335,11 @@ class TestView(ClusterTestCase): r = view.map_sync(f, data) self.assertEqual(r, list(map(f, data))) + def test_map_empty_sequence(self): + view = self.client[:] + r = view.map_sync(lambda x: x, []) + self.assertEqual(r, []) + def test_map_iterable(self): """test map on iterables (direct)""" view = self.client[:]