Skip to content

Commit 6f4900b

Browse files
committed
[SPARK-2627] more misc PEP 8 fixes
1 parent fe57ed0 commit 6f4900b

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

python/pyspark/mllib/tests.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def test_classification(self):
136136
self.assertTrue(nb_model.predict(features[2]) <= 0)
137137
self.assertTrue(nb_model.predict(features[3]) > 0)
138138

139-
categoricalFeaturesInfo = {0: 3} # feature 0 has 3 categories
139+
categoricalFeaturesInfo = {0: 3} # feature 0 has 3 categories
140140
dt_model = \
141141
DecisionTree.trainClassifier(rdd, numClasses=2,
142142
categoricalFeaturesInfo=categoricalFeaturesInfo)
@@ -176,9 +176,10 @@ def test_regression(self):
176176
self.assertTrue(rr_model.predict(features[2]) <= 0)
177177
self.assertTrue(rr_model.predict(features[3]) > 0)
178178

179-
categoricalFeaturesInfo = {0: 2} # feature 0 has 2 categories
179+
categoricalFeaturesInfo = {0: 2} # feature 0 has 2 categories
180180
dt_model = \
181-
DecisionTree.trainRegressor(rdd, categoricalFeaturesInfo=categoricalFeaturesInfo)
181+
DecisionTree.trainRegressor(
182+
rdd, categoricalFeaturesInfo=categoricalFeaturesInfo)
182183
self.assertTrue(dt_model.predict(features[0]) <= 0)
183184
self.assertTrue(dt_model.predict(features[1]) > 0)
184185
self.assertTrue(dt_model.predict(features[2]) <= 0)
@@ -290,7 +291,7 @@ def test_classification(self):
290291
self.assertTrue(nb_model.predict(features[2]) <= 0)
291292
self.assertTrue(nb_model.predict(features[3]) > 0)
292293

293-
categoricalFeaturesInfo = {0: 3} # feature 0 has 3 categories
294+
categoricalFeaturesInfo = {0: 3} # feature 0 has 3 categories
294295
dt_model = DecisionTree.trainClassifier(rdd, numClasses=2,
295296
categoricalFeaturesInfo=categoricalFeaturesInfo)
296297
self.assertTrue(dt_model.predict(features[0]) <= 0)
@@ -329,8 +330,9 @@ def test_regression(self):
329330
self.assertTrue(rr_model.predict(features[2]) <= 0)
330331
self.assertTrue(rr_model.predict(features[3]) > 0)
331332

332-
categoricalFeaturesInfo = {0: 2} # feature 0 has 2 categories
333-
dt_model = DecisionTree.trainRegressor(rdd, categoricalFeaturesInfo=categoricalFeaturesInfo)
333+
categoricalFeaturesInfo = {0: 2} # feature 0 has 2 categories
334+
dt_model = DecisionTree.trainRegressor(
335+
rdd, categoricalFeaturesInfo=categoricalFeaturesInfo)
334336
self.assertTrue(dt_model.predict(features[0]) <= 0)
335337
self.assertTrue(dt_model.predict(features[1]) > 0)
336338
self.assertTrue(dt_model.predict(features[2]) <= 0)

python/pyspark/mllib/tree.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
from pyspark.mllib.regression import LabeledPoint
2626
from pyspark.serializers import NoOpSerializer
2727

28+
2829
class DecisionTreeModel(object):
30+
2931
"""
3032
A decision tree model for classification or regression.
3133
@@ -77,6 +79,7 @@ def __str__(self):
7779

7880

7981
class DecisionTree(object):
82+
8083
"""
8184
Learning algorithm for a decision tree model
8285
for classification or regression.
@@ -174,7 +177,6 @@ def trainRegressor(data, categoricalFeaturesInfo={},
174177
categoricalFeaturesInfo,
175178
impurity, maxDepth, maxBins)
176179

177-
178180
@staticmethod
179181
def train(data, algo, numClasses, categoricalFeaturesInfo,
180182
impurity, maxDepth, maxBins=100):
@@ -216,7 +218,8 @@ def _test():
216218
import doctest
217219
globs = globals().copy()
218220
globs['sc'] = SparkContext('local[4]', 'PythonTest', batchSize=2)
219-
(failure_count, test_count) = doctest.testmod(globs=globs, optionflags=doctest.ELLIPSIS)
221+
(failure_count, test_count) = doctest.testmod(
222+
globs=globs, optionflags=doctest.ELLIPSIS)
220223
globs['sc'].stop()
221224
if failure_count:
222225
exit(-1)

python/pyspark/mllib/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ def loadLibSVMFile(sc, path, numFeatures=-1, minPartitions=None):
127127
parsed = lines.map(lambda l: MLUtils._parse_libsvm_line(l))
128128
if numFeatures <= 0:
129129
parsed.cache()
130-
numFeatures = parsed.map(lambda x: -1 if x[1].size == 0 else x[1][-1]).reduce(max) + 1
130+
numFeatures = parsed.map(
131+
lambda x: -1 if x[1].size == 0 else x[1][-1]).reduce(max) + 1
131132
return parsed.map(lambda x: LabeledPoint(x[0], Vectors.sparse(numFeatures, x[1], x[2])))
132133

133134
@staticmethod

python/pyspark/sql.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -981,9 +981,10 @@ def registerFunction(self, name, f, returnType=StringType()):
981981
env = MapConverter().convert(self._sc.environment,
982982
self._sc._gateway._gateway_client)
983983
includes = ListConverter().convert(self._sc._python_includes,
984-
self._sc._gateway._gateway_client)
984+
self._sc._gateway._gateway_client)
985985
self._ssql_ctx.registerPython(name,
986-
bytearray(CloudPickleSerializer().dumps(command)),
986+
bytearray(
987+
CloudPickleSerializer().dumps(command)),
987988
env,
988989
includes,
989990
self._sc.pythonExec,
@@ -1525,7 +1526,8 @@ def registerTempTable(self, name):
15251526
self._jschema_rdd.registerTempTable(name)
15261527

15271528
def registerAsTable(self, name):
1528-
warnings.warn("Use registerTempTable instead of registerAsTable.", DeprecationWarning)
1529+
warnings.warn(
1530+
"Use registerTempTable instead of registerAsTable.", DeprecationWarning)
15291531
self.registerTempTable(name)
15301532

15311533
def insertInto(self, tableName, overwrite=False):

0 commit comments

Comments
 (0)