Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix parsing for empty DenseVector
  • Loading branch information
zero323 committed Apr 20, 2016
commit f46da1b76fbdfc46ced8133b69fcb08a003ee308
7 changes: 4 additions & 3 deletions python/pyspark/mllib/linalg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,9 @@ def parse(s):
if ind_end == -1:
raise ValueError("Indices array should end with ']'")
new_s = s[ind_start + 1: ind_end]
ind_list = new_s.split(',')
ind_list = new_s.split(',') if new_s else []
try:
indices = [int(ind) for ind in ind_list]
indices = [int(ind) for ind in ind_list]
except ValueError:
raise ValueError("Unable to parse indices from %s." % new_s)
s = s[ind_end + 1:].strip()
Expand All @@ -597,7 +597,8 @@ def parse(s):
val_end = s.find(']')
if val_end == -1:
raise ValueError("Values array should end with ']'.")
val_list = s[val_start + 1: val_end].split(',')
val_s = s[val_start + 1: val_end]
val_list = val_s.split(',') if val_s else []
try:
values = [float(val) for val in val_list]
except ValueError:
Expand Down