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: DataFrame plot was raising when some extra keywords were passed to encodings (e.g. x=alt.X(a, axis=alt.Axis(labelAngle=30))) #18836

Merged
merged 2 commits into from
Sep 23, 2024

Conversation

MarcoGorelli
Copy link
Collaborator

@MarcoGorelli MarcoGorelli commented Sep 20, 2024

closes #18830

cc @dangotbanned in case you have time/interest to take a look

Summary: the solution used in #18625 breaks if some extra options (e.g. sort, axis) are specified to the encode arguments. What I'm proposing is to extract 'shorthand' in such cases, so that the tooltips can keep being shown by default

@github-actions github-actions bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Sep 20, 2024
…to encodings (e.g. `x=alt.X(a, axis=alt.Axis(labelAngle=30))`)
Copy link

codecov bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.86%. Comparing base (2b4986a) to head (e8b5ffd).
Report is 16 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #18836   +/-   ##
=======================================
  Coverage   79.86%   79.86%           
=======================================
  Files        1518     1518           
  Lines      205610   205641   +31     
  Branches     2893     2894    +1     
=======================================
+ Hits       164202   164236   +34     
+ Misses      40860    40857    -3     
  Partials      548      548           

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



def _maybe_extract_shorthand(encoding: Encoding) -> Encoding:
if isinstance(encoding, alt.SchemaBase) and hasattr(encoding, "shorthand"):
Copy link
Contributor

Choose a reason for hiding this comment

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

Will try to look at this properly tomorrow @MarcoGorelli

This could be a source of false positives, you may be safer using inspect.getattr_static
https://docs.python.org/3/library/inspect.html#fetching-attributes-statically

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

thanks @dangotbanned !

the value does need returning, so maybe just using getattr directly is fine?

@ritchie46
Copy link
Member

Alright, I will already merge to include in todays release. Can be improved upon later ofcourse!

@ritchie46 ritchie46 merged commit 262f7bc into pola-rs:main Sep 23, 2024
14 checks passed
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 rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: plotting breaks when axis is passed to alt.X
3 participants