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

Replace _is_categorical_dtype with isinstance #14942

Closed

Conversation

mroeschke
Copy link
Contributor

Description

This is more explicit than _is_categorical_dtype which may allow array objects when we don't want to

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@mroeschke mroeschke added Python Affects Python cuDF API. improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jan 31, 2024
@mroeschke mroeschke requested review from a team as code owners January 31, 2024 22:34
@mroeschke mroeschke requested review from wence- and isVoid January 31, 2024 22:34
Comment on lines +970 to +971
dtype = cudf.dtype(dtype)
if isinstance(dtype, cudf.CategoricalDtype):
Copy link
Contributor

Choose a reason for hiding this comment

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

I think replacing _is_categorical_dtype calls else where with isinstance checks is the right thing but places like these where users can pass .astype('category'), we will need _is_categroical_dtype because doing a cudf.dtype('category') will lead to different behaviors:

In [1]: import cudf

In [2]: cudf.dtype("category")
Out[2]: CategoricalDtype(categories=None, ordered=None, categories_dtype=None)

@mroeschke
Copy link
Contributor Author

Going to reopen this one with different changes so closing

@mroeschke mroeschke closed this Feb 26, 2024
@mroeschke mroeschke deleted the cln/_is_categorical_dtype branch February 26, 2024 23:21
@mroeschke mroeschke mentioned this pull request Feb 26, 2024
3 tasks
rapids-bot bot pushed a commit that referenced this pull request Apr 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement / enhancement to an existing function non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants