From 872028db838fcd29743c509422e96e928c49e149 Mon Sep 17 00:00:00 2001 From: Yanbo Liang Date: Tue, 21 Apr 2015 13:07:01 +0800 Subject: [PATCH] fix code style --- .../spark/mllib/regression/IsotonicRegression.scala | 11 ++++++----- .../mllib/regression/IsotonicRegressionSuite.scala | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/mllib/src/main/scala/org/apache/spark/mllib/regression/IsotonicRegression.scala b/mllib/src/main/scala/org/apache/spark/mllib/regression/IsotonicRegression.scala index cd9231155fb9a..1d7617046b6c7 100644 --- a/mllib/src/main/scala/org/apache/spark/mllib/regression/IsotonicRegression.scala +++ b/mllib/src/main/scala/org/apache/spark/mllib/regression/IsotonicRegression.scala @@ -160,15 +160,15 @@ object IsotonicRegressionModel extends Loader[IsotonicRegressionModel] { predictions: Array[Double], isotonic: Boolean): Unit = { val sqlContext = new SQLContext(sc) - import sqlContext.implicits._ val metadata = compact(render( ("class" -> thisClassName) ~ ("version" -> thisFormatVersion) ~ ("isotonic" -> isotonic))) sc.parallelize(Seq(metadata), 1).saveAsTextFile(metadataPath(path)) - sqlContext.createDataFrame(boundaries.toSeq.zip(predictions) - .map { case (b, p) => Data(b, p) }).saveAsParquetFile(dataPath(path)) + sqlContext.createDataFrame( + boundaries.toSeq.zip(predictions).map { case (b, p) => Data(b, p) } + ).saveAsParquetFile(dataPath(path)) } def load(sc: SparkContext, path: String): (Array[Double], Array[Double]) = { @@ -177,8 +177,9 @@ object IsotonicRegressionModel extends Loader[IsotonicRegressionModel] { checkSchema[Data](dataRDD.schema) val dataArray = dataRDD.select("boundary", "prediction").collect() - val (boundaries, predictions) = dataArray.map { - x => (x.getDouble(0), x.getDouble(1)) }.toList.sortBy(_._1).unzip + val (boundaries, predictions) = dataArray.map { x => + (x.getDouble(0), x.getDouble(1)) + }.toList.sortBy(_._1).unzip (boundaries.toArray, predictions.toArray) } } diff --git a/mllib/src/test/scala/org/apache/spark/mllib/regression/IsotonicRegressionSuite.scala b/mllib/src/test/scala/org/apache/spark/mllib/regression/IsotonicRegressionSuite.scala index a32318bfbaa66..8e12340bbd9d6 100644 --- a/mllib/src/test/scala/org/apache/spark/mllib/regression/IsotonicRegressionSuite.scala +++ b/mllib/src/test/scala/org/apache/spark/mllib/regression/IsotonicRegressionSuite.scala @@ -88,7 +88,7 @@ class IsotonicRegressionSuite extends FunSuite with MLlibTestSparkContext with M val sameModel = IsotonicRegressionModel.load(sc, path) assert(model.boundaries === sameModel.boundaries) assert(model.predictions === sameModel.predictions) - assert(model.isotonic == model.isotonic) + assert(model.isotonic === model.isotonic) } finally { Utils.deleteRecursively(tempDir) }