Skip to content
Snippets Groups Projects
Commit 26000af4 authored by Ismael Juma's avatar Ismael Juma
Browse files

Replace deprecated fromFunction with either tabulate or fill.

tabulate used if indexed used by function and fill otherwise.
parent 0b6a862b
No related branches found
No related tags found
No related merge requests found
...@@ -106,8 +106,8 @@ object LocalALS { ...@@ -106,8 +106,8 @@ object LocalALS {
val R = generateR() val R = generateR()
// Initialize m and u randomly // Initialize m and u randomly
var ms = Array.fromFunction(_ => factory1D.random(F))(M) var ms = Array.fill(M)(factory1D.random(F))
var us = Array.fromFunction(_ => factory1D.random(F))(U) var us = Array.fill(U)(factory1D.random(F))
// Iteratively update movies then users // Iteratively update movies then users
for (iter <- 1 to ITERATIONS) { for (iter <- 1 to ITERATIONS) {
......
...@@ -18,7 +18,7 @@ object LocalLR { ...@@ -18,7 +18,7 @@ object LocalLR {
val x = Vector(D, _ => rand.nextGaussian + y * R) val x = Vector(D, _ => rand.nextGaussian + y * R)
DataPoint(x, y) DataPoint(x, y)
} }
Array.fromFunction(generatePoint _)(N) Array.tabulate(N)(generatePoint)
} }
def main(args: Array[String]) { def main(args: Array[String]) {
......
...@@ -117,8 +117,8 @@ object SparkALS { ...@@ -117,8 +117,8 @@ object SparkALS {
val R = generateR() val R = generateR()
// Initialize m and u randomly // Initialize m and u randomly
var ms = Array.fromFunction(_ => factory1D.random(F))(M) var ms = Array.fill(M)(factory1D.random(F))
var us = Array.fromFunction(_ => factory1D.random(F))(U) var us = Array.fill(U)(factory1D.random(F))
// Iteratively update movies then users // Iteratively update movies then users
val Rc = spark.broadcast(R) val Rc = spark.broadcast(R)
......
...@@ -20,7 +20,7 @@ object SparkLR { ...@@ -20,7 +20,7 @@ object SparkLR {
val x = Vector(D, _ => rand.nextGaussian + y * R) val x = Vector(D, _ => rand.nextGaussian + y * R)
DataPoint(x, y) DataPoint(x, y)
} }
Array.fromFunction(generatePoint _)(N) Array.tabulate(N)(generatePoint)
} }
def main(args: Array[String]) { def main(args: Array[String]) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment