Skip to content

Commit f644438

Browse files
committed
remove parse methods based on eval from pyspark
1 parent a41675a commit f644438

File tree

2 files changed

+0
-41
lines changed

2 files changed

+0
-41
lines changed

python/pyspark/mllib/linalg.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -232,30 +232,6 @@ def dense(elements):
232232
"""
233233
return array(elements, dtype=float64)
234234

235-
236-
@staticmethod
237-
def parse(s):
238-
"""
239-
Parses a string resulted from Vectors.stringify() into a vector.
240-
241-
>>> Vectors.parse("[0.0,1.0]")
242-
array([ 0., 1.])
243-
>>> print Vectors.parse("(2,[1],[1.0])")
244-
(2,[1],[1.0])
245-
"""
246-
return Vectors._parse_structured(eval(s))
247-
248-
249-
@staticmethod
250-
def _parse_structured(data):
251-
if type(data) == list:
252-
return Vectors.dense(data)
253-
elif type(data) == tuple:
254-
return Vectors.sparse(data[0], data[1], data[2])
255-
else:
256-
raise SyntaxError("Cannot recognize " + data)
257-
258-
259235
@staticmethod
260236
def stringify(vector):
261237
"""

python/pyspark/mllib/regression.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,6 @@ def __str__(self):
4848
return "(" + ",".join((str(self.label), Vectors.stringify(self.features))) + ")"
4949

5050

51-
@staticmethod
52-
def parse(s):
53-
"""
54-
Parses a string resulted from str() to a LabeledPoint.
55-
56-
>>> print LabeledPoint.parse("(1.0,[0.0,1.0])")
57-
(1.0,[0.0,1.0])
58-
>>> print LabeledPoint.parse("(1.0,(2,[1],[1.0]))")
59-
(1.0,(2,[1],[1.0]))
60-
"""
61-
return LabeledPoint._parse_structured(eval(s))
62-
63-
64-
@staticmethod
65-
def _parse_structured(data):
66-
return LabeledPoint(data[0], Vectors._parse_structured(data[1]))
67-
6851
class LinearModel(object):
6952
"""A linear model that has a vector of coefficients and an intercept."""
7053
def __init__(self, weights, intercept):

0 commit comments

Comments
 (0)