Github user holdenk commented on a diff in the pull request: https://github.com/apache/spark/pull/15496#discussion_r89464558 --- 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 -- This error message would probably be better of just saying SciPy not installed since its on the else branch of `if _have_scipy` unless I'm missing something?
--- 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