Fix raster images added twice to SVG output#97
Closed
leofernandezg wants to merge 1 commit intocdelker:masterfrom
Closed
Fix raster images added twice to SVG output#97leofernandezg wants to merge 1 commit intocdelker:masterfrom
leofernandezg wants to merge 1 commit intocdelker:masterfrom
Conversation
The image() method in the SVG backend appended raster image elements to svgelements twice: once before setting attributes (line 599) and again at the shared exit point (line 608). SVG images were only appended once, at the shared exit point, which was correct. Remove the early append so raster images are added once, after all attributes are set. Added test/test_raster_image.py to verify. Fixes cdelker#92
Author
Test suite resultsFull test suite (
The 38 pre-existing failures are in |
Author
|
Update: Re-ran the full test suite with all optional dependencies installed (matplotlib, ziamath, pyparsing).
No regressions introduced. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
svgelements.append()call for raster images in the SVG backendProblem
In
schemdraw/backends/svg.py, theimage()method appends raster image elements toself.svgelementstwice:elsebranch (raster images only)SVG images are only appended at line 608 (correct). Raster images get appended at both lines, resulting in every raster image appearing twice in the final SVG.
Changes
schemdraw/backends/svg.py: Remove the earlyself.svgelements.append()at line 599, keeping only the shared one at line 608test/test_raster_image.py: New test verifying raster images appear exactly onceTest results
Without fix:
Expected 1 image element, got 2With fix:
1 passedFixes #92