Skip to content

Commit

Permalink
formating
Browse files Browse the repository at this point in the history
  • Loading branch information
DB Tsai committed Nov 21, 2014
1 parent 03dd693 commit 844b0e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ class MultivariateOnlineSummarizer extends MultivariateStatisticalSummary with S
require(n == sample.size, s"Dimensions mismatch when adding new sample." +
s" Expecting $n but got ${sample.size}.")

sample.foreachActive((index, value) => {
if(value != 0.0){
sample.foreachActive { (index, value) =>
if (value != 0.0) {
if (currMax(index) < value) {
currMax(index) = value
}
Expand All @@ -88,7 +88,7 @@ class MultivariateOnlineSummarizer extends MultivariateStatisticalSummary with S

nnz(index) += 1.0
}
})
}

totalCnt += 1
this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,20 +174,24 @@ class VectorsSuite extends FunSuite {
assert(v.size === x.rows)
}

test("foreach") {
test("foreachActive") {
val dv = Vectors.dense(0.0, 1.2, 3.1, 0.0)
val sv = Vectors.sparse(4, Seq((1, 1.2), (2, 3.1), (3, 0.0)))

val dvMap = scala.collection.mutable.Map[Int, Double]()
dv.foreachActive((index, value) => dvMap.put(index, value))
dv.foreachActive { (index, value) =>
dvMap.put(index, value)
}
assert(dvMap.size === 4)
assert(dvMap.get(0) === Some(0.0))
assert(dvMap.get(1) === Some(1.2))
assert(dvMap.get(2) === Some(3.1))
assert(dvMap.get(3) === Some(0.0))

val svMap = scala.collection.mutable.Map[Int, Double]()
sv.foreachActive((index, value) => svMap.put(index, value))
sv.foreachActive { (index, value) =>
svMap.put(index, value)
}
assert(svMap.size === 3)
assert(svMap.get(1) === Some(1.2))
assert(svMap.get(2) === Some(3.1))
Expand Down

0 comments on commit 844b0e6

Please sign in to comment.