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: Throw informative error for 0-width Array #18929

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/polars-core/src/series/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ impl Series {
pub fn cast_with_options(&self, dtype: &DataType, options: CastOptions) -> PolarsResult<Self> {
use DataType as D;

#[cfg(feature = "dtype-array")]
if matches!(dtype, D::Array(_, width) if *width == 0) {
Copy link
Member

@ritchie46 ritchie46 Sep 26, 2024

Choose a reason for hiding this comment

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

Can we fail a bit lower? Maybe in the array cast kernel?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I started looking yesterday at just implementing zero-width arrays. It is almost done so this PR is not really needed anymore.

Copy link
Member

Choose a reason for hiding this comment

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

Alright. Even better. :P

polars_bail!(InvalidOperation: "Arrays with 0 width are not yet supported");
}

let do_clone = match dtype {
D::Unknown(UnknownKind::Any) => true,
D::Unknown(UnknownKind::Int(_)) if self.dtype().is_integer() => true,
Expand Down
Loading