Update app.py
Browse files
app.py
CHANGED
|
@@ -1333,7 +1333,6 @@ def render(d, show_labels_vals, path, mark_vals, mark_dist_vals, subsel, switchs
|
|
| 1333 |
return fig
|
| 1334 |
|
| 1335 |
|
| 1336 |
-
|
| 1337 |
@app.callback(
|
| 1338 |
Output("path_info", "children"),
|
| 1339 |
Input("dim", "value"),
|
|
@@ -1346,8 +1345,10 @@ def path_info(d, path):
|
|
| 1346 |
if not path:
|
| 1347 |
return html.Span("Path: (empty)")
|
| 1348 |
|
|
|
|
| 1349 |
path_str = ", ".join(str(v) for v in path)
|
| 1350 |
|
|
|
|
| 1351 |
label, valid = classify_path(path, d)
|
| 1352 |
color = {
|
| 1353 |
"snake": "green",
|
|
@@ -1360,47 +1361,44 @@ def path_info(d, path):
|
|
| 1360 |
# Dimensions of consecutive edges
|
| 1361 |
dims = []
|
| 1362 |
for i in range(len(path) - 1):
|
| 1363 |
-
|
| 1364 |
-
dims.append(
|
| 1365 |
dims_str = ", ".join(str(x) for x in dims) if dims else "(none)"
|
| 1366 |
|
| 1367 |
-
|
|
|
|
| 1368 |
if label == "not snake":
|
| 1369 |
viol = snake_violations(path, d)
|
| 1370 |
|
| 1371 |
pairs = []
|
| 1372 |
-
|
| 1373 |
-
|
| 1374 |
-
|
| 1375 |
-
|
| 1376 |
-
|
| 1377 |
-
|
| 1378 |
-
|
| 1379 |
-
|
| 1380 |
-
|
| 1381 |
-
|
| 1382 |
-
|
| 1383 |
-
|
|
|
|
|
|
|
| 1384 |
MAX_SHOW = 30
|
| 1385 |
-
shown =
|
| 1386 |
pairs_str = ", ".join(f"({a},{b})" for a, b in shown)
|
| 1387 |
-
if len(
|
| 1388 |
-
pairs_str += f", ... (+{len(
|
| 1389 |
|
| 1390 |
-
|
| 1391 |
-
[
|
| 1392 |
-
html.Span("Violations: ", style={"fontWeight": "bold"}),
|
| 1393 |
-
html.Span(pairs_str if pairs_str else "(none)", style={"fontFamily": "monospace"}),
|
| 1394 |
-
],
|
| 1395 |
-
style={"marginTop": "4px"},
|
| 1396 |
-
)
|
| 1397 |
|
| 1398 |
return html.Div(
|
| 1399 |
[
|
| 1400 |
html.Div(
|
| 1401 |
[
|
| 1402 |
html.Span(f"Path: {path_str} "),
|
| 1403 |
-
html.Span(f"[{
|
| 1404 |
]
|
| 1405 |
),
|
| 1406 |
html.Div(
|
|
@@ -1409,10 +1407,10 @@ def path_info(d, path):
|
|
| 1409 |
html.Span(dims_str, style={"fontFamily": "monospace"}),
|
| 1410 |
]
|
| 1411 |
),
|
| 1412 |
-
extra if extra is not None else html.Span(),
|
| 1413 |
]
|
| 1414 |
)
|
| 1415 |
|
|
|
|
| 1416 |
@app.callback(
|
| 1417 |
Output("path_bits", "children"),
|
| 1418 |
Input("dim", "value"),
|
|
|
|
| 1333 |
return fig
|
| 1334 |
|
| 1335 |
|
|
|
|
| 1336 |
@app.callback(
|
| 1337 |
Output("path_info", "children"),
|
| 1338 |
Input("dim", "value"),
|
|
|
|
| 1345 |
if not path:
|
| 1346 |
return html.Span("Path: (empty)")
|
| 1347 |
|
| 1348 |
+
# Vertex list
|
| 1349 |
path_str = ", ".join(str(v) for v in path)
|
| 1350 |
|
| 1351 |
+
# Classification
|
| 1352 |
label, valid = classify_path(path, d)
|
| 1353 |
color = {
|
| 1354 |
"snake": "green",
|
|
|
|
| 1361 |
# Dimensions of consecutive edges
|
| 1362 |
dims = []
|
| 1363 |
for i in range(len(path) - 1):
|
| 1364 |
+
ed = edge_dimension(path[i], path[i + 1])
|
| 1365 |
+
dims.append(ed if ed is not None else "?")
|
| 1366 |
dims_str = ", ".join(str(x) for x in dims) if dims else "(none)"
|
| 1367 |
|
| 1368 |
+
# If not snake, append violations inside the same bracket label
|
| 1369 |
+
label_text = label
|
| 1370 |
if label == "not snake":
|
| 1371 |
viol = snake_violations(path, d)
|
| 1372 |
|
| 1373 |
pairs = []
|
| 1374 |
+
pairs.extend(viol.get("dup_vertices", []))
|
| 1375 |
+
pairs.extend(viol.get("non_adjacent_steps", []))
|
| 1376 |
+
pairs.extend(viol.get("bad_closing_edge", []))
|
| 1377 |
+
pairs.extend(viol.get("chords", []))
|
| 1378 |
+
|
| 1379 |
+
# De-duplicate exact pairs (keep order)
|
| 1380 |
+
seen = set()
|
| 1381 |
+
uniq = []
|
| 1382 |
+
for a, b in pairs:
|
| 1383 |
+
key = (a, b)
|
| 1384 |
+
if key not in seen:
|
| 1385 |
+
seen.add(key)
|
| 1386 |
+
uniq.append((a, b))
|
| 1387 |
+
|
| 1388 |
MAX_SHOW = 30
|
| 1389 |
+
shown = uniq[:MAX_SHOW]
|
| 1390 |
pairs_str = ", ".join(f"({a},{b})" for a, b in shown)
|
| 1391 |
+
if len(uniq) > MAX_SHOW:
|
| 1392 |
+
pairs_str += f", ... (+{len(uniq) - MAX_SHOW} more)"
|
| 1393 |
|
| 1394 |
+
label_text = f"not snake. violations: {pairs_str if pairs_str else '(none)'}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1395 |
|
| 1396 |
return html.Div(
|
| 1397 |
[
|
| 1398 |
html.Div(
|
| 1399 |
[
|
| 1400 |
html.Span(f"Path: {path_str} "),
|
| 1401 |
+
html.Span(f"[{label_text}]", style={"color": color, "fontWeight": "bold"}),
|
| 1402 |
]
|
| 1403 |
),
|
| 1404 |
html.Div(
|
|
|
|
| 1407 |
html.Span(dims_str, style={"fontFamily": "monospace"}),
|
| 1408 |
]
|
| 1409 |
),
|
|
|
|
| 1410 |
]
|
| 1411 |
)
|
| 1412 |
|
| 1413 |
+
|
| 1414 |
@app.callback(
|
| 1415 |
Output("path_bits", "children"),
|
| 1416 |
Input("dim", "value"),
|