Github user mateiz commented on a diff in the pull request:
https://github.com/apache/spark/pull/685#discussion_r12502581
--- Diff: python/pyspark/mllib/linalg.py ---
@@ -234,6 +233,45 @@ def dense(elements):
return array(elements, dtype=float64)
+ @staticmethod
+ def parse(s):
+ """
+ Parses a string resulted from Vectors.stringify() into a vector.
+
+ >>> Vectors.parse("[0.0,1.0]")
+ array([ 0., 1.])
+ >>> print Vectors.parse("(2,[1],[1.0])")
+ (2,[1],[1.0])
+ """
+ return Vectors._parse_structured(eval(s))
--- End diff --
We can't use eval here; it will be both slow and a security risk. If it's a
lot of work to create a fast parser in Python (which is might be), maybe we
should instead do JSON, with just tuples.
---
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.
---