Format floating point numbers in output d-paths #225
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.
Format the floating point numbers output by
Path.d
to avoid a bunch of .x0000000000001 and .x999999999999 noise. Fixes #223.Changed behavior:
Numbers with small errors introduced by their floating point representation are output correctly. ex
12.870000000000001
->12.87
,64.13999999999999
->64.14
Whole numbers which were emitted with a trailing 0 now have no trailing 0. ex:
2.0
->2
. This required some changes in the existing test cases. The output now more closely matches the way numbers are represented in the SVG spec examples. It's easiest to see this in the changes totest.test_generation.TestGeneration.test_path_parsing
.Some small floating point numbers now emit fewer significant digits. ex:
206.07112
->206.071
intest.test_groups.TestGroups.test_add_group
. This is chosen by python's idea of which representation is the 'best' as explained hereThis change also removes the need for special python2/3 casing in
test.test_generation.TestGeneration.test_path_parsing
since the behavior ofg
is the same in both. It may be possible to further simplify this test.