Skip to content

Commit 326988e

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 e0c2ccf commit 326988e

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
@@ -77,7 +77,7 @@ def dot(self, other):
7777
25.0
7878
>>> a.dot(array([1., 2., 3., 4.]))
7979
22.0
80-
>>> b = SparseVector(4, [2, 4], [1.0, 2.0])
80+
>>> b = SparseVector(4, [2], [1.0])
8181
>>> a.dot(b)
8282
0.0
8383
>>> a.dot(array([[1, 1], [2, 2], [3, 3], [4, 4]]))
@@ -117,11 +117,11 @@ def squared_distance(self, other):
117117
0.0
118118
>>> a.squared_distance(array([1., 2., 3., 4.]))
119119
11.0
120-
>>> b = SparseVector(4, [2, 4], [1.0, 2.0])
120+
>>> b = SparseVector(4, [2], [1.0])
121121
>>> a.squared_distance(b)
122-
30.0
122+
26.0
123123
>>> b.squared_distance(a)
124-
30.0
124+
26.0
125125
"""
126126
if type(other) == ndarray:
127127
if other.ndim == 1:

0 commit comments

Comments
 (0)