Skip to content

Commit c8b17da

Browse files
jkbradleymengxr
authored andcommitted
[SPARK-9198] [MLLIB] [PYTHON] Fixed typo in pyspark sparsevector doc tests
Several places in the PySpark SparseVector docs have one defined as: ``` SparseVector(4, [2, 4], [1.0, 2.0]) ``` The index 4 goes out of bounds (but this is not checked). CC: mengxr Author: Joseph K. Bradley <[email protected]> Closes #7541 from jkbradley/sparsevec-doc-typo-fix and squashes the following commits: c806a65 [Joseph K. Bradley] fixed doc test e2dcb23 [Joseph K. Bradley] Fixed typo in pyspark sparsevector doc tests (cherry picked from commit a5d0581) Signed-off-by: Xiangrui Meng <[email protected]>
1 parent 596a4cb commit c8b17da

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

python/pyspark/mllib/linalg.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ def dot(self, other):
390390
25.0
391391
>>> a.dot(array.array('d', [1., 2., 3., 4.]))
392392
22.0
393-
>>> b = SparseVector(4, [2, 4], [1.0, 2.0])
393+
>>> b = SparseVector(4, [2], [1.0])
394394
>>> a.dot(b)
395395
0.0
396396
>>> a.dot(np.array([[1, 1], [2, 2], [3, 3], [4, 4]]))
@@ -455,11 +455,11 @@ def squared_distance(self, other):
455455
11.0
456456
>>> a.squared_distance(np.array([1., 2., 3., 4.]))
457457
11.0
458-
>>> b = SparseVector(4, [2, 4], [1.0, 2.0])
458+
>>> b = SparseVector(4, [2], [1.0])
459459
>>> a.squared_distance(b)
460-
30.0
460+
26.0
461461
>>> b.squared_distance(a)
462-
30.0
462+
26.0
463463
>>> b.squared_distance([1., 2.])
464464
Traceback (most recent call last):
465465
...

0 commit comments

Comments
 (0)