Skip to content

Commit 85885a9

Browse files
author
DB Tsai
committed
revert to have lazy in shift array.
1 parent daf2b06 commit 85885a9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

mllib/src/main/scala/org/apache/spark/mllib/feature/StandardScaler.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ class StandardScalerModel private[mllib] (
8585
f
8686
}
8787

88-
private val shift: Array[Double] = mean.toArray
88+
// Since `shift` will be only used in `withMean` branch, we have it as
89+
// `lazy val` so it will be evaluated in that branch. Note that we don't
90+
// want to create this array multiple times in `transform` function.
91+
private lazy val shift: Array[Double] = mean.toArray
8992

9093
/**
9194
* Applies standardization transformation on a vector.

0 commit comments

Comments
 (0)