Fix matplot pt-unit stripping inflating whole-number dims 100x (#1654) - #1655
Fix matplot pt-unit stripping inflating whole-number dims 100x (#1654)#1655Maya-Mohamed wants to merge 9 commits into
Conversation
|
🧙 Sourcery has finished reviewing your pull request! Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Since the regex already captures the numeric part (
([0-9\.]* )pt), you could simplify the height/width handling by always usinggroup(1)and removing thereplace("pt", "")calls entirely to avoid dual code paths.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Since the regex already captures the numeric part (`([0-9\.]* )pt`), you could simplify the height/width handling by always using `group(1)` and removing the `replace("pt", "")` calls entirely to avoid dual code paths.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Quick note on testing: the I'm happy to add a small regression test if useful. My plan would be a
It'd be guarded with Would you like this in this PR, or would you prefer to keep the change |
Manik-Khajuria-5
left a comment
There was a problem hiding this comment.
@rajnisht7 @Jayantparashar10 @tonypzy @vedansh-5 Please review this PR
|
Thanks for the review @Saksham-Sirohi! Addressed both points:
|
Manik-Khajuria-5
left a comment
There was a problem hiding this comment.
@Maya-Mohamed Please resolve the conflicts
Done. |
Manik-Khajuria-5
left a comment
There was a problem hiding this comment.
@Maya-Mohamed Code changes LGTM! But please go through below mentioned test and see whether it is compatible with current codebase or some changes in requirement.txt is required
|
|
||
|
|
||
| @unittest.skipUnless(visdom.BS4_AVAILABLE, "requires bs4/lxml") | ||
| class TestMatplotResizable(unittest.TestCase): |
There was a problem hiding this comment.
@Maya-Mohamed Please make it compatible with pytest .
… tests run under pytest (fossasia#1655)
|
@Manik-Khajuria-5 Added beautifulsoup4 and lxml to test-requirements.txt. CI installs from |
Manik-Khajuria-5
left a comment
There was a problem hiding this comment.
@Maya-Mohamed Thanks for the fix and for confirming it locally! Since we're integrating pytest, I'd lean towards using @pytest.mark.skipif
thanks for the review! I made the switch to @pytest.mark.skipif. |
Description
Fixes the
pt-unit stripping logic inmatplot()whenresizable=True.The cleanup line used
.replace("pt", "00"), which substitutes the literalptfor00instead of removing it. For whole-number SVG dimensions like"300pt"this produced"30000"— a silent 100x oversized pane. Decimalvalues like
"345.6pt"only worked by coincidence ("345.600"). Changedboth the height and width lines to
.replace("pt", "")so the unit isstripped correctly regardless of decimals.
Motivation and Context
Fixes #1654. Panes rendered ~100x too large with no error or warning
whenever a matplotlib plot's SVG dimensions came out as whole points.
How Has This Been Tested?
height="300pt" width="400pt": before the fixmatplot(..., opts={"resizable": True})computed
height=42000.0, width=54000.0; after the fix it computes thecorrect
height=420.0, width=540.0(1.4300, 1.35400)."345.6pt"still correct).python -m unittest py.tests.test_plots -v— all 42 tests pass.
black py— no formatting changes.Types of changes
Checklist:
py/visdom/VERSIONaccording to Semantic VersioningSummary by Sourcery
Fix incorrect handling of matplotlib SVG pt units in matplot() resizable plots to prevent 100x oversized panes and bump the visdom package version accordingly.
Bug Fixes:
Chores: