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

    https://github.com/apache/spark/pull/3869#discussion_r22477129
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/mllib/linalg/VectorsSuite.scala ---
    @@ -175,6 +177,33 @@ class VectorsSuite extends FunSuite {
         assert(v.size === x.rows)
       }
     
    +  test("sqdist") {
    +    val random = new Random(System.nanoTime())
    +    for (m <- 1 until 1000 by 10) {
    +      val nnz = random.nextInt(m) + 1
    +
    +      val indices1 = random.shuffle(0 to m - 1).toArray.slice(0, 
nnz).sorted
    +      val values1 = indices1.map(i => random.nextInt(m + 1) * 
random.nextDouble())
    +      val sparseVector1 = Vectors.sparse(m, indices1, values1)
    +
    +      val indices2 = random.shuffle(0 to m - 1).toArray.slice(0, 
nnz).sorted
    +      val values2 = indices2.map(i => random.nextInt(m + 1) * 
random.nextDouble())
    +      val sparseVector2 = Vectors.sparse(m, indices2, values2)
    +
    +      val denseVector1 = Vectors.dense(sparseVector1.toArray)
    +      val denseVector2 = Vectors.dense(sparseVector2.toArray)
    +
    +      val squaredDist = breezeSquaredDistance(sparseVector1.toBreeze, 
sparseVector2.toBreeze)
    +
    +      // SparseVector vs. SparseVector 
    +      assert(Vectors.sqdist(sparseVector1, sparseVector2) === squaredDist) 
    --- End diff --
    
    We should allow small numerical error here, e.g.:
    
    
https://github.com/apache/spark/blob/master/mllib/src/test/scala/org/apache/spark/mllib/linalg/VectorsSuite.scala#L202


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to