Skip to content

Commit a57d9a2

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 2f9d5f4 commit a57d9a2

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
@@ -502,7 +502,7 @@ def dot(self, other):
502502
25.0
503503
>>> a.dot(array.array('d', [1., 2., 3., 4.]))
504504
22.0
505-
>>> b = SparseVector(4, [2, 4], [1.0, 2.0])
505+
>>> b = SparseVector(4, [2], [1.0])
506506
>>> a.dot(b)
507507
0.0
508508
>>> a.dot(np.array([[1, 1], [2, 2], [3, 3], [4, 4]]))
@@ -567,11 +567,11 @@ def squared_distance(self, other):
567567
11.0
568568
>>> a.squared_distance(np.array([1., 2., 3., 4.]))
569569
11.0
570-
>>> b = SparseVector(4, [2, 4], [1.0, 2.0])
570+
>>> b = SparseVector(4, [2], [1.0])
571571
>>> a.squared_distance(b)
572-
30.0
572+
26.0
573573
>>> b.squared_distance(a)
574-
30.0
574+
26.0
575575
>>> b.squared_distance([1., 2.])
576576
Traceback (most recent call last):
577577
...

0 commit comments

Comments
 (0)