Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit f2eba2f

Browse files
committed
Cleaning up unit tests to be fewer lines
1 parent aa330e3 commit f2eba2f

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

mllib/src/test/scala/org/apache/spark/mllib/linalg/VectorsSuite.scala

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,10 @@ class VectorsSuite extends FunSuite {
6868
assert(vec.argmax === -1)
6969

7070
val vec2 = Vectors.dense(arr).asInstanceOf[DenseVector]
71-
val max = vec2.argmax
72-
assert(max === 3)
71+
assert(vec2.argmax === 3)
7372

7473
val vec3 = Vectors.dense(Array(-1.0, 0.0, -2.0, 1.0)).asInstanceOf[DenseVector]
75-
val max2 = vec3.argmax
76-
assert(max === 3)
74+
assert(vec3.argmax === 3)
7775
}
7876

7977
test("sparse to array") {
@@ -83,37 +81,29 @@ class VectorsSuite extends FunSuite {
8381

8482
test("sparse argmax") {
8583
val vec = Vectors.sparse(0,Array.empty[Int],Array.empty[Double]).asInstanceOf[SparseVector]
86-
val noMax = vec.argmax
87-
assert(noMax === -1)
84+
assert(vec.argmax === -1)
8885

8986
val vec2 = Vectors.sparse(n,indices,values).asInstanceOf[SparseVector]
90-
val max = vec2.argmax
91-
assert(max === 3)
87+
assert(vec2.argmax === 3)
9288

9389
val vec3 = Vectors.sparse(5,Array(2, 3, 4),Array(1.0, 0.0, -.7))
94-
val max2 = vec3.argmax
95-
assert(max2 === 2)
90+
assert(vec3.argmax === 2)
9691

9792
// check for case that sparse vector is created with only negative values {0.0, 0.0,-1.0, -0.7, 0.0}
9893
val vec4 = Vectors.sparse(5,Array(2, 3),Array(-1.0, -.7))
99-
val max3 = vec4.argmax
100-
assert(max3 === 0)
94+
assert(vec4.argmax === 0)
10195

10296
val vec5 = Vectors.sparse(11,Array(0, 3, 10),Array(-1.0, -.7, 0.0))
103-
val max4 = vec5.argmax
104-
assert(max4 === 1)
97+
assert(vec5.argmax === 1)
10598

10699
val vec6 = Vectors.sparse(11,Array(0, 1, 2),Array(-1.0, -.7, 0.0))
107-
val max5 = vec6.argmax
108-
assert(max5 === 2)
100+
assert(vec6.argmax === 2)
109101

110102
val vec7 = Vectors.sparse(5,Array(0, 1, 3),Array(-1.0, 0.0, -.7))
111-
val max6 = vec7.argmax
112-
assert(max6 === 1)
103+
assert(vec7.argmax === 1)
113104

114105
var vec8 = Vectors.sparse(5,Array(1, 2),Array(0.0, -1.0))
115-
val max7 = vec8.argmax
116-
assert(max7 === 0)
106+
assert(vec8.argmax === 0)
117107
}
118108

119109
test("vector equals") {

0 commit comments

Comments
 (0)