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

[BUG] Missing data with length-one sliced-based __setitem__ and singleton array #12073

Closed
wence- opened this issue Nov 4, 2022 · 0 comments · Fixed by #12075
Closed

[BUG] Missing data with length-one sliced-based __setitem__ and singleton array #12073

wence- opened this issue Nov 4, 2022 · 0 comments · Fixed by #12075
Assignees
Labels
bug Something isn't working Python Affects Python cuDF API.

Comments

@wence-
Copy link
Contributor

wence- commented Nov 4, 2022

Describe the bug

Trying to set a length-one slice of a series with a length-one array (rather than a scalar) loses the value.

Steps/Code to reproduce bug

import cudf
import cupy
s = cudf.Series([1, 2, 3], dtype=cupy.int64)
s.iloc[:1] = cupy.asarray([7], dtype=cupy.int64)
print(s)
# 0    1 <------ expecting this to be 7
# 1    2
# 2    3
# dtype: int64

Expected behavior

Setting a length-one range with a length-one array should work.

Why does this happen?

There's an off-by-one in copying.copy_range:

    if abs(target_end - target_begin) <= 1: # should be `<`.
        return target_column
@wence- wence- added bug Something isn't working Needs Triage Need team to review and classify Python Affects Python cuDF API. labels Nov 4, 2022
@wence- wence- self-assigned this Nov 4, 2022
wence- added a commit to wence-/cudf that referenced this issue Nov 4, 2022
Only when copying a zero-length range can we afford to return the
target column. Closes rapidsai#12073.
@galipremsagar galipremsagar removed the Needs Triage Need team to review and classify label Nov 4, 2022
rapids-bot bot pushed a commit that referenced this issue Nov 14, 2022
When trying to set a length-one range with a length-one array, an off-by-one error in `copying.copy_range` meant that the value was discarded. Fix that, and tidy up the semantics of `copy_range` a little while we're here. Closes #12073.

Authors:
  - Lawrence Mitchell (https://github.com/wence-)

Approvers:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

URL: #12075
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants