GitHub user itg-abby reopened a pull request: https://github.com/apache/spark/pull/15496
[SPARK-17950] [Python] Match SparseVector behavior with DenseVector ## What changes were proposed in this pull request? Simply added the `__getattr__` to SparseVector that DenseVector has, but calls self.toArray() instead of storing a vector all the time in self.array This allows for use of numpy functions on the values of a SparseVector in the same direct way that users interact with DenseVectors. i.e. you can simply call SparseVector.mean() to average the values in the entire vector. ## How was this patch tested? Manual testing on local machine. Passed ./dev/run-tests No UI changes. You can merge this pull request into a Git repository by running: $ git pull https://github.com/itg-abby/spark patch-2 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/15496.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #15496 ---- commit d9b6ecc9c7aaebf834556797404ff783fef44dcf Author: itg-abby <abbys...@gmail.com> Date: 2016-10-15T00:03:08Z Match SparseVector behavior with DenseVector << What changes were proposed in this pull request? >> Simply added the __getattr__ to SparseVector that DenseVector has, but calls to self.toArray() instead of storing a vector all the time in self.array This allows for use of numpy functions on the values of a SparseVector in the same direct way that users interact with DenseVectors. <<How was this patch tested?>> Manual testing on local machine. ---- --- 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