Skip to content

[SPARK-10973][ML][PYTHON] __gettitem__ method throws IndexError exception when we…#9009

Closed
zero323 wants to merge 2 commits into
apache:masterfrom
zero323:sparse_vector_index_error
Closed

[SPARK-10973][ML][PYTHON] __gettitem__ method throws IndexError exception when we…#9009
zero323 wants to merge 2 commits into
apache:masterfrom
zero323:sparse_vector_index_error

Conversation

@zero323

@zero323 zero323 commented Oct 7, 2015

Copy link
Copy Markdown
Member

gettitem method throws IndexError exception when we try to access index after the last non-zero entry

from pyspark.mllib.linalg import Vectors
sv = Vectors.sparse(5, {1: 3})
sv[0]
## 0.0
sv[1]
## 3.0
sv[2]
## Traceback (most recent call last):
##   File "<stdin>", line 1, in <module>
##   File "/python/pyspark/mllib/linalg/__init__.py", line 734, in __getitem__
##     row_ind = inds[insert_index]
## IndexError: index out of bounds

… try to access index after the last non-zero entry.
@jkbradley

Copy link
Copy Markdown
Member

ok to test

@jkbradley

Copy link
Copy Markdown
Member

test this please

Comment thread python/pyspark/mllib/linalg/__init__.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May as well use inds here for clarity since that's what is used elsewhere

@jkbradley

Copy link
Copy Markdown
Member

LGTM

Ping @mengxr FYI. Also, which Spark versions are we patching?

@jkbradley

Copy link
Copy Markdown
Member

@zero323 Can you please add tags "[ML] [PYTHON]" to the title of this PR?

@SparkQA

SparkQA commented Oct 8, 2015

Copy link
Copy Markdown

Test build #1859 has finished for PR 9009 at commit d28a644.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@zero323 zero323 changed the title [SPARK-10973] __gettitem__ method throws IndexError exception when we… [SPARK-10973][ML][PYTHON] __gettitem__ method throws IndexError exception when we… Oct 8, 2015
@zero323

zero323 commented Oct 8, 2015

Copy link
Copy Markdown
Member Author

@jkbradley Done.

@jkbradley

Copy link
Copy Markdown
Member

Thanks! I'll merge this with master once tests pass.

Would you be able to send PRs against branch-1.3, branch-1.4, branch-1.5 in order to backport this to previous Spark versions? They can use the same JIRA number.

@SparkQA

SparkQA commented Oct 8, 2015

Copy link
Copy Markdown

Test build #1862 has finished for PR 9009 at commit a1898ee.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@jkbradley

Copy link
Copy Markdown
Member

merging with master

@zero323

zero323 commented Oct 10, 2015

Copy link
Copy Markdown
Member Author

@jkbradley #9062, #9063, #9064

@zero323

zero323 commented Oct 10, 2015

Copy link
Copy Markdown
Member Author

It should be possible to push this check before binary search: 8a695fe2c3344acd19279fcd539177426d436a02

@jkbradley

Copy link
Copy Markdown
Member

@zero323 Good point, that's better for sure. Do you mind preparing a patch for 1.6 for that? (I don't think it's necessary to backport it everywhere.)

@zero323

zero323 commented Oct 11, 2015

Copy link
Copy Markdown
Member Author

@jkbradley Sure, I can do it later this week. Should I open a new JIRA for that?

@jkbradley

Copy link
Copy Markdown
Member

Yes, please. Thanks!

asfgit pushed a commit that referenced this pull request Oct 12, 2015
…when asked for index after the last non-zero entry

See #9009 for details.

Author: zero323 <matthew.szymkiewicz@gmail.com>

Closes #9064 from zero323/SPARK-10973_1.5.
asfgit pushed a commit that referenced this pull request Oct 12, 2015
…when asked for index after the last non-zero entry

See #9009 for details.

Author: zero323 <matthew.szymkiewicz@gmail.com>

Closes #9063 from zero323/SPARK-10973_1.4.
asfgit pushed a commit that referenced this pull request Oct 13, 2015
…when asked for index after the last non-zero entry

See #9009 for details.

Author: zero323 <matthew.szymkiewicz@gmail.com>

Closes #9062 from zero323/SPARK-10973_1.3.
@zero323

zero323 commented Oct 13, 2015

Copy link
Copy Markdown
Member Author

@jkbradley I've created a JIRA and opened a PR.

@zero323 zero323 deleted the sparse_vector_index_error branch April 6, 2017 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants