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(rust): Allow casting integer types to Enum #13955

Merged
merged 2 commits into from
Jan 26, 2024

Conversation

c-peters
Copy link
Collaborator

fix #13409

@github-actions github-actions bot added fix Bug fix rust Related to Rust Polars labels Jan 24, 2024
unsafe { &*(self as *const ChunkedArray<T> as *const UInt32Chunked) }
.clone()
},
DataType::Int8
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this only be allowed for Enum?

Do we need to bound check or can underlying categories be OOB? Not sure without looking it up.

Copy link
Collaborator Author

@c-peters c-peters Jan 24, 2024

Choose a reason for hiding this comment

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

Yes, for other categoricals it does not really make sense. We do the bounds check for enums and globals

The from_global_indices seems to me like a hack, we should always have the rev_map when casting from UInt32 to Categorical and check for it.

@ritchie46 ritchie46 merged commit 37ca0af into pola-rs:main Jan 26, 2024
22 checks passed
@c-peters c-peters deleted the enum_casting branch January 31, 2024 09:58
@neeldugar neeldugar mentioned this pull request Apr 18, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow casting integer types to Enum
2 participants