Github user mengxr commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2548#discussion_r18245962
  
    --- Diff: python/pyspark/mllib/linalg.py ---
    @@ -222,20 +283,33 @@ def dot(self, other):
             0.0
             >>> a.dot(np.array([[1, 1], [2, 2], [3, 3], [4, 4]]))
             array([ 22.,  22.])
    +        >>> a.dot([1., 2., 3.])
    +        Traceback (most recent call last):
    +            ...
    +        AssertionError: dimension mismatch
    +        >>> a.dot(np.array([1., 2.]))
    +        Traceback (most recent call last):
    +            ...
    +        AssertionError: dimension mismatch
    +        >>> a.dot(DenseVector([1., 2.]))
    +        Traceback (most recent call last):
    +            ...
    +        AssertionError: dimension mismatch
    +        >>> a.dot(np.zeros((3, 2)))
    +        Traceback (most recent call last):
    +            ...
    +        AssertionError: dimension mismatch
             """
             if type(other) == np.ndarray:
    -            if other.ndim == 1:
    -                result = 0.0
    -                for i in xrange(len(self.indices)):
    -                    result += self.values[i] * other[self.indices[i]]
    -                return result
    -            elif other.ndim == 2:
    +            if other.ndim == 2:
                     results = [self.dot(other[:, i]) for i in 
xrange(other.shape[1])]
                     return np.array(results)
    -            else:
    -                raise Exception("Cannot call dot with %d-dimensional 
array" % other.ndim)
    +            elif other.ndim > 2:
    +                raise ValueError("Cannot call dot with %d-dimentaional 
array" % other.ndim)
    --- End diff --
    
    done.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to