hedtorresca commited on
Commit
f80c3bc
verified
1 Parent(s): 77d2459

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -5,7 +5,7 @@ from io import BytesIO
5
  from PIL import Image
6
  import pandas as pd
7
 
8
- def validate_inputs(A, B, C, AB, AC, BC, ABC, U):
9
  union_ABC = A + B + C - AB - AC - BC + ABC
10
  errors = []
11
 
@@ -25,7 +25,7 @@ def validate_inputs(A, B, C, AB, AC, BC, ABC, U):
25
  errors.append(f"A鈭〣鈭〤 ({ABC}) no puede ser mayor que B鈭〤 ({BC}).")
26
 
27
  return errors
28
- def suggest_intersections(A, B, C, AB, AC, BC, ABC, U):
29
  union_ABC = A + B + C - AB - AC - BC + ABC
30
 
31
  min_AB = min(A, B, ABC)
@@ -45,7 +45,7 @@ def suggest_intersections(A, B, C, AB, AC, BC, ABC, U):
45
  }
46
  return suggestions
47
 
48
- def calculate_probabilities(A, B, C, AB, AC, BC, ABC, U):
49
  total = U if U > 0 else (A + B + C - AB - AC - BC + ABC)
50
  if total == 0:
51
  return {
@@ -119,7 +119,7 @@ def calculate_probabilities(A, B, C, AB, AC, BC, ABC, U):
119
  df = pd.DataFrame(list(formatted_probs.items()), columns=["Descripci贸n", "Valor"])
120
  return df
121
 
122
- def draw_venn(A, B, C, AB, AC, BC, ABC, U):
123
  plt.figure(figsize=(10,10))
124
  venn = venn3(subsets=(max(0, A - AB - AC + ABC), max(0,B - AB - BC + ABC), max(0,AB - ABC), max(0,C- AC - BC + ABC), max(AC - ABC, 0), max(BC - ABC,0), ABC), set_labels=('A', 'B', 'C'))
125
  img = BytesIO()
@@ -129,15 +129,15 @@ def draw_venn(A, B, C, AB, AC, BC, ABC, U):
129
  image = Image.open(img)
130
  return image
131
 
132
- def main(A, B, C, AB, AC, BC, ABC, U):
133
- errors = validate_inputs(A, B, C, AB, AC, BC, ABC, U)
134
  if errors:
135
  # Devolver None para la imagen y el DataFrame si hay errores
136
  return None, pd.DataFrame({"Errores de validaci贸n": errors}), {}
137
 
138
- venn_image = draw_venn(A, B, C, AB, AC, BC, ABC, U)
139
- probabilities_df = calculate_probabilities(A, B, C, AB, AC, BC, ABC, U)
140
- suggestions = suggest_intersections(A, B, C, AB, AC, BC, ABC, U)
141
 
142
  return venn_image, probabilities_df, suggestions
143
 
 
5
  from PIL import Image
6
  import pandas as pd
7
 
8
+ def validate_inputs(U, A, B, C, AB, AC, BC, ABC):
9
  union_ABC = A + B + C - AB - AC - BC + ABC
10
  errors = []
11
 
 
25
  errors.append(f"A鈭〣鈭〤 ({ABC}) no puede ser mayor que B鈭〤 ({BC}).")
26
 
27
  return errors
28
+ def suggest_intersections(U, A, B, C, AB, AC, BC, ABC):
29
  union_ABC = A + B + C - AB - AC - BC + ABC
30
 
31
  min_AB = min(A, B, ABC)
 
45
  }
46
  return suggestions
47
 
48
+ def calculate_probabilities(U, A, B, C, AB, AC, BC, ABC):
49
  total = U if U > 0 else (A + B + C - AB - AC - BC + ABC)
50
  if total == 0:
51
  return {
 
119
  df = pd.DataFrame(list(formatted_probs.items()), columns=["Descripci贸n", "Valor"])
120
  return df
121
 
122
+ def draw_venn(U, A, B, C, AB, AC, BC, ABC):
123
  plt.figure(figsize=(10,10))
124
  venn = venn3(subsets=(max(0, A - AB - AC + ABC), max(0,B - AB - BC + ABC), max(0,AB - ABC), max(0,C- AC - BC + ABC), max(AC - ABC, 0), max(BC - ABC,0), ABC), set_labels=('A', 'B', 'C'))
125
  img = BytesIO()
 
129
  image = Image.open(img)
130
  return image
131
 
132
+ def main(U, A, B, C, AB, AC, BC, ABC):
133
+ errors = validate_inputs(U, A, B, C, AB, AC, BC, ABC)
134
  if errors:
135
  # Devolver None para la imagen y el DataFrame si hay errores
136
  return None, pd.DataFrame({"Errores de validaci贸n": errors}), {}
137
 
138
+ venn_image = draw_venn(U, A, B, C, AB, AC, BC, ABC)
139
+ probabilities_df = calculate_probabilities(U, A, B, C, AB, AC, BC, ABC)
140
+ suggestions = suggest_intersections(U, A, B, C, AB, AC, BC, ABC)
141
 
142
  return venn_image, probabilities_df, suggestions
143