pola-rs / polars

Dataframes powered by a multithreaded, vectorized query engine, written in Rust
https://docs.pola.rs
Other
27.23k stars 1.67k forks source link

fix(python): Include `pl.` qualifier for inner dtypes in `to_init_repr` #16235

Closed datenzauberai closed 1 week ago

datenzauberai commented 1 month ago

Closes #15802

This is a minimal fix for https://github.com/pola-rs/polars/issues/15802 by adding a method that prefixes representations, which will be called "recursively" for nested types.

datenzauberai commented 1 month ago

I somehow managed to close the preceding PR https://github.com/pola-rs/polars/pull/16223 where @stinodego suggested to create a utility function instead of putting this into the DataType classes.

datenzauberai commented 1 month ago

It would be an option to include an optional prefix parameter for DataFrame.to_init_repr and Series.to_init_repr, but I don't think this flexibility is really needed.

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 87.50000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 80.80%. Comparing base (a7f9c8d) to head (266ef82). Report is 1 commits behind head on main.

:exclamation: Current head 266ef82 differs from pull request most recent head 316f772

Please upload reports for the commit 316f772 to get more accurate results.

Files Patch % Lines
py-polars/polars/datatypes/_utils.py 87.09% 2 Missing and 2 partials :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #16235 +/- ## ========================================== - Coverage 81.32% 80.80% -0.52% ========================================== Files 1423 1394 -29 Lines 187177 179407 -7770 Branches 2721 2927 +206 ========================================== - Hits 152214 144975 -7239 + Misses 34468 33927 -541 - Partials 495 505 +10 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

datenzauberai commented 1 month ago

Noted one extra thing: Is it really possible with the current version to have a pl.List/pl.Array without a properly defined inner dtype (I think that was possible in the past)? In the constructor both call py_type_to_dtype which would raise an Exception. Would simplify things a little bit...

ritchie46 commented 3 weeks ago

Any news on this one @stinodego

datenzauberai commented 1 week ago

Just a friendly ping regarding the open pull request @stinodego

stinodego commented 1 week ago

It looks good, but the Array repr has been updated. I'll send an update and this can be merged.