Skip to content

Commit 429eedd

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 0df5304 commit 429eedd

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
@@ -351,7 +351,7 @@ def dot(self, other):
351351
25.0
352352
>>> a.dot(array.array('d', [1., 2., 3., 4.]))
353353
22.0
354-
>>> b = SparseVector(4, [2, 4], [1.0, 2.0])
354+
>>> b = SparseVector(4, [2], [1.0])
355355
>>> a.dot(b)
356356
0.0
357357
>>> a.dot(np.array([[1, 1], [2, 2], [3, 3], [4, 4]]))
@@ -416,11 +416,11 @@ def squared_distance(self, other):
416416
11.0
417417
>>> a.squared_distance(np.array([1., 2., 3., 4.]))
418418
11.0
419-
>>> b = SparseVector(4, [2, 4], [1.0, 2.0])
419+
>>> b = SparseVector(4, [2], [1.0])
420420
>>> a.squared_distance(b)
421-
30.0
421+
26.0
422422
>>> b.squared_distance(a)
423-
30.0
423+
26.0
424424
>>> b.squared_distance([1., 2.])
425425
Traceback (most recent call last):
426426
...

0 commit comments

Comments
 (0)