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

Merged
merged 5 commits into from
Jun 6, 2024

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 missing coverage. Please review.

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

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 ⚠️
Additional details and impacted files
@@            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     

☔ 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 Outdated Show resolved Hide resolved
@ritchie46
Copy link
Member

Any news on this one @stinodego

@datenzauberai
Copy link
Contributor Author

Just a friendly ping regarding the open pull request @stinodego

@stinodego
Copy link
Member

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

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.

I updated the Array repr and added a parametric test to make sure we will not diverge with the official repr.

Thanks for the PR!

@stinodego stinodego merged commit 3b67c25 into pola-rs:main Jun 6, 2024
13 of 14 checks passed
@stinodego stinodego changed the title fix(python): Include pl. qualifier for inner dtypes in to_init_repr() fix(python): Include pl. qualifier for inner dtypes in to_init_repr Jun 6, 2024
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