Github user hhbyyh commented on a diff in the pull request:
https://github.com/apache/spark/pull/3997#discussion_r23139716
--- Diff:
mllib/src/test/scala/org/apache/spark/mllib/linalg/VectorsSuite.scala ---
@@ -89,6 +89,29 @@ class VectorsSuite extends FunSuite {
}
}
+ test("sparse equals with explicit 0") {
+ val sv1 = Vectors.sparse(10, Array(1, 3, 4, 7), Array(0.9, 0.8, 0.7,
0.6))
+ val sv2 = Vectors.sparse(10, Array(0, 1, 3, 4, 7), Array(0.0, 0.9,
0.8, 0.7, 0.6))
+ val sv3 = Vectors.sparse(10, Array(1, 3, 4, 5, 6, 7), Array(0.9, 0.8,
0.7, 0, 0, 0.6))
+ val sv4 = Vectors.sparse(10, Array(1, 3, 4, 7, 9), Array(0.9, 0.8,
0.7, 0.6, 0))
+ val sv5 = Vectors.sparse(10, Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9),
+ Array(0, 0.9, 0, 0.8, 0.7, 0, 0, 0.6, 0, 0))
+
+ val vectors = Seq(sv1, sv2, sv3, sv4, sv5)
+
+ for (v <- vectors; u <- vectors) {
+ assert(v === u)
+ assert(v.## === u.##)
+ }
+
+ val another = Vectors.sparse(10, Array(1, 3, 4, 7), Array(0.9, 0.2,
0.7, 0.6))
+
+ for (v <- vectors) {
+ assert(v != another)
+ assert(v.## != another.##)
+ }
+ }
+
--- End diff --
sure. I'll add some.
---
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]