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(python): Include pl. qualifier for inner dtypes in to_init_repr() #16235

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

datenzauberai
Copy link
Contributor

@datenzauberai datenzauberai commented May 15, 2024

Closes #15802

This is a minimal fix for #15802 by adding a method that prefixes representations, which will be called "recursively" for nested types.

@github-actions github-actions bot added fix Bug fix python Related to Python Polars labels May 15, 2024
@datenzauberai
Copy link
Contributor Author

I somehow managed to close the preceding PR #16223 where @stinodego suggested to create a utility function instead of putting this into the DataType classes.

@datenzauberai
Copy link
Contributor Author

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.

Copy link

codecov bot commented May 15, 2024

Codecov Report

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

Project coverage is 80.80%. Comparing base (15f6b36) to head (266ef82).
Report is 18 commits behind head on main.

Files Patch % Lines
py-polars/polars/datatypes/_utils.py 87.09% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16235      +/-   ##
==========================================
- Coverage   80.85%   80.80%   -0.06%     
==========================================
  Files        1394     1394              
  Lines      179955   179407     -548     
  Branches     2909     2927      +18     
==========================================
- Hits       145508   144975     -533     
+ Misses      33942    33927      -15     
  Partials      505      505              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@datenzauberai
Copy link
Contributor Author

datenzauberai commented May 16, 2024

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...

Copy link
Member

@stinodego stinodego left a comment

Choose a reason for hiding this comment

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

Thanks, looks good! A few comments.

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...

This is possible for user defined types, but not for data types returned by Series.dtype. So you don't have to handle it in this function.

py-polars/polars/datatypes/convert.py Outdated Show resolved Hide resolved
py-polars/polars/datatypes/__init__.py Outdated Show resolved Hide resolved
py-polars/polars/datatypes/convert.py Outdated Show resolved Hide resolved
py-polars/tests/unit/interop/test_interop.py Show resolved Hide resolved
@ritchie46
Copy link
Member

Any news on this one @stinodego

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Bug fix python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

to_init_repr() inner dtypes missing pl. qualifier
3 participants