Skip to content

Copy width/height calculating logic from kaleido - #5325

Merged
emilykl merged 10 commits into
plotly:mainfrom
geopozo:andrew/better-kaleido-defaults
Aug 19, 2025
Merged

Copy width/height calculating logic from kaleido#5325
emilykl merged 10 commits into
plotly:mainfrom
geopozo:andrew/better-kaleido-defaults

Conversation

@ayjayt

@ayjaytayjayt commented Aug 13, 2025

Copy link
Copy Markdown
Contributor

Code PR

  • I have read through the contributing notes and understand the structure of the package. In particular, if my PR modifies code of plotly.graph_objects, my modifications concern the code generator and not the generated files.
  • I have added tests or modified existing tests.
  • For a new feature, I have added documentation examples (please see the doc checklist as well).
  • I have added a CHANGELOG entry if changing anything substantial.
  • For a new feature or a change in behavior, I have updated the relevant docstrings in the code.

plotly/Kaleido#378

@ayjayt

ayjayt commented Aug 13, 2025

Copy link
Copy Markdown
ContributorAuthor

closes plotly/Kaleido#378

Comment threadplotly/io/_kaleido.py Outdated
Comment threadplotly/io/_kaleido.py Outdated
@emilykl

Copy link
Copy Markdown
Contributor

Looks good @ayjayt ! Just run ruff format on plotly/io/_kaleido.py so the CI will pass.

Let's add a test for this one. I'm happy to do that if you don't have the bandwidth, just let me know.

ayjaytand others added 6 commits August 14, 2025 15:00
Co-authored-by: Emily KL <4672118+emilykl@users.noreply.github.com>
Co-authored-by: Emily KL <4672118+emilykl@users.noreply.github.com>
@ayjayt
ayjayt marked this pull request as ready for review August 14, 2025 21:04
@ayjayt
ayjayt requested a review from emilyklAugust 14, 2025 21:04
mock_get_chrome.assert_called_once()


def create_figure(width=None, height=None):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: could you move these two utility functions to the top of the file so they're not mixed in with the test functions?

fig = create_figure()
svg_bytes = pio.to_image(fig, format="svg")
width, height = parse_svg_dimensions(svg_bytes)
assert width is not None and height is not None, (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You should be able to import pio.defaults here and check that the dimensions equal the defaults

@emilyklemilykl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @ayjayt ! 🚀

@ayjayt
ayjayt requested a review from emilyklAugust 18, 2025 20:28
@emilykl

Copy link
Copy Markdown
Contributor

@ayjayt Looks good to me -- may I merge?

@emilykl
emilykl merged commit 7639653 into plotly:mainAug 19, 2025
8 checks passed
@ayjayt
ayjayt deleted the andrew/better-kaleido-defaults branch August 19, 2025 18:33
Sign up for freeto 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.

2 participants

@ayjayt@emilykl