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

    https://github.com/apache/spark/pull/5872#discussion_r29811164
  
    --- Diff: python/pyspark/mllib/linalg.py ---
    @@ -208,9 +209,55 @@ def __init__(self, ar):
                 ar = ar.astype(np.float64)
             self.array = ar
     
    +    def toString(self):
    +        """
    +        Convert DenseVector to string representation.
    +
    +        >>> a = DenseVector([0, 1, 2, 3])
    +        >>> a.toString()
    +        '[0.0,1.0,2.0,3.0]'
    +        """
    +        return str(self)
    +
    +    def copy(self):
    +        return DenseVector(np.copy(self.array))
    +
    +    @staticmethod
    +    def parse(vectorString):
    +        """
    +        Parse string representation back into the DenseVector.
    +
    +        >>> DenseVector.parse('[0.0,1.0,2.0,3.0]')
    +        DenseVector([0.0, 1.0, 2.0, 3.0])
    +        """
    +        vectorString = vectorString[1:-1]
    --- End diff --
    
    I think the Scala version is a bit more robust since it uses Java's 
StringTokenizer for splitting


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to