Skip to content

Commit

Permalink
fix doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
MechCoder committed Jul 2, 2015
1 parent fcad0a3 commit bce2b07
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/pyspark/mllib/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,17 +577,20 @@ def dot(self, other):
...
AssertionError: dimension mismatch
"""
assert len(self) == _vector_size(other), "dimension mismatch"

if isinstance(other, np.ndarray):
if other.ndim == 2:
results = [self.dot(other[:, i]) for i in xrange(other.shape[1])]
return np.array(results)
elif other.ndim == 1:
assert len(self) == _vector_size(other), "dimension mismatch"
return np.dot(other[self.indices], self.values)
else:
raise ValueError("Cannot call dot with %d-dimensional array" % other.ndim)

elif isinstance(other, DenseVector):
assert len(self) == _vector_size(other), "dimension mismatch"

if isinstance(other, DenseVector):
return np.dot(other.array[self.indices], self.values)

elif isinstance(other, SparseVector):
Expand Down

0 comments on commit bce2b07

Please sign in to comment.