Skip to content

Commit 7722d16

Browse files
committed
minor style fixes
1 parent 51052d3 commit 7722d16

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

python/pyspark/mllib/tests.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -893,16 +893,16 @@ def test_model_params(self):
893893
self.assertIsNone(stkm.latestModel())
894894
self.assertRaises(ValueError, stkm.trainOn, [0.0, 1.0])
895895

896-
stkm.setInitialCenters([[0.0, 0.0], [1.0, 1.0]], [1.0, 1.0])
896+
stkm.setInitialCenters(
897+
centers=[[0.0, 0.0], [1.0, 1.0]], weights=[1.0, 1.0])
897898
self.assertEquals(
898899
stkm.latestModel().centers, [[0.0, 0.0], [1.0, 1.0]])
899900
self.assertEquals(stkm.latestModel().clusterWeights, [1.0, 1.0])
900901

901902
def test_accuracy_for_single_center(self):
902-
"""Test that the parameters obtained are correct for a single center."""
903-
numBatches, numPoints, k, d, r, seed = 5, 5, 1, 5, 0.1, 0
903+
"""Test that parameters obtained are correct for a single center."""
904904
centers, batches = self.streamingKMeansDataGenerator(
905-
numBatches, numPoints, k, d, r, seed)
905+
batches=5, numPoints=5, k=1, d=5, r=0.1, seed=0)
906906
stkm = StreamingKMeans(1)
907907
stkm.setInitialCenters([[0., 0., 0., 0., 0.]], [0.])
908908
input_stream = self.ssc.queueStream(
@@ -914,7 +914,7 @@ def test_accuracy_for_single_center(self):
914914
self._ssc_wait(t, 10.0, 0.01)
915915
self.assertEquals(stkm.latestModel().clusterWeights, [25.0])
916916
realCenters = array_sum(array(centers), axis=0)
917-
for i in range(d):
917+
for i in range(5):
918918
modelCenters = stkm.latestModel().centers[0][i]
919919
self.assertAlmostEqual(centers[0][i], modelCenters, 1)
920920
self.assertAlmostEqual(realCenters[i], modelCenters, 1)
@@ -934,8 +934,8 @@ def test_trainOn_model(self):
934934
"""Test the model on toy data with four clusters."""
935935
stkm = StreamingKMeans()
936936
initCenters = [[1.0, 1.0], [-1.0, 1.0], [-1.0, -1.0], [1.0, -1.0]]
937-
weights = [1.0, 1.0, 1.0, 1.0]
938-
stkm.setInitialCenters(initCenters, weights)
937+
stkm.setInitialCenters(
938+
centers=initCenters, weights=[1.0, 1.0, 1.0, 1.0])
939939

940940
# Create a toy dataset by setting a tiny offest for each point.
941941
offsets = [[0, 0.1], [0, -0.1], [0.1, 0], [-0.1, 0]]
@@ -958,10 +958,10 @@ def test_trainOn_model(self):
958958

959959
def test_predictOn_model(self):
960960
"""Test that the model predicts correctly on toy data."""
961-
initCenters = [[1.0, 1.0], [-1.0, 1.0], [-1.0, -1.0], [1.0, -1.0]]
962-
weights = [1.0, 1.0, 1.0, 1.0]
963961
stkm = StreamingKMeans()
964-
stkm._model = StreamingKMeansModel(initCenters, weights)
962+
stkm._model = StreamingKMeansModel(
963+
clusterCenters=[[1.0, 1.0], [-1.0, 1.0], [-1.0, -1.0], [1.0, -1.0]],
964+
clusterWeights=[1.0, 1.0, 1.0, 1.0])
965965

966966
predict_data = [[[1.5, 1.5]], [[-1.5, 1.5]], [[-1.5, -1.5]], [[1.5, -1.5]]]
967967
predict_data = [sc.parallelize(batch, 1) for batch in predict_data]

0 commit comments

Comments
 (0)