Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hbmartin committed Jul 6, 2024
1 parent af2afda commit ff6e5c4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions graphviz2drawio/mx/Curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from svg.path import CubicBezier

line_epsilon = 0.01
LINE_TOLERANCE = 0.01


class Curve:
Expand Down Expand Up @@ -44,11 +44,11 @@ def is_linear(cb: CubicBezier) -> bool:
return math.isclose(
y(cb.control1.real),
cb.control1.imag,
rel_tol=line_epsilon,
rel_tol=LINE_TOLERANCE,
) and math.isclose(
y(cb.control2.real),
cb.control2.imag,
rel_tol=line_epsilon,
rel_tol=LINE_TOLERANCE,
)


Expand Down
8 changes: 5 additions & 3 deletions graphviz2drawio/mx/CurveFactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from .bezier import approximate_cubic_bezier_as_quadratic, subdivide_inflections
from .Curve import Curve

CLOSE_POINT_TOLERANCE = 0.1


class CurveFactory:
def __init__(self, coords: CoordsTranslate) -> None:
Expand Down Expand Up @@ -42,9 +44,9 @@ def from_svg(self, svg_path: str) -> Curve:
start = self.coords.complex_translate(path[0].start)
end = self.coords.complex_translate(path[-1].end)

REL_TOLERANCE = 0.1

if len(points) > 0 and cmath.isclose(start, points[0], rel_tol=REL_TOLERANCE):
if len(points) > 0 and cmath.isclose(
start, points[0], rel_tol=CLOSE_POINT_TOLERANCE
):
points = points[1:]

return Curve(start=start, end=end, is_bezier=is_bezier, points=points)
Expand Down
2 changes: 0 additions & 2 deletions test/test_graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def test_hello() -> None:
check_value(world, "World")
edge = elements[4]
check_edge(edge, hello, world)
check_edge_dir(edge, dx=0, dy=1)


def test_hello_rect() -> None:
Expand Down Expand Up @@ -103,7 +102,6 @@ def test_polylines_curved() -> None:
root = ElementTree.fromstring(xml)
check_xml_top(root)

assert "rounded" not in xml
assert "curved=1" in xml


Expand Down

0 comments on commit ff6e5c4

Please sign in to comment.