Update app.py
Browse files
app.py
CHANGED
|
@@ -356,6 +356,22 @@ def longest_cib(d: int):
|
|
| 356 |
seq.append(g)
|
| 357 |
return seq
|
| 358 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 359 |
|
| 360 |
def shorter_cib(d: int):
|
| 361 |
"""
|
|
@@ -748,6 +764,8 @@ app.layout = html.Div(
|
|
| 748 |
html.Button("Set path", id="btn_set", n_clicks=0),
|
| 749 |
html.Button("Longest CIB", id="btn_longest_cib", n_clicks=0,
|
| 750 |
style={"background": "#059669", "color": "white"}),
|
|
|
|
|
|
|
| 751 |
html.Button("Shorter CIB", id="btn_shorter_cib", n_clicks=0,
|
| 752 |
style={"background": "#00C04B", "color": "white"}),
|
| 753 |
html.Button("Clear", id="btn_clear", n_clicks=0),
|
|
@@ -850,6 +868,7 @@ def stats(d, path):
|
|
| 850 |
Input("fig", "clickData"),
|
| 851 |
Input("btn_clear", "n_clicks"),
|
| 852 |
Input("btn_longest_cib", "n_clicks"),
|
|
|
|
| 853 |
Input("btn_shorter_cib", "n_clicks"),
|
| 854 |
Input("btn_set", "n_clicks"),
|
| 855 |
Input("btn_swap", "n_clicks"),
|
|
@@ -868,6 +887,7 @@ def stats(d, path):
|
|
| 868 |
def update_path(clickData,
|
| 869 |
n_clear,
|
| 870 |
n_longest,
|
|
|
|
| 871 |
n_shorter,
|
| 872 |
n_set,
|
| 873 |
n_swap,
|
|
@@ -897,7 +917,12 @@ def update_path(clickData,
|
|
| 897 |
if trigger == "btn_longest_cib":
|
| 898 |
return longest_cib(d), {"active": False, "start_idx": None, "end_idx": None}
|
| 899 |
|
| 900 |
-
# 2b)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 901 |
if trigger == "btn_shorter_cib":
|
| 902 |
return shorter_cib(d), {"active": False, "start_idx": None, "end_idx": None}
|
| 903 |
|
|
|
|
| 356 |
seq.append(g)
|
| 357 |
return seq
|
| 358 |
|
| 359 |
+
def longest_sym_cib(d: int):
|
| 360 |
+
"""
|
| 361 |
+
Return a predefined longest symmetric coil-in-the-box
|
| 362 |
+
for certain dimensions, otherwise fall back to a trivial path.
|
| 363 |
+
"""
|
| 364 |
+
presets = {
|
| 365 |
+
4: [0, 1, 3, 7, 15, 14, 12, 8, 0],
|
| 366 |
+
5: [0, 1, 3, 7, 15, 31, 29, 21, 20, 22, 18, 26, 10, 8, 0],
|
| 367 |
+
6: [0, 1, 3, 7, 15, 13, 29, 28, 20, 22, 18, 50, 48, 56, 57, 59, 63, 55, 53, 37, 36, 44, 46, 42, 10, 8, 0],
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
if d in presets:
|
| 371 |
+
return presets[d][:] # return a copy
|
| 372 |
+
|
| 373 |
+
return [0]
|
| 374 |
+
|
| 375 |
|
| 376 |
def shorter_cib(d: int):
|
| 377 |
"""
|
|
|
|
| 764 |
html.Button("Set path", id="btn_set", n_clicks=0),
|
| 765 |
html.Button("Longest CIB", id="btn_longest_cib", n_clicks=0,
|
| 766 |
style={"background": "#059669", "color": "white"}),
|
| 767 |
+
html.Button("Longest Symmetric CIB", id="btn_longest_sym_cib", n_clicks=0,
|
| 768 |
+
style={"background": "#7DD3FC", "color": "#0B1220"}),
|
| 769 |
html.Button("Shorter CIB", id="btn_shorter_cib", n_clicks=0,
|
| 770 |
style={"background": "#00C04B", "color": "white"}),
|
| 771 |
html.Button("Clear", id="btn_clear", n_clicks=0),
|
|
|
|
| 868 |
Input("fig", "clickData"),
|
| 869 |
Input("btn_clear", "n_clicks"),
|
| 870 |
Input("btn_longest_cib", "n_clicks"),
|
| 871 |
+
Input("btn_longest_sym_cib", "n_clicks"),
|
| 872 |
Input("btn_shorter_cib", "n_clicks"),
|
| 873 |
Input("btn_set", "n_clicks"),
|
| 874 |
Input("btn_swap", "n_clicks"),
|
|
|
|
| 887 |
def update_path(clickData,
|
| 888 |
n_clear,
|
| 889 |
n_longest,
|
| 890 |
+
n_longest_sym,
|
| 891 |
n_shorter,
|
| 892 |
n_set,
|
| 893 |
n_swap,
|
|
|
|
| 917 |
if trigger == "btn_longest_cib":
|
| 918 |
return longest_cib(d), {"active": False, "start_idx": None, "end_idx": None}
|
| 919 |
|
| 920 |
+
# 2b) Longest Symmetric CIB
|
| 921 |
+
if trigger == "btn_longest_sym_cib":
|
| 922 |
+
return longest_sym_cib(d), {"active": False, "start_idx": None, "end_idx": None}
|
| 923 |
+
|
| 924 |
+
|
| 925 |
+
# 2c) Shorter CIB
|
| 926 |
if trigger == "btn_shorter_cib":
|
| 927 |
return shorter_cib(d), {"active": False, "start_idx": None, "end_idx": None}
|
| 928 |
|