Skip to content

Commit 25d7451

Browse files
committed
fix tests in python 3
1 parent babdde7 commit 25d7451

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

python/pyspark/ml/evaluation.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ class BinaryClassificationEvaluator(JavaEvaluator, HasLabelCol, HasRawPrediction
3131
columns: rawPrediction and label.
3232
3333
>>> from pyspark.mllib.linalg import Vectors
34-
>>> scoreAndLabels = sc.parallelize([
35-
... (0.1, 0.0), (0.1, 1.0), (0.4, 0.0), (0.6, 0.0), (0.6, 1.0), (0.6, 1.0), (0.8, 1.0)])
36-
>>> rawPredictionAndLabels = scoreAndLabels.map(
37-
... lambda x: (Vectors.dense([1.0 - x[0], x[0]]), x[1]))
38-
>>> dataset = rawPredictionAndLabels.toDF(["raw", "label"])
34+
>>> scoreAndLabels = map(lambda x: (Vectors.dense([1.0 - x[0], x[0]]), x[1]),
35+
... [(0.1, 0.0), (0.1, 1.0), (0.4, 0.0), (0.6, 0.0), (0.6, 1.0), (0.6, 1.0), (0.8, 1.0)])
36+
>>> dataset = sqlContext.createDataFrame(scoreAndLabels, ["raw", "label"])
37+
...
3938
>>> evaluator = BinaryClassificationEvaluator(rawPredictionCol="raw")
4039
>>> evaluator.evaluate(dataset)
4140
0.70...
@@ -97,7 +96,7 @@ def setParams(self, rawPredictionCol="rawPrediction", labelCol="label",
9796
globs = globals().copy()
9897
# The small batch size here ensures that we see multiple batches,
9998
# even in these small test examples:
100-
sc = SparkContext("local[2]", "ml.feature tests")
99+
sc = SparkContext("local[2]", "ml.evaluation tests")
101100
sqlContext = SQLContext(sc)
102101
globs['sc'] = sc
103102
globs['sqlContext'] = sqlContext

python/pyspark/sql/_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ def _python_to_sql_converter(dataType):
652652

653653
if isinstance(dataType, StructType):
654654
names, types = zip(*[(f.name, f.dataType) for f in dataType.fields])
655-
converters = map(_python_to_sql_converter, types)
655+
converters = [_python_to_sql_converter(t) for t in types]
656656

657657
def converter(obj):
658658
if isinstance(obj, dict):

0 commit comments

Comments
 (0)