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

Error when using Series.clear on nested Object types #16261

Open
2 tasks done
stinodego opened this issue May 16, 2024 · 1 comment · Fixed by #16959
Open
2 tasks done

Error when using Series.clear on nested Object types #16261

stinodego opened this issue May 16, 2024 · 1 comment · Fixed by #16959
Labels
A-ops Area: operations accepted Ready for implementation bug Something isn't working P-low Priority: low python Related to Python Polars

Comments

@stinodego
Copy link
Member

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

import polars as pl

s = pl.Series([[object()]], dtype=pl.List(pl.Object()))
s.clear()

Log output

thread '<unnamed>' panicked at /home/stijn/code/polars/crates/polars-core/src/named_from.rs:162:86:
called `Result::unwrap()` on an `Err` value: InvalidOperation(ErrString("`list_builder` operation not supported for dtype `object`"))
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
  File "/home/stijn/code/polars/py-polars/repro.py", line 11, in <module>
    s = pl.Series([[object()]], dtype=pl.List(pl.Object()))
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/stijn/code/polars/py-polars/polars/series/series.py", line 314, in __init__
    self._s = sequence_to_pyseries(
              ^^^^^^^^^^^^^^^^^^^^^
  File "/home/stijn/code/polars/py-polars/polars/_utils/construction/series.py", line 277, in sequence_to_pyseries
    pyseries = PySeries.new_series_list(name, pyseries_list, strict)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: InvalidOperation(ErrString("`list_builder` operation not supported for dtype `object`"))

Issue description

Offending code is here:

pub fn clear(&self) -> Series {
if self.is_empty() {
self.clone()
} else {
match self.dtype() {
#[cfg(feature = "object")]
DataType::Object(_, _) => self
.take(&ChunkedArray::<IdxType>::new_vec("", vec![]))
.unwrap(),
dt => Series::new_empty(self.name(), dt),
}
}
}

Clearly this doesn't account for nested object types.

Expected behavior

Return an empty Series.

Installed versions

main

@stinodego stinodego added bug Something isn't working python Related to Python Polars needs triage Awaiting prioritization by a maintainer P-low Priority: low labels May 16, 2024
@github-project-automation github-project-automation bot moved this to Ready in Backlog May 16, 2024
@stinodego stinodego added A-ops Area: operations A-panic Area: code that results in panic exceptions and removed needs triage Awaiting prioritization by a maintainer labels May 16, 2024
@stinodego stinodego moved this from Ready to Candidate in Backlog Jun 9, 2024
@github-project-automation github-project-automation bot moved this from Candidate to Done in Backlog Jun 14, 2024
@stinodego stinodego removed the A-panic Area: code that results in panic exceptions label Jun 16, 2024
@stinodego
Copy link
Member Author

stinodego commented Jun 16, 2024

@ritchie46 Thanks for the fixing the panic - but the issue has not been fixed yet! This should not error either.

We should be careful not to close panic issues when the underlying issue persists.

@stinodego stinodego reopened this Jun 16, 2024
@github-project-automation github-project-automation bot moved this from Done to Ready in Backlog Jun 16, 2024
@stinodego stinodego changed the title Panic when using Series.clear on nested Object types Error when using Series.clear on nested Object types Jun 16, 2024
@c-peters c-peters added the accepted Ready for implementation label Jun 16, 2024
@c-peters c-peters moved this from Ready to Done in Backlog Jun 16, 2024
@stinodego stinodego moved this from Done to Ready in Backlog Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ops Area: operations accepted Ready for implementation bug Something isn't working P-low Priority: low python Related to Python Polars
Projects
Status: Ready
Development

Successfully merging a pull request may close this issue.

3 participants