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

Fix strings strip() to accept only str Scalar for to_strip parameter #10597

Merged
merged 2 commits into from
Apr 6, 2022

Conversation

davidwendt
Copy link
Contributor

Closes #10591

Ensures to_strip parameter is a str type when converting it to cudf.Scalar. It will now through a TypeError as follows

    libstrings.strip(self._column, cudf.Scalar(to_strip, "str"))
  File "/conda/envs/rapids/lib/python3.8/site-packages/cudf-22.6.0a0+96.g0aef0c1c3e.dirty-py3.8-linux-x86_64.egg/cudf/core/scalar.py", line 78, in __init__
    self._host_value, self._host_dtype = self._preprocess_host_value(
  File "/conda/envs/rapids/lib/python3.8/site-packages/cudf-22.6.0a0+96.g0aef0c1c3e.dirty-py3.8-linux-x86_64.egg/cudf/core/scalar.py", line 128, in _preprocess_host_value
    raise TypeError("Lists may not be cast to a different dtype")
TypeError: Lists may not be cast to a different dtype

This will also prevent the sticky CUDA error.

Also, added the str parameter to other cudf.Scalar calls where only strings are supported as well.

@davidwendt davidwendt added bug Something isn't working 3 - Ready for Review Ready for review by team Python Affects Python cuDF API. non-breaking Non-breaking change labels Apr 5, 2022
@davidwendt davidwendt self-assigned this Apr 5, 2022
@davidwendt davidwendt requested a review from a team as a code owner April 5, 2022 15:57
Copy link
Member

@charlesbluca charlesbluca left a comment

Choose a reason for hiding this comment

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

Should we add test(s) for passing the incorrect input type for some of these methods?

@davidwendt
Copy link
Contributor Author

Should we add test(s) for passing the incorrect input type for some of these methods?

Yes. I think that is a good idea.

@codecov
Copy link

codecov bot commented Apr 5, 2022

Codecov Report

Merging #10597 (2479078) into branch-22.06 (0aef0c1) will increase coverage by 0.02%.
The diff coverage is n/a.

@@               Coverage Diff                @@
##           branch-22.06   #10597      +/-   ##
================================================
+ Coverage         86.29%   86.31%   +0.02%     
================================================
  Files               140      140              
  Lines             22255    22255              
================================================
+ Hits              19205    19210       +5     
+ Misses             3050     3045       -5     
Impacted Files Coverage Δ
python/cudf/cudf/core/column/string.py 89.10% <ø> (+0.12%) ⬆️
python/cudf/cudf/datasets.py 97.56% <0.00%> (ø)
python/cudf/cudf/utils/cudautils.py 59.83% <0.00%> (ø)
python/cudf/cudf/core/udf/templates.py 100.00% <0.00%> (ø)
python/custreamz/custreamz/_version.py 0.00% <0.00%> (ø)
python/dask_cudf/dask_cudf/_version.py 0.00% <0.00%> (ø)
python/cudf/cudf/core/udf/row_function.py 100.00% <0.00%> (ø)
python/cudf/cudf/core/udf/scalar_function.py 100.00% <0.00%> (ø)
python/cudf/cudf/core/groupby/groupby.py 91.72% <0.00%> (+0.22%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0aef0c1...2479078. Read the comment docs.

@davidwendt davidwendt requested a review from charlesbluca April 5, 2022 19:45
@galipremsagar galipremsagar added 5 - Ready to Merge Testing and reviews complete, ready to merge and removed 3 - Ready for Review Ready for review by team labels Apr 6, 2022
@galipremsagar
Copy link
Contributor

@gpucibot merge

@rapids-bot rapids-bot bot merged commit 956c7b5 into rapidsai:branch-22.06 Apr 6, 2022
@davidwendt davidwendt deleted the bug-strings-strip branch April 6, 2022 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Ready to Merge Testing and reviews complete, ready to merge bug Something isn't working non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Passing a list to StringMethods.strip puts cuDF into a broken state
4 participants