posit-dev / great-tables

Make awesome display tables using Python.
https://posit-dev.github.io/great-tables/
MIT License
1.43k stars 48 forks source link

fix: `CellStyleBorders` is not properly constructed when `sides` is set to "all" #326

Closed jrycw closed 1 month ago

jrycw commented 2 months ago

It seems that the following code does not render as expected when sides is set to "all" for style.borders. The main reason might be the omission of other values while constructing a new CellStyleBorders.

import polars as pl
from great_tables import GT, md, html, style, loc
from great_tables.data import islands

islands_mini = (
    pl.from_pandas(islands).sort("size", descending=True)
    .head(10)
)

(
    GT(islands_mini)
    .tab_style(
      style=style.borders(sides=["all"], style="solid", weight="4px", color="red"),
      locations=loc.body(rows=[-1])
    )
)

The table comparison before and after fixing can be found as below:

comparison

codecov-commenter commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 83.43%. Comparing base (5ea06af) to head (368d05a).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #326 +/- ## ======================================= Coverage 83.43% 83.43% ======================================= Files 41 41 Lines 4287 4287 ======================================= Hits 3577 3577 Misses 710 710 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

machow commented 1 month ago

Ah, nice catch, thanks! I added a small lil test, and everything looks good!

machow commented 1 month ago

@rich-iannone do you mind merging? :)

jrycw commented 1 month ago

Ah, nice catch, thanks! I added a small lil test, and everything looks good!

@machow, thanks for adding a test.