predictygraph 0.3.3__tar.gz → 0.3.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {predictygraph-0.3.3 → predictygraph-0.3.5}/PKG-INFO +1 -1
- {predictygraph-0.3.3 → predictygraph-0.3.5}/pyproject.toml +1 -1
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/route.py +41 -3
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/scene.py +1 -1
- {predictygraph-0.3.3 → predictygraph-0.3.5}/tests/test_routing.py +61 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/tests/test_sketch.py +9 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/LICENSE +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/NOTICE +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/README.md +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/__init__.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/__main__.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/anim.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/cli.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/default.css +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/Carlito-Bold.ttf +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/Carlito-Regular.ttf +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/DejaVuSans-Bold.ttf +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/DejaVuSans.ttf +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/LiberationMono-Bold.ttf +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/LiberationMono-Regular.ttf +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/LiberationSans-Bold.ttf +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/LiberationSans-Regular.ttf +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/LiberationSerif-Bold.ttf +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/LiberationSerif-Regular.ttf +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/licenses/Bitstream-Vera.txt +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/licenses/OFL-1.1.txt +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/licenses/README.md +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/ir.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/layout.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/model.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/parser.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/render/__init__.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/render/apng.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/render/svg.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/safe.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/sketch.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/style.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/styleutil.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/text.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/theme.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/themes/catppuccin-frappe.toml +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/themes/catppuccin-latte.toml +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/themes/catppuccin-macchiato.toml +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/themes/catppuccin-mocha.toml +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/themes/default.toml +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/themes/dracula.toml +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/themes/github-light.toml +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/themes/gruvbox-dark.toml +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/themes/hami.toml +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/themes/nord.toml +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/themes/solarized-dark.toml +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/themes/solarized-light.toml +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/themes/trunkline.toml +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/tests/test_annotations.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/tests/test_blocks.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/tests/test_diagonal.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/tests/test_fixes.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/tests/test_hardening.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/tests/test_predictygraph.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/tests/test_scene.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/tests/test_stack.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/tests/test_targets.py +0 -0
- {predictygraph-0.3.3 → predictygraph-0.3.5}/tests/test_trunkline.py +0 -0
|
@@ -133,7 +133,7 @@ def octilinear(p0, p1, axis, mid, stub, diag: Diagonal):
|
|
|
133
133
|
angle = max(angle, math.degrees(math.atan2(abs(cross), room)))
|
|
134
134
|
dlen = abs(cross) / math.tan(math.radians(angle)) # main-axis length the slant uses
|
|
135
135
|
centre = mid if mid is not None else (a0 + a1) / 2
|
|
136
|
-
if abs(cross) <= diag.max and dlen <= room:
|
|
136
|
+
if abs(cross) <= diag.max and dlen <= room + 1e-6: # always: dlen == room up to rounding
|
|
137
137
|
if diag.early:
|
|
138
138
|
s = a0 + sgn * stub
|
|
139
139
|
elif sgn > 0:
|
|
@@ -170,6 +170,7 @@ class Router:
|
|
|
170
170
|
self.offset: dict[str, float] = {}
|
|
171
171
|
self.port_shift: dict[tuple[str, int], float] = {}
|
|
172
172
|
self.bend_level: dict[str, float] = {}
|
|
173
|
+
self.curve_level: dict[str, float] = {}
|
|
173
174
|
self.channel: dict[str, tuple[float, float]] = {}
|
|
174
175
|
self.gapkey: dict[str, tuple[str, int]] = {}
|
|
175
176
|
self.needs: dict[tuple[str, int], float] = {}
|
|
@@ -178,6 +179,7 @@ class Router:
|
|
|
178
179
|
self._parallel_offsets()
|
|
179
180
|
self._spread_ports()
|
|
180
181
|
self._shared_bends()
|
|
182
|
+
self._shared_curves()
|
|
181
183
|
self._separate_channels()
|
|
182
184
|
return self
|
|
183
185
|
|
|
@@ -239,6 +241,37 @@ class Router:
|
|
|
239
241
|
for k, (_, eid, end, _sp) in enumerate(lst):
|
|
240
242
|
self.port_shift[(eid, end)] = (k - (len(lst) - 1) / 2) * step
|
|
241
243
|
|
|
244
|
+
def _shared_curves(self):
|
|
245
|
+
"""Curved fan-out/fan-in on one side of a node: the S-curves would each swing at
|
|
246
|
+
their own midpoint, and targets at different distances make those swings cross
|
|
247
|
+
although the ports are ordered. They all swing at one common level instead."""
|
|
248
|
+
geo = {}
|
|
249
|
+
for e in self.doc.edges:
|
|
250
|
+
if e.style.get("route", "curve") != "curve" or spread(e) or e.waypoints or e.attrs.get("exit") or e.attrs.get("enter"):
|
|
251
|
+
continue
|
|
252
|
+
pts, axis = self.geometry(e)
|
|
253
|
+
if axis in ("v", "h") and len(pts) == 2:
|
|
254
|
+
geo[e.id] = (pts, axis)
|
|
255
|
+
for key in ("src", "dst"):
|
|
256
|
+
buckets: dict[tuple, list] = {}
|
|
257
|
+
for e in self.doc.edges:
|
|
258
|
+
if e.id not in geo or e.id in self.curve_level:
|
|
259
|
+
continue
|
|
260
|
+
pts, axis = geo[e.id]
|
|
261
|
+
i = 1 if axis == "v" else 0
|
|
262
|
+
sign = (pts[1][i] > pts[0][i]) - (pts[1][i] < pts[0][i])
|
|
263
|
+
buckets.setdefault((getattr(e, key), axis, sign), []).append(e)
|
|
264
|
+
for es in buckets.values():
|
|
265
|
+
if len(es) < 2:
|
|
266
|
+
continue
|
|
267
|
+
i = 1 if geo[es[0].id][1] == "v" else 0
|
|
268
|
+
end, other = (0, 1) if key == "src" else (1, 0)
|
|
269
|
+
hub = sum(geo[e.id][0][end][i] for e in es) / len(es)
|
|
270
|
+
nearest = min((geo[e.id][0][other][i] for e in es), key=lambda f: abs(f - hub))
|
|
271
|
+
level = hub + (nearest - hub) / 2
|
|
272
|
+
for e in es:
|
|
273
|
+
self.curve_level[e.id] = level
|
|
274
|
+
|
|
242
275
|
def _shared_bends(self):
|
|
243
276
|
"""Ortho fan-in/fan-out: edges sharing a target (or source) turn at one common
|
|
244
277
|
level, so they merge into a single bus line (class-diagram style)."""
|
|
@@ -506,10 +539,15 @@ class Router:
|
|
|
506
539
|
return rounded(list(pts), 0)
|
|
507
540
|
if route in ("bend", "ortho"):
|
|
508
541
|
return rounded(self.polyline(pts, axis, route, radius, stub, mid, diag), radius)
|
|
509
|
-
# curve: cubic beziers with tangents along the flow axis
|
|
542
|
+
# curve: cubic beziers with tangents along the flow axis; a fan swings at one level
|
|
510
543
|
segs = [("M", *pts[0])]
|
|
511
544
|
for (x0, y0), (x1, y1) in zip(pts, pts[1:]):
|
|
512
|
-
if
|
|
545
|
+
if mid is not None and len(pts) == 2:
|
|
546
|
+
if axis == "v":
|
|
547
|
+
segs.append(("C", x0, mid, x1, mid, x1, y1))
|
|
548
|
+
else:
|
|
549
|
+
segs.append(("C", mid, y0, mid, y1, x1, y1))
|
|
550
|
+
elif axis == "v":
|
|
513
551
|
k = (y1 - y0) / 2
|
|
514
552
|
segs.append(("C", x0, y0 + k, x1, y1 - k, x1, y1))
|
|
515
553
|
else:
|
|
@@ -541,7 +541,7 @@ class SceneBuilder:
|
|
|
541
541
|
stub += hl
|
|
542
542
|
radius = px(st.get("radius"), 12 if route == "bend" else 6)
|
|
543
543
|
diag = Diagonal.from_style(st, route)
|
|
544
|
-
level = R.level(e)
|
|
544
|
+
level = R.curve_level.get(e.id) if route == "curve" else R.level(e)
|
|
545
545
|
segs = R.path_segs(pts, axis, route, radius, stub, level, diag)
|
|
546
546
|
self.edge_polys[e.id] = R.polyline(pts, axis, route, radius, stub, level, diag)
|
|
547
547
|
|
|
@@ -59,3 +59,64 @@ def test_shifted_ports_sit_on_the_circle():
|
|
|
59
59
|
for n, p in ((doc.items[e.src], pts[0]), (doc.items[e.dst], pts[-1])):
|
|
60
60
|
d = ((p[0] - n.cx) / (n.w / 2)) ** 2 + ((p[1] - n.cy) / (n.h / 2)) ** 2
|
|
61
61
|
assert abs(d - 1) < 0.02, f"{e.src}->{e.dst} end is off the outline of {n.id}"
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
FAN = """graph dir=LR
|
|
65
|
+
group site layout=column gap=12 {
|
|
66
|
+
g "GPU servers" shape=box
|
|
67
|
+
}
|
|
68
|
+
api "Sovereign API" shape=box
|
|
69
|
+
group sys layout=column gap=12 {
|
|
70
|
+
idp "Login" shape=box
|
|
71
|
+
bill "Billing and ERP integration" shape=box
|
|
72
|
+
ui "Portal for everyone" shape=box
|
|
73
|
+
}
|
|
74
|
+
api -> idp
|
|
75
|
+
api -> bill
|
|
76
|
+
api -> ui
|
|
77
|
+
g -> api
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _curve_points(segs, n=40):
|
|
82
|
+
pts, cur = [], None
|
|
83
|
+
for s in segs:
|
|
84
|
+
if s[0] == "M":
|
|
85
|
+
cur = s[1:3]
|
|
86
|
+
pts.append(cur)
|
|
87
|
+
elif s[0] == "C":
|
|
88
|
+
(x0, y0), (x1, y1, x2, y2, x3, y3) = cur, s[1:]
|
|
89
|
+
for i in range(1, n + 1):
|
|
90
|
+
t = i / n
|
|
91
|
+
u = 1 - t
|
|
92
|
+
pts.append((u**3 * x0 + 3 * u * u * t * x1 + 3 * u * t * t * x2 + t**3 * x3, u**3 * y0 + 3 * u * u * t * y1 + 3 * u * t * t * y2 + t**3 * y3))
|
|
93
|
+
cur = (x3, y3)
|
|
94
|
+
return pts
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _crosses(a, b):
|
|
98
|
+
def ccw(p, q, r):
|
|
99
|
+
return (r[1] - p[1]) * (q[0] - p[0]) - (q[1] - p[1]) * (r[0] - p[0])
|
|
100
|
+
|
|
101
|
+
for p, q in zip(a, a[1:]):
|
|
102
|
+
for r, s in zip(b, b[1:]):
|
|
103
|
+
if ccw(p, r, s) * ccw(q, r, s) < 0 and ccw(p, q, r) * ccw(p, q, s) < 0:
|
|
104
|
+
return True
|
|
105
|
+
return False
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def test_curved_fan_out_to_targets_at_different_distances_does_not_cross():
|
|
109
|
+
"""Targets of different widths put their ports at different x; each S-curve used to
|
|
110
|
+
swing at its own midpoint, so the fan crossed although the source ports were ordered."""
|
|
111
|
+
doc = _style(parse(FAN), None, None, None)
|
|
112
|
+
layout(doc)
|
|
113
|
+
r = Router(doc).route()
|
|
114
|
+
paths = []
|
|
115
|
+
for e in doc.edges:
|
|
116
|
+
if e.src == "api":
|
|
117
|
+
pts, axis = r.geometry(e)
|
|
118
|
+
paths.append(_curve_points(r.path_segs(pts, axis, "curve", 6, None, r.curve_level.get(e.id), None)))
|
|
119
|
+
assert len(paths) == 3
|
|
120
|
+
for i in range(3):
|
|
121
|
+
for j in range(i + 1, 3):
|
|
122
|
+
assert not _crosses(paths[i], paths[j])
|
|
@@ -83,3 +83,12 @@ def test_label_at_start_has_no_background():
|
|
|
83
83
|
svg = render('graph route=ortho\na\nb\na -> b "x" exit=right enter=top label-at=start')
|
|
84
84
|
edge = svg.split('<g id="e0"', 1)[1].split("</g>", 1)[0]
|
|
85
85
|
assert "pdg-label-bg" not in edge and ">x<" in edge
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def test_diagonal_always_slants_every_jog():
|
|
89
|
+
from predictygraph.route import Diagonal, octilinear
|
|
90
|
+
|
|
91
|
+
diag = Diagonal("auto", 1e9, 45.0)
|
|
92
|
+
for cross in (18.0, 35.0, 78.0):
|
|
93
|
+
pts = octilinear((0.0, 0.0), (cross, 48.0), "v", None, 9.0, diag)
|
|
94
|
+
assert len(pts) == 4 and pts[1][0] != pts[2][0] and pts[1][1] != pts[2][1]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/LiberationMono-Regular.ttf
RENAMED
|
File without changes
|
|
File without changes
|
{predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/LiberationSans-Regular.ttf
RENAMED
|
File without changes
|
{predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/LiberationSerif-Bold.ttf
RENAMED
|
File without changes
|
{predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/LiberationSerif-Regular.ttf
RENAMED
|
File without changes
|
{predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/fonts/licenses/Bitstream-Vera.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{predictygraph-0.3.3 → predictygraph-0.3.5}/src/predictygraph/themes/catppuccin-macchiato.toml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|