Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17419#discussion_r108218508
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/stat/SummarizerSuite.scala ---
    @@ -0,0 +1,338 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.ml.stat
    +
    +import org.scalatest.exceptions.TestFailedException
    +
    +import org.apache.spark.{SparkException, SparkFunSuite}
    +import org.apache.spark.ml.linalg.{Vector, Vectors}
    +import org.apache.spark.ml.stat.SummaryBuilderImpl.Buffer
    +import org.apache.spark.ml.util.TestingUtils._
    +import org.apache.spark.mllib.linalg.{Vector => OldVector, Vectors => 
OldVectors}
    +import org.apache.spark.mllib.stat.MultivariateOnlineSummarizer
    +import org.apache.spark.mllib.util.MLlibTestSparkContext
    +import org.apache.spark.sql.{DataFrame, Row}
    +import org.apache.spark.sql.catalyst.expressions.GenericRowWithSchema
    +
    +class SummarizerSuite extends SparkFunSuite with MLlibTestSparkContext {
    +
    +  import testImplicits._
    +  import Summarizer._
    +
    +  private case class ExpectedMetrics(
    +      mean: Seq[Double],
    +      variance: Seq[Double],
    +      count: Long,
    +      numNonZeros: Seq[Long],
    +      max: Seq[Double],
    +      min: Seq[Double],
    +      normL2: Seq[Double],
    +      normL1: Seq[Double])
    +
    +  // The input is expected to be either a sparse vector, a dense vector or 
an array of doubles
    +  // (which will be converted to a dense vector)
    +  // The expected is the list of all the known metrics.
    +  //
    +  // The tests take an list of input vectors and a list of all the summary 
values that
    +  // are expected for this input. They currently test against some fixed 
subset of the
    +  // metrics, but should be made fuzzy in the future.
    +
    +  private def testExample(name: String, input: Seq[Any], exp: 
ExpectedMetrics): Unit = {
    +    def inputVec: Seq[Vector] = input.map {
    +      case x: Array[Double @unchecked] => Vectors.dense(x)
    +      case x: Seq[Double @unchecked] => Vectors.dense(x.toArray)
    +      case x: Vector => x
    +      case x => throw new Exception(x.toString)
    +    }
    +
    +    val s = {
    +      val s2 = new MultivariateOnlineSummarizer
    +      inputVec.foreach(v => s2.add(OldVectors.fromML(v)))
    +      s2
    +    }
    +
    +    // Because the Spark context is reset between tests, we cannot hold a 
reference onto it.
    +    def wrapped() = {
    --- End diff --
    
    rename wrapped -> wrappedInit


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to