Skip to content

feat: Add fmt_image_circle() and vals.fmt_image_circle() functions#676

Closed
jrycw wants to merge 1 commit into
posit-dev:mainfrom
jrycw:feat-fmt_image_circle
Closed

feat: Add fmt_image_circle() and vals.fmt_image_circle() functions#676
jrycw wants to merge 1 commit into
posit-dev:mainfrom
jrycw:feat-fmt_image_circle

Conversation

@jrycw
Copy link
Copy Markdown
Collaborator

@jrycw jrycw commented Apr 26, 2025

Hello team,

This PR addresses #354.

Rather than modifying the existing fmt_image() to accommodate border-related parameters, I have renamed the current fmt_image() to _fmt_image(), and introduced new fmt_image() and fmt_image_circle() functions as thin wrappers around it. Keeping _fmt_image() and FmtImage under our control gives us greater flexibility to add more parameters in the future if needed.

Here’s a short demo to illustrate the usage:

import polars as pl
from great_tables import GT, vals, html

posit_avatar = "https://avatars.githubusercontent.com/u/107264312?s=200&v=4"
rich_avatar = "https://avatars.githubusercontent.com/u/5612024?v=4"
michael_avatar = "https://avatars.githubusercontent.com/u/2574498?v=4"

title_img = vals.fmt_image_circle(posit_avatar, height=100, border_color="#D3D3D3")[0]
df = pl.DataFrame({"@rich-iannone": [rich_avatar], "@machow": [michael_avatar]})

(
    GT(df)
    .fmt_image_circle(height=150, border_width=5)
    .tab_header(html(title_img))
    .cols_align("center")
    .opt_stylize(color="green", style=6)
)

image

One thing that seems odd to me is that NotImplementedError doesn’t appear to be raised as expected during execution, yet our tests still pass.

For instance, when running the following code, I would expect it to break, but instead, the print statement after vals.fmt_image() is executed successfully, which feels strange.

import polars as pl
from great_tables import GT

df = pl.DataFrame({"col1": ["https://avatars.githubusercontent.com/u/107264312?s=200&v=4"]})

print(GT(df).fmt_image(width=100)) # Is `NotImplementedError` actually being raised?
print("still running???")

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 26, 2025

Codecov Report

❌ Patch coverage is 97.36842% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.21%. Comparing base (ae0204c) to head (ba5ba7f).
⚠️ Report is 27 commits behind head on main.

Files with missing lines Patch % Lines
great_tables/_formats.py 96.87% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #676      +/-   ##
==========================================
+ Coverage   91.17%   91.21%   +0.03%     
==========================================
  Files          47       47              
  Lines        5462     5495      +33     
==========================================
+ Hits         4980     5012      +32     
- Misses        482      483       +1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rich-iannone
Copy link
Copy Markdown
Member

@jrycw would you be able to resubmit this feature/PR to posit-dev/gt-extras?

@jrycw
Copy link
Copy Markdown
Collaborator Author

jrycw commented Jul 29, 2025

@jrycw would you be able to resubmit this feature/PR to posit-dev/gt-extras?

@rich-iannone, that's a great suggestion. I think we can close this PR now.

Would you be able to port the code over or create an issue there? My laptop has been down for a few days, so I'd appreciate the help.

@rich-iannone
Copy link
Copy Markdown
Member

@jrycw would you be able to resubmit this feature/PR to posit-dev/gt-extras?

@rich-iannone, that's a great suggestion. I think we can close this PR now.

Would you be able to port the code over or create an issue there? My laptop has been down for a few days, so I'd appreciate the help.

I can do that!

@juleswg23
Copy link
Copy Markdown
Contributor

juleswg23 commented Aug 18, 2025

I am closing this PR because posit-dev/gt-extras#164 has been merged.

@juleswg23 juleswg23 closed this Aug 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants