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

    https://github.com/apache/spark/pull/15496#discussion_r90139924
  
    --- Diff: python/pyspark/ml/linalg/__init__.py ---
    @@ -705,6 +705,22 @@ def __eq__(self, other):
                 return Vectors._equals(self.indices, self.values, 
list(xrange(len(other))), other.array)
             return False
     
    +    def __getattr__(self, item):
    +        def wrapper(*args, **kwargs):
    +            if _have_scipy:
    +                csr = scipy.sparse.csr_matrix((np.append(self.values, 0),
    +                                               np.append(self.indices, 
self.size-1),
    +                                               [0, len(self.values)]))
    +                func = getattr(csr, item)
    +                result = func(*args, **kwargs)
    +                if isinstance(result, scipy.sparse.csr.csr_matrix):
    +                    return 
SparseVector(result.shape[1],result.indices,result.data)
    +                return result
    +            else:
    +                raise AttributeError(
    +                    "'{0}' object has no attribute '{1}' or SciPy not 
installed.".format(self.__class__, item))
    --- End diff --
    
    Ok so maybe we can improve the error message to something like "'{0}' 
object has no attribute '{1}' and SciPy is not installed to proxy request to 
SparseVector" (or similar).
    
    Because saying its X or Y is confusing since this error message only 
happens in the event SciPy is not installed.
    
    What do you think?


---
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