-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Python] Slicing an array backwards beyond the start doesn't include first item #38768
Comments
Merged
5 tasks
Hi, I am interested in working on this issue. I will have a look and submit a PR. |
LucasG0
added a commit
to LucasG0/arrow
that referenced
this issue
Dec 15, 2023
jorisvandenbossche
pushed a commit
that referenced
this issue
Mar 15, 2024
…cludes first item. (#39240) ### What changes are included in this PR? Minor changes in `_normalize_slice` so `start` and `stop` are both computed in a single if/else block instead of having them modified later in case of a negative `step`. ### Are these changes tested? Yes. ### Are there any user-facing changes? Fixing wrong data returned in an edge case. * Closes: #38768 Authored-by: LucasG0 <[email protected]> Signed-off-by: Joris Van den Bossche <[email protected]>
jorisvandenbossche
added a commit
that referenced
this issue
Apr 9, 2024
…is now empty (#40682) ### What changes are included in this PR? `_normalize_slice` now relies on `slice.indices` (https://docs.python.org/3/reference/datamodel.html#slice.indices). ### Are these changes tested? Yes. ### Are there any user-facing changes? Fixing wrong data returned in an edge case. * GitHub Issue: #40642 * GitHub Issue: #38768 Lead-authored-by: LucasG0 <[email protected]> Co-authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Joris Van den Bossche <[email protected]>
raulcd
pushed a commit
that referenced
this issue
Apr 10, 2024
…is now empty (#40682) ### What changes are included in this PR? `_normalize_slice` now relies on `slice.indices` (https://docs.python.org/3/reference/datamodel.html#slice.indices). ### Are these changes tested? Yes. ### Are there any user-facing changes? Fixing wrong data returned in an edge case. * GitHub Issue: #40642 * GitHub Issue: #38768 Lead-authored-by: LucasG0 <[email protected]> Co-authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Joris Van den Bossche <[email protected]>
verma-kartik
pushed a commit
to verma-kartik/arrow
that referenced
this issue
Apr 11, 2024
…start is now empty (apache#40682) ### What changes are included in this PR? `_normalize_slice` now relies on `slice.indices` (https://docs.python.org/3/reference/datamodel.html#slice.indices). ### Are these changes tested? Yes. ### Are there any user-facing changes? Fixing wrong data returned in an edge case. * GitHub Issue: apache#40642 * GitHub Issue: apache#38768 Lead-authored-by: LucasG0 <[email protected]> Co-authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Joris Van den Bossche <[email protected]>
vibhatha
pushed a commit
to vibhatha/arrow
that referenced
this issue
Apr 15, 2024
…start is now empty (apache#40682) ### What changes are included in this PR? `_normalize_slice` now relies on `slice.indices` (https://docs.python.org/3/reference/datamodel.html#slice.indices). ### Are these changes tested? Yes. ### Are there any user-facing changes? Fixing wrong data returned in an edge case. * GitHub Issue: apache#40642 * GitHub Issue: apache#38768 Lead-authored-by: LucasG0 <[email protected]> Co-authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Joris Van den Bossche <[email protected]>
tolleybot
pushed a commit
to tmct/arrow
that referenced
this issue
May 2, 2024
…start is now empty (apache#40682) ### What changes are included in this PR? `_normalize_slice` now relies on `slice.indices` (https://docs.python.org/3/reference/datamodel.html#slice.indices). ### Are these changes tested? Yes. ### Are there any user-facing changes? Fixing wrong data returned in an edge case. * GitHub Issue: apache#40642 * GitHub Issue: apache#38768 Lead-authored-by: LucasG0 <[email protected]> Co-authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Joris Van den Bossche <[email protected]>
vibhatha
pushed a commit
to vibhatha/arrow
that referenced
this issue
May 25, 2024
…start is now empty (apache#40682) ### What changes are included in this PR? `_normalize_slice` now relies on `slice.indices` (https://docs.python.org/3/reference/datamodel.html#slice.indices). ### Are these changes tested? Yes. ### Are there any user-facing changes? Fixing wrong data returned in an edge case. * GitHub Issue: apache#40642 * GitHub Issue: apache#38768 Lead-authored-by: LucasG0 <[email protected]> Co-authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Joris Van den Bossche <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From pandas-dev/pandas#55832
When slicing an array "backwards" (with negative step, -1 in the example), and when the
stop
is "beyond" the start (larger negative number than number of elements), the first item is not included:While if we omit the
stop
(meaning, slice until the end, in this case of backwards slicing until the start), it works correctly:I haven't yet checked if this is an issue in the underlying C++ slicing, or in the Python layer, eg in our "normalize_slice" logic:
arrow/python/pyarrow/array.pxi
Line 544 in 26cf0e0
The text was updated successfully, but these errors were encountered: