Skip to content

Commit a8ff1e0

Browse files
committed
minor
1 parent ce3e53e commit a8ff1e0

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

python/pyspark/mllib/linalg.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,16 @@ def parse(s):
218218
"""
219219
start = s.find('[')
220220
if start == -1:
221-
raise ValueError("Array should start with '['")
221+
raise ValueError("Array should start with '['.")
222222
end = s.find(']')
223223
if end == -1:
224-
raise ValueError("Array should end with ']")
224+
raise ValueError("Array should end with ']'.")
225225
s = s[start + 1: end]
226226

227227
try:
228228
values = [float(val) for val in s.split(',')]
229229
except ValueError:
230-
raise ValueError("Unable to parse values.")
230+
raise ValueError("Unable to parse values from %s" % s)
231231
return DenseVector(values)
232232

233233
def __reduce__(self):
@@ -468,28 +468,29 @@ def parse(s):
468468

469469
ind_start = s.find('[')
470470
if ind_start == -1:
471-
raise ValueError("Indices array should start with '('.")
471+
raise ValueError("Indices array should start with '['.")
472472
ind_end = s.find(']')
473473
if ind_end == -1:
474-
raise ValueError("Indices array should end with ')'")
475-
ind_list = s[ind_start + 1: ind_end].split(',')
474+
raise ValueError("Indices array should end with ']'")
475+
new_s = s[ind_start + 1: ind_end]
476+
ind_list = new_s.split(',')
476477
try:
477478
indices = [int(ind) for ind in ind_list]
478479
except ValueError:
479-
raise ValueError("Unabel to parse indices.")
480+
raise ValueError("Unable to parse indices from %s." % new_s)
480481
s = s[ind_end + 1:].strip()
481482

482483
val_start = s.find('[')
483484
if val_start == -1:
484-
raise ValueError("Values array should start with '('.")
485+
raise ValueError("Values array should start with '['.")
485486
val_end = s.find(']')
486487
if val_end == -1:
487-
raise ValueError("Values array should end with ')'.")
488+
raise ValueError("Values array should end with ']'.")
488489
val_list = s[val_start + 1: val_end].split(',')
489490
try:
490491
values = [float(val) for val in val_list]
491492
except ValueError:
492-
raise ValueError("Unable to parse values.")
493+
raise ValueError("Unable to parse values from %s." % s)
493494
return SparseVector(size, indices, values)
494495

495496
def dot(self, other):

0 commit comments

Comments
 (0)