Skip to content

Copy width/height calculating logic from kaleido #5325

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ayjayt
Copy link
Contributor

@ayjayt ayjayt commented Aug 13, 2025

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
Copy link
Contributor Author

ayjayt commented Aug 13, 2025

closes plotly/Kaleido#378

@emilykl
Copy link
Contributor

emilykl commented Aug 14, 2025

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.

@ayjayt ayjayt marked this pull request as ready for review August 14, 2025 21:04
@ayjayt ayjayt requested a review from emilykl August 14, 2025 21:04
@@ -314,3 +315,59 @@ def test_get_chrome():

# Verify that kaleido.get_chrome_sync was called
mock_get_chrome.assert_called_once()


def create_figure(width=None, height=None):
Copy link
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
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

Copy link
Contributor

@emilykl emilykl left a comment

Choose a reason for hiding this comment

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

Thanks @ayjayt ! 🚀

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.

2 participants