Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index lists with double references using negative indices #1395

Merged
merged 2 commits into from
Mar 2, 2018

Conversation

jgosmann
Copy link
Collaborator

@jgosmann jgosmann commented Dec 29, 2017

Motivation and context:
There is one special case with sliced indexing that still does not correctly work: If a list of indices references the same index twice, but once with a positive integer and once with a negative integer, one of those will overwrite the other one when the slicing is done on an input. This PR fixes that by converting all indices to positive indices (as a canonical representation) before checking for repeated indices.

Interactions with other PRs:
none

How has this been tested?
added a test

How long should this take to review?

  • Average (neither quick nor lengthy)

Where should a reviewer start?
I'd recommend going commit by commit, but the PR is small enough that looking at the full diff should work too.

Types of changes:

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have read the CONTRIBUTING.rst document.
  • I have updated the documentation accordingly.
  • I have included a changelog entry.
  • I have added tests to cover my changes.
  • I have run the test suite locally and all tests passed.

@jgosmann jgosmann added the bug label Dec 29, 2017
@Seanny123
Copy link
Contributor

There's an issue with Numpy 1.8 on Python 2.7 that should be resolved before merging.

@jgosmann jgosmann removed their assignment Jan 2, 2018
@jgosmann
Copy link
Collaborator Author

jgosmann commented Jan 2, 2018

I replaced the last commit, now the tests should pass.

Copy link
Member

@tbekolay tbekolay left a comment

Choose a reason for hiding this comment

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

Pushed a commit with a few improvements. LGTM! Will merge in an hour or so if no one stops me.

This commit adds a comment explaining why a ValueError can occur
in an indexing operation and catches the same error in the second
indexing operation for consistency.
These might reference the same elements as positive indices and
therefore need special handling.

`test_list_indexing` was modified to test negative indices, and to
create all plots before the first assertion so that they can be
viewed if an assertion fails. Additionally, some test tolerances
were raised to accommodate more seeds.
@tbekolay tbekolay merged commit c107a47 into master Mar 2, 2018
@tbekolay tbekolay deleted the negative-indices branch March 2, 2018 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

3 participants