-
Notifications
You must be signed in to change notification settings - Fork 71
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
docs: add an example demonstrating define_units()
usage
#446
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #446 +/- ##
=======================================
Coverage 86.75% 86.75%
=======================================
Files 42 42
Lines 4702 4702
=======================================
Hits 4079 4079
Misses 623 623 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@machow this looks great to me. Please merge whenever convenient! |
define_units()
usagedefine_units()
usage
@rich-iannone afaict parsing the curly braces in inputs like It seems like define_units() handling of curly braces may be a bug (and inconsistent)?: from great_tables import define_units
# removes curly braces ----
define_units("{{a_1}}").to_html()
# > 'a<span style="white-space:nowrap;"><sub style="line-height:0;">1</sub></span>'
# Notice that the second piece in curly braces (b_2) still has the braces around it ----
define_units("{{a_1}} {{b_2}}").to_html()
# > 'a<span style="white-space:nowrap;"><sub style="line-height:0;">1}}</sub></span> {{b<span style="white-space:nowrap;"><sub style="line-height:0;">2</sub></span>' What is the intended behavior of define_units? It seems like it should not parse braces, since that's afaict
Does this sounds right, and this behavior of |
Thanks for pointing this out! I originally thought it was a cool feature and didn’t notice that. |
I definitely think there is a cool feature tucked away in But I wonder if we skipped an important piece when initially wiring up units. Based on this PR, it seems like exposing a function similar to Maybe something like this?:
This would provide a bridge into other structure things:
Could be nicer ways to handle though?! (Related to #439) |
Hello team,
As we know,
define_units()
powersGT.fmt_units()
behind the scenes, but it seems to lack a clear example for users to quickly grasp its usage.I’d like to propose an example that demonstrates how to use
define_units()
to render a string with unit annotations as a subtitle in the table header. This example highlights thatdefine_units()
can be used independently and within components that don’t yet support unit annotations (such as the table header).Below is the final table for reference.