Skip to content

Commit

Permalink
Fix Python3 error
Browse files Browse the repository at this point in the history
  • Loading branch information
MechCoder committed Jun 18, 2015
1 parent a9817df commit 8ab9e89
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -975,8 +975,7 @@ private[python] class PythonMLLibAPI extends Serializable {
val model = new StreamingKMeansModel(
clusterCenters.asScala.toArray, clusterWeights.asScala.toArray)
.update(data, decayFactor, timeUnit)
List(model.clusterCenters, model.clusterWeights).
map(_.asInstanceOf[Object]).asJava
List[AnyRef](model.clusterCenters, Vectors.dense(model.clusterWeights)).asJava
}

}
Expand Down
5 changes: 3 additions & 2 deletions python/pyspark/mllib/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
import array as pyarray
from time import time, sleep

from numpy import array, array_equal, zeros, inf, all, random, sum
from numpy import array, array_equal, zeros, inf, all, random
from numpy import sum as array_sum
from py4j.protocol import Py4JJavaError

if sys.version_info[:2] <= (2, 6):
Expand Down Expand Up @@ -908,7 +909,7 @@ def test_accuracy_for_single_center(self):
self.ssc.start()
self._ssc_wait(t, 10.0, 0.01)
self.assertEquals(stkm.latestModel.getClusterWeights, [25.0])
realCenters = sum(array(centers), axis=0)
realCenters = array_sum(array(centers), axis=0)
for i in range(d):
modelCenters = stkm.latestModel.centers[0][i]
self.assertAlmostEqual(centers[0][i], modelCenters, 1)
Expand Down

0 comments on commit 8ab9e89

Please sign in to comment.