##// END OF EJS Templates
Backport PR #5766: View.map with empty sequence should return empty list...
Thomas Kluyver -
Show More
@@ -1,20 +1,7 b''
1 """Remote Functions and decorators for Views.
1 """Remote Functions and decorators for Views."""
2
2
3 Authors:
3 # Copyright (c) IPython Development Team.
4
4 # Distributed under the terms of the Modified BSD License.
5 * Brian Granger
6 * Min RK
7 """
8 #-----------------------------------------------------------------------------
9 # Copyright (C) 2010-2011 The IPython Development Team
10 #
11 # Distributed under the terms of the BSD License. The full license is in
12 # the file COPYING, distributed as part of this software.
13 #-----------------------------------------------------------------------------
14
15 #-----------------------------------------------------------------------------
16 # Imports
17 #-----------------------------------------------------------------------------
18
5
19 from __future__ import division
6 from __future__ import division
20
7
@@ -203,6 +190,10 b' class ParallelFunction(RemoteFunction):'
203 minlen = n
190 minlen = n
204 lens.append(n)
191 lens.append(n)
205
192
193 if maxlen == 0:
194 # nothing to iterate over
195 return []
196
206 # check that the length of sequences match
197 # check that the length of sequences match
207 if not self._mapping and minlen != maxlen:
198 if not self._mapping and minlen != maxlen:
208 msg = 'all sequences must have equal length, but have %s' % lens
199 msg = 'all sequences must have equal length, but have %s' % lens
@@ -1,20 +1,8 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """test View objects
2 """test View objects"""
3
3
4 Authors:
4 # Copyright (c) IPython Development Team.
5
5 # Distributed under the terms of the Modified BSD License.
6 * Min RK
7 """
8 #-------------------------------------------------------------------------------
9 # Copyright (C) 2011 The IPython Development Team
10 #
11 # Distributed under the terms of the BSD License. The full license is in
12 # the file COPYING, distributed as part of this software.
13 #-------------------------------------------------------------------------------
14
15 #-------------------------------------------------------------------------------
16 # Imports
17 #-------------------------------------------------------------------------------
18
6
19 import base64
7 import base64
20 import sys
8 import sys
@@ -347,6 +335,11 b' class TestView(ClusterTestCase):'
347 r = view.map_sync(f, data)
335 r = view.map_sync(f, data)
348 self.assertEqual(r, list(map(f, data)))
336 self.assertEqual(r, list(map(f, data)))
349
337
338 def test_map_empty_sequence(self):
339 view = self.client[:]
340 r = view.map_sync(lambda x: x, [])
341 self.assertEqual(r, [])
342
350 def test_map_iterable(self):
343 def test_map_iterable(self):
351 """test map on iterables (direct)"""
344 """test map on iterables (direct)"""
352 view = self.client[:]
345 view = self.client[:]
General Comments 0
You need to be logged in to leave comments. Login now