Skip to content

Commit

Permalink
Update flawed logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jrycw committed Sep 12, 2024
1 parent 02ec399 commit c42c1ad
Showing 1 changed file with 46 additions and 21 deletions.
67 changes: 46 additions & 21 deletions great_tables/_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,29 +938,54 @@ def opt_all_caps(

# TODO: Ensure that all values within `locations` are valid

# Set new options for `locations` selected, or, reset to default options
# if `all_caps` is False
res = self
# if `all_caps` is False, reset options to default, or, set new options
# for `locations` selected
if not all_caps:
return tab_options(

Check warning on line 944 in great_tables/_options.py

View check run for this annotation

Codecov / codecov/patch

great_tables/_options.py#L943-L944

Added lines #L943 - L944 were not covered by tests
self,
column_labels_font_size="100%",
column_labels_font_weight="normal",
column_labels_text_transform="inherit",
stub_font_size="100%",
stub_font_weight="initial",
stub_text_transform="inherit",
row_group_font_size="100%",
row_group_font_weight="initial",
row_group_text_transform="inherit",
)

# Predicates for locations
p1 = all_caps and "column_labels" in locations
p2 = all_caps and "stub" in locations
p3 = all_caps and "row_group" in locations

res = tab_options(
res,
column_labels_font_size="80%" if p1 else "100%",
column_labels_font_weight="bolder" if p1 else "normal",
column_labels_text_transform="uppercase" if p1 else "inherit",
stub_font_size="80%" if p2 else "100%",
stub_font_weight="bolder" if p2 else "initial",
stub_text_transform="uppercase" if p2 else "inherit",
row_group_font_size="80%" if p3 else "100%",
row_group_font_weight="bolder" if p3 else "initial",
row_group_text_transform="uppercase" if p3 else "inherit",
)
info = [

Check warning on line 957 in great_tables/_options.py

View check run for this annotation

Codecov / codecov/patch

great_tables/_options.py#L957

Added line #L957 was not covered by tests
(
"column_labels",
{
"column_labels_font_size": "80%",
"column_labels_font_weight": "bolder",
"column_labels_text_transform": "uppercase",
},
),
(
"stub",
{
"stub_font_size": "80%",
"stub_font_weight": "bolder",
"stub_text_transform": "uppercase",
},
),
(
"row_group",
{
"row_group_font_size": "80%",
"row_group_font_weight": "bolder",
"row_group_text_transform": "uppercase",
},
),
]
d = {}
for location, params in info:
if location in locations:
d |= params

Check warning on line 986 in great_tables/_options.py

View check run for this annotation

Codecov / codecov/patch

great_tables/_options.py#L983-L986

Added lines #L983 - L986 were not covered by tests

return res
return tab_options(self, **d)

Check warning on line 988 in great_tables/_options.py

View check run for this annotation

Codecov / codecov/patch

great_tables/_options.py#L988

Added line #L988 was not covered by tests


def opt_table_outline(
Expand Down

0 comments on commit c42c1ad

Please sign in to comment.