Skip to content

Commit f5fdf63

Browse files
author
Davies Liu
committed
fix bug with int in weights
1 parent 4dfa2cd commit f5fdf63

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

python/pyspark/rdd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,13 @@ def randomSplit(self, weights, seed=None):
325325
:return: split RDDs in a list
326326
327327
>>> rdd = sc.parallelize(range(5), 1)
328-
>>> rdd1, rdd2 = rdd.randomSplit([2.0, 3.0], 101)
328+
>>> rdd1, rdd2 = rdd.randomSplit([2, 3], 101)
329329
>>> rdd1.collect()
330330
[2, 3]
331331
>>> rdd2.collect()
332332
[0, 1, 4]
333333
"""
334-
s = sum(weights)
334+
s = float(sum(weights))
335335
cweights = [0.0]
336336
for w in weights:
337337
cweights.append(cweights[-1] + w / s)

0 commit comments

Comments
 (0)