From e5381cd87940676db58f7cf45f694e9c4837db4b Mon Sep 17 00:00:00 2001 From: Sandy Ryza Date: Thu, 4 Sep 2014 01:51:11 -0700 Subject: [PATCH] Fix python style warnings --- python/pyspark/rdd.py | 4 ++-- python/pyspark/tests.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/python/pyspark/rdd.py b/python/pyspark/rdd.py index 2122183f614e1..10168a13f4838 100644 --- a/python/pyspark/rdd.py +++ b/python/pyspark/rdd.py @@ -525,7 +525,7 @@ def repartitionAndSortWithinPartition(self, ascending=True, numPartitions=None, """ Repartition the RDD according to the given partitioner and, within each resulting partition, sort records by their keys. - + >>> rdd = sc.parallelize([(0, 5), (3, 8), (2, 6), (0, 8), (3, 8), (1, 3)]) >>> rdd2 = rdd.repartitionAndSortWithinPartition(True, lambda x: x % 2, 2) >>> rdd2.glom().collect() @@ -541,7 +541,7 @@ def repartitionAndSortWithinPartition(self, ascending=True, numPartitions=None, def sortPartition(iterator): sort = ExternalSorter(memory * 0.9, serializer).sorted if spill else sorted return iter(sort(iterator, key=lambda (k, v): keyfunc(k), reverse=(not ascending))) - + return self.partitionBy(numPartitions, partitionFunc).mapPartitions(sortPartition, True) def sortByKey(self, ascending=True, numPartitions=None, keyfunc=lambda x: x): diff --git a/python/pyspark/tests.py b/python/pyspark/tests.py index fdec259af17f8..5b2fa54e239ce 100644 --- a/python/pyspark/tests.py +++ b/python/pyspark/tests.py @@ -547,7 +547,7 @@ def test_histogram(self): def test_repartitionAndSortWithinPartition(self): rdd = self.sc.parallelize([(0, 5), (3, 8), (2, 6), (0, 8), (3, 8), (1, 3)], 2) - + repartitioned = rdd.repartitionAndSortWithinPartition(True, 2, lambda key: key % 2) partitions = repartitioned.glom().collect() self.assertEquals(partitions[0], [(0, 5), (0, 8), (2, 6)])