Skip to content

Commit

Permalink
[SPARK-9198] [MLLIB] [PYTHON] Fixed typo in pyspark sparsevector doc …
Browse files Browse the repository at this point in the history
…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]>
  • Loading branch information
jkbradley authored and mengxr committed Jul 20, 2015
1 parent 0df5304 commit 429eedd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions python/pyspark/mllib/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def dot(self, other):
25.0
>>> a.dot(array.array('d', [1., 2., 3., 4.]))
22.0
>>> b = SparseVector(4, [2, 4], [1.0, 2.0])
>>> b = SparseVector(4, [2], [1.0])
>>> a.dot(b)
0.0
>>> a.dot(np.array([[1, 1], [2, 2], [3, 3], [4, 4]]))
Expand Down Expand Up @@ -416,11 +416,11 @@ def squared_distance(self, other):
11.0
>>> a.squared_distance(np.array([1., 2., 3., 4.]))
11.0
>>> b = SparseVector(4, [2, 4], [1.0, 2.0])
>>> b = SparseVector(4, [2], [1.0])
>>> a.squared_distance(b)
30.0
26.0
>>> b.squared_distance(a)
30.0
26.0
>>> b.squared_distance([1., 2.])
Traceback (most recent call last):
...
Expand Down

0 comments on commit 429eedd

Please sign in to comment.