Skip to content

Incorrect parsing of floating point values #18

@amcewen

Description

@amcewen

While running the tests for #12 (Yay test code!) the new viewBox support was producing slightly different gcode for the hiking.svg test file.

Digging into it a bit I found that it was because the SVG height and width attributes were being truncated - I was getting a height of 791.716 for example, rather than the full 791.71631 in the SVG file. The viewBox code ended up scaling things a tiny bit, which threw the test code off.

The problem seems to be with the lines like this:
canvas_height = float(height_str) if height_str.isnumeric() else float(height_str[:-2])

Seems that isnumeric() returns False for strings containing decimals, and the code assumes they've got a mm or px, etc. at the end and chops off the last two characters - in the case of hiking.svg that's the last two decimal places of the number.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions