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] Scalar.astype is ill-defined #7835

Open
isVoid opened this issue Apr 2, 2021 · 3 comments
Open

[BUG] Scalar.astype is ill-defined #7835

isVoid opened this issue Apr 2, 2021 · 3 comments
Labels
bug Something isn't working Python Affects Python cuDF API.

Comments

@isVoid
Copy link
Contributor

isVoid commented Apr 2, 2021

What is the expected behavior of Scalar.astype?

During implementing #7182, I realized cudf.Scalar.astype's behavior is not well-defined. Since cudf Scalar has a host-side and a device-side, which one astype should operate on and what is the expected behavior? In addition, device side scalar is not really operable since libcudf does not cast scalars types. How to resolve for the discrepancy?

cc @kkraus14 @brandon-b-miller

@isVoid isVoid added question Further information is requested Needs Triage Need team to review and classify labels Apr 2, 2021
@brandon-b-miller
Copy link
Contributor

I think there can be three scenarios when astype is called on a cudf scalar s:

  • s host value is present, and its device value is not. This returns a new python object with a new host value, but still no device value.
  • both the host and device values are present for s. In this case, we cast the host value, and construct a new cudf scalar from the result. The question is should the device value be set. My initial thought is that there's no reason to set it until it's actually needed, and .device_value is accessed.
  • s device value is present, and the host value is not. Here I think we need to move the device value to host, cast it there and construct a new scalar again. The question is again should the device value be set - and I lean towards no for the same reasons as above - it shouldn't harm anything to leave it unsynchronized until it's used.

Most of the time we'll obtain a numpy scalar and we can just use numpy casting to get the new scalar. But we'll need special handling for strings and decimals.

@kkraus14 kkraus14 changed the title [QST] Scalar.astype is ill-defined [BUG] Scalar.astype is ill-defined Apr 6, 2021
@kkraus14 kkraus14 added bug Something isn't working Python Affects Python cuDF API. and removed Needs Triage Need team to review and classify question Further information is requested labels Apr 6, 2021
@github-actions
Copy link

github-actions bot commented May 6, 2021

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

@github-actions
Copy link

github-actions bot commented Feb 7, 2022

This issue has been labeled inactive-90d due to no recent activity in the past 90 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed.

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
Status: Todo
Development

No branches or pull requests

4 participants