C2MV commited on
Commit
5c5ea4a
verified
1 Parent(s): a6dcc94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -17
app.py CHANGED
@@ -17,6 +17,24 @@ from docx.enum.text import WD_PARAGRAPH_ALIGNMENT
17
  from matplotlib.colors import to_hex
18
  import os
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  # --- Clase RSM_BoxBehnken ---
21
  class RSM_BoxBehnken:
22
  def __init__(self, data, x1_name, x2_name, x3_name, y_name, x1_levels, x2_levels, x3_levels):
@@ -603,21 +621,8 @@ def load_data(data_str): # Modified load_data to only take data_str
603
  Carga los datos del dise帽o Box-Behnken desde cajas de texto y crea la instancia de RSM_BoxBehnken.
604
  """
605
  try:
606
- # Use the data dictionary directly
607
- data_dict = {
608
- 'Tratamiento': ['T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'T9', 'T10', 'T11', 'T12', 'T13', 'T14', 'T15'] * 3,
609
- 'Tiempo_fermentacion_h': [16] * 15 + [23] * 15 + [40] * 15,
610
- 'pH': [6.02, 5.39, 6.27, 4.82, 6.25, 4.87, 4.76, 4.68, 4.64, 6.35, 4.67, 6.43, 4.58, 4.60, 6.96,
611
- 5.17, 5.95, 6.90, 5.50, 5.08, 4.95, 5.41, 5.52, 4.98, 7.10, 5.36, 6.91, 5.21, 4.66, 7.10,
612
- 5.42, 5.60, 7.36, 5.36, 4.66, 4.93, 5.18, 5.26, 4.92, 7.28, 5.26, 6.84, 5.19, 4.58, 7.07],
613
- 'Abs_600nm': [1.576, 1.474, 1.293, 1.446, 1.537, 1.415, 1.481, 1.419, 1.321, 1.224, 1.459, 0.345, 1.279, 1.181, 0.662,
614
- 1.760, 1.690, 1.485, 1.658, 1.728, 1.594, 1.673, 1.607, 1.531, 1.424, 1.595, 0.344, 1.477, 1.257, 0.660,
615
- 1.932, 1.780, 1.689, 1.876, 1.885, 1.824, 1.913, 1.810, 1.852, 1.694, 1.831, 0.347, 1.752, 1.367, 0.656],
616
- 'Glucosa_g_L': [5,10,0,5,10,5,10,5,10,0,5,0,5,5,0] * 3,
617
- 'Proteina_Pescado_g_L': [1.4,1.4,3.2,3.2,3.2,3.2,3.2,5,5,5,5,0,5,5,0] * 3,
618
- 'Sulfato_Manganeso_g_L': [0.75,0.5,0.75,0.5,0.75,0.5,0.75,0.5,0.25,0.75,0.5,0.25,0.5,0.25,0.5] * 3
619
- }
620
- data = pd.DataFrame(data_dict)
621
 
622
  x1_name = "Glucosa_g_L"
623
  x2_name = "Proteina_Pescado_g_L"
@@ -629,7 +634,6 @@ def load_data(data_str): # Modified load_data to only take data_str
629
 
630
 
631
  # Crear la instancia de RSM_BoxBehnken
632
- global rsm
633
  rsm = RSM_BoxBehnken(data, x1_name, x2_name, x3_name, y_name, x1_levels, x2_levels, x3_levels)
634
 
635
  return data.round(3), gr.update(visible=True) # Removed other outputs, only return data_output and analysis_row
@@ -705,7 +709,7 @@ def navigate_plot(direction, current_index, all_figures):
705
  selected_fig = all_figures[new_index]
706
  plot_info_text = f"Gr谩fico {new_index + 1} de {len(all_figures)}"
707
 
708
- return selected_fig, plot_info_text, new_index
709
 
710
  def download_current_plot(all_figures, current_index):
711
  """
 
17
  from matplotlib.colors import to_hex
18
  import os
19
 
20
+ # --- Data definition in global scope ---
21
+ data_dict = {
22
+ 'Tratamiento': ['T1', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'T9', 'T10', 'T11', 'T12', 'T13', 'T14', 'T15'] * 3,
23
+ 'Tiempo_fermentacion_h': [16] * 15 + [23] * 15 + [40] * 15,
24
+ 'pH': [6.02, 5.39, 6.27, 4.82, 6.25, 4.87, 4.76, 4.68, 4.64, 6.35, 4.67, 6.43, 4.58, 4.60, 6.96,
25
+ 5.17, 5.95, 6.90, 5.50, 5.08, 4.95, 5.41, 5.52, 4.98, 7.10, 5.36, 6.91, 5.21, 4.66, 7.10,
26
+ 5.42, 5.60, 7.36, 5.36, 4.66, 4.93, 5.18, 5.26, 4.92, 7.28, 5.26, 6.84, 5.19, 4.58, 7.07],
27
+ 'Abs_600nm': [1.576, 1.474, 1.293, 1.446, 1.537, 1.415, 1.481, 1.419, 1.321, 1.224, 1.459, 0.345, 1.279, 1.181, 0.662,
28
+ 1.760, 1.690, 1.485, 1.658, 1.728, 1.594, 1.673, 1.607, 1.531, 1.424, 1.595, 0.344, 1.477, 1.257, 0.660,
29
+ 1.932, 1.780, 1.689, 1.876, 1.885, 1.824, 1.913, 1.810, 1.852, 1.694, 1.831, 0.347, 1.752, 1.367, 0.656],
30
+ 'Glucosa_g_L': [5,10,0,5,10,5,10,5,10,0,5,0,5,5,0] * 3,
31
+ 'Proteina_Pescado_g_L': [1.4,1.4,3.2,3.2,3.2,3.2,3.2,5,5,5,5,0,5,5,0] * 3,
32
+ 'Sulfato_Manganeso_g_L': [0.75,0.5,0.75,0.5,0.75,0.5,0.75,0.5,0.25,0.75,0.5,0.25,0.5,0.25,0.5] * 3
33
+ }
34
+ data = pd.DataFrame(data_dict)
35
+ # --- End of data definition in global scope ---
36
+
37
+
38
  # --- Clase RSM_BoxBehnken ---
39
  class RSM_BoxBehnken:
40
  def __init__(self, data, x1_name, x2_name, x3_name, y_name, x1_levels, x2_levels, x3_levels):
 
621
  Carga los datos del dise帽o Box-Behnken desde cajas de texto y crea la instancia de RSM_BoxBehnken.
622
  """
623
  try:
624
+ # Use the global data DataFrame
625
+ global rsm, data
 
 
 
 
 
 
 
 
 
 
 
 
 
626
 
627
  x1_name = "Glucosa_g_L"
628
  x2_name = "Proteina_Pescado_g_L"
 
634
 
635
 
636
  # Crear la instancia de RSM_BoxBehnken
 
637
  rsm = RSM_BoxBehnken(data, x1_name, x2_name, x3_name, y_name, x1_levels, x2_levels, x3_levels)
638
 
639
  return data.round(3), gr.update(visible=True) # Removed other outputs, only return data_output and analysis_row
 
709
  selected_fig = all_figures[new_index]
710
  plot_info_text = f"Gr谩fico {new_index + 1} de {len(all_figures)}"
711
 
712
+ return selected_fig, plot_info_text, current_index
713
 
714
  def download_current_plot(all_figures, current_index):
715
  """