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

GH-40642: [Python] Empty slicing an array backwards beyond the start is now empty #40682

Merged

Conversation

LucasG0
Copy link
Contributor

@LucasG0 LucasG0 commented Mar 20, 2024

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.

Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Comment on lines 581 to 598
if step != 1:
indices = np.arange(start, stop, step)
return arrow_obj.take(indices)
else:
length = max(stop - start, 0)
return arrow_obj.slice(start, length)
Copy link
Member

Choose a reason for hiding this comment

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

We do want to keep this part, using a slice when possible, because the slice method is always zero-copy, while the take method returns new data

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I added it back

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting review Awaiting review labels Mar 20, 2024
@LucasG0 LucasG0 force-pushed the fix_empty_slicing_array_backwards branch from 10d63ac to 37d4411 Compare March 25, 2024 00:03
@github-actions github-actions bot added Component: C++ awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Mar 25, 2024
@LucasG0 LucasG0 force-pushed the fix_empty_slicing_array_backwards branch from 37d4411 to b9df1e6 Compare March 25, 2024 00:04
Copy link
Member

@jorisvandenbossche jorisvandenbossche left a comment

Choose a reason for hiding this comment

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

Thanks for the update, looks good!

Merged in the main branch in the hope this fixes the CI

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting change review Awaiting change review labels Apr 9, 2024
@jorisvandenbossche jorisvandenbossche merged commit 75a100a into apache:main Apr 9, 2024
12 checks passed
@jorisvandenbossche jorisvandenbossche removed the awaiting merge Awaiting merge label Apr 9, 2024
@jorisvandenbossche jorisvandenbossche changed the title GH-38768: [Python] Empty slicing an array backwards beyond the start is now empty GH-40642: [Python] Empty slicing an array backwards beyond the start is now empty Apr 9, 2024
Copy link

github-actions bot commented Apr 9, 2024

⚠️ GitHub issue #40642 has been automatically assigned in GitHub to PR creator.

@jorisvandenbossche
Copy link
Member

Thanks @LucasG0 !

Copy link

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit 75a100a.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details.

raulcd pushed a commit that referenced this pull request 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 <guillermou.lucas@gmail.com>
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
verma-kartik pushed a commit to verma-kartik/arrow that referenced this pull request 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 <guillermou.lucas@gmail.com>
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
vibhatha pushed a commit to vibhatha/arrow that referenced this pull request 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 <guillermou.lucas@gmail.com>
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
tolleybot pushed a commit to tmct/arrow that referenced this pull request 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 <guillermou.lucas@gmail.com>
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
vibhatha pushed a commit to vibhatha/arrow that referenced this pull request 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 <guillermou.lucas@gmail.com>
Co-authored-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants