tzurshubi commited on
Commit
d4d5ede
·
verified ·
1 Parent(s): 10763d2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -605,7 +605,7 @@ app.layout = html.Div(
605
  html.Div(
606
  style={"display": "flex", "gap": "8px", "alignItems": "center", "marginBottom": "8px"},
607
  children=[
608
- html.Button("Flip subpath (2 clicks)", id="btn_flip_subpath", n_clicks=0,
609
  style={"background": "#2563EB", "color": "white"}),
610
  dcc.Input(
611
  id="subpath_dim",
@@ -834,16 +834,16 @@ def update_path(clickData,
834
  return path, {"active": False, "start_idx": None, "end_idx": None}
835
 
836
  # subpath is path[s:e+1] = (v1,...,vk)
837
- # requirement: remove v2..vk and replace them with flipped(v2..vk)
838
- # so v1 stays as-is, and we replace the tail of the selected subpath.
839
- head = path[:s + 1]
840
- tail_selected = path[s + 1:e + 1] # v2..vk
841
- flipped_tail = [flip_dim_vertex(v, i) for v in tail_selected]
842
- rest = path[e + 1:]
843
- new_path = head + flipped_tail + rest
844
 
845
  return new_path, {"active": False, "start_idx": None, "end_idx": None}
846
 
 
847
  # 7) Figure clicks
848
  if trigger == "fig" and clickData and clickData.get("points"):
849
  p = clickData["points"][0]
 
605
  html.Div(
606
  style={"display": "flex", "gap": "8px", "alignItems": "center", "marginBottom": "8px"},
607
  children=[
608
+ html.Button("Flip subpath", id="btn_flip_subpath", n_clicks=0,
609
  style={"background": "#2563EB", "color": "white"}),
610
  dcc.Input(
611
  id="subpath_dim",
 
834
  return path, {"active": False, "start_idx": None, "end_idx": None}
835
 
836
  # subpath is path[s:e+1] = (v1,...,vk)
837
+ # desired: keep prefix (..., v1), keep suffix (vk, ...),
838
+ # and insert flipped(v1..vk) between them.
839
+ head = path[:s + 1] # includes v1
840
+ flipped_subpath = [flip_dim_vertex(v, i) for v in path[s:e + 1]]
841
+ rest = path[e:] # starts at vk
842
+ new_path = head + flipped_subpath + rest
 
843
 
844
  return new_path, {"active": False, "start_idx": None, "end_idx": None}
845
 
846
+
847
  # 7) Figure clicks
848
  if trigger == "fig" and clickData and clickData.get("points"):
849
  p = clickData["points"][0]