prakharg24 commited on
Commit
5061012
·
verified ·
1 Parent(s): 67606c8

Update my_pages/multiverse.py

Browse files
Files changed (1) hide show
  1. my_pages/multiverse.py +21 -19
my_pages/multiverse.py CHANGED
@@ -5,41 +5,43 @@ from utils import development_stages
5
  def render():
6
  st.title("Multiverse of Developer Decisions")
7
 
8
- # Generate placeholder options for each stage
9
- stage_options = {}
10
- for stage in development_stages:
11
- stage_options[stage] = [f"{stage} Option {i}" for i in range(1, 4)]
12
 
13
- # User selects one option for each stage
 
 
 
14
  selected_path = []
15
  st.subheader("Choose your path")
16
- for stage, options in stage_options.items():
17
- choice = st.selectbox(f"{stage}:", options, key=stage)
18
  selected_path.append(choice)
19
 
20
- # Create Sankey diagram data
21
  labels = []
22
- for stage in development_stages:
23
- labels.extend(stage_options[stage])
24
 
25
- # Create links between every option in one stage to all options in the next
26
  source = []
27
  target = []
28
  value = []
29
  colors = []
30
 
31
- for i in range(len(development_stages) - 1):
32
- start_idx = i * 3
33
- end_idx = (i + 1) * 3
34
- next_start_idx = (i + 1) * 3
 
35
 
36
- for s in range(start_idx, start_idx + 3):
37
- for t in range(next_start_idx, next_start_idx + 3):
38
  source.append(s)
39
  target.append(t)
40
- value.append(1) # constant flow thickness
41
 
42
- # Highlight if both source and target are in selected path
43
  if labels[s] == selected_path[i] and labels[t] == selected_path[i+1]:
44
  colors.append("rgba(0, 150, 0, 0.8)")
45
  else:
 
5
  def render():
6
  st.title("Multiverse of Developer Decisions")
7
 
8
+ # Extract stage labels
9
+ stage_labels = [stage["label"] for stage in development_stages]
 
 
10
 
11
+ # Generate options from each stage's questions
12
+ stage_options = {stage["label"]: stage["questions"] for stage in development_stages}
13
+
14
+ # Let user pick one option from each stage
15
  selected_path = []
16
  st.subheader("Choose your path")
17
+ for stage_label, options in stage_options.items():
18
+ choice = st.selectbox(f"{stage_label}:", options, key=stage_label)
19
  selected_path.append(choice)
20
 
21
+ # Prepare Sankey diagram labels
22
  labels = []
23
+ for stage_label in stage_labels:
24
+ labels.extend(stage_options[stage_label])
25
 
26
+ # Create links between options in consecutive stages
27
  source = []
28
  target = []
29
  value = []
30
  colors = []
31
 
32
+ options_per_stage = [stage_options[stage] for stage in stage_labels]
33
+
34
+ for i in range(len(stage_labels) - 1):
35
+ start_idx = sum(len(opts) for opts in options_per_stage[:i])
36
+ next_start_idx = sum(len(opts) for opts in options_per_stage[:i+1])
37
 
38
+ for s in range(start_idx, start_idx + len(options_per_stage[i])):
39
+ for t in range(next_start_idx, next_start_idx + len(options_per_stage[i+1])):
40
  source.append(s)
41
  target.append(t)
42
+ value.append(1) # constant thickness for now
43
 
44
+ # Highlight chosen path
45
  if labels[s] == selected_path[i] and labels[t] == selected_path[i+1]:
46
  colors.append("rgba(0, 150, 0, 0.8)")
47
  else: