not-lain commited on
Commit
e64e782
1 Parent(s): 9c7dc56

add colors

Browse files
Files changed (1) hide show
  1. app.py +20 -5
app.py CHANGED
@@ -58,10 +58,18 @@ def sanitize_dimention(dim):
58
  return out
59
 
60
 
61
- def create_row(dim):
62
  out = "| "
63
- for i in dim:
64
- out = out + str(i) + " | "
 
 
 
 
 
 
 
 
65
  return out + "\n"
66
 
67
 
@@ -78,9 +86,16 @@ def generate_table(dim1, dim2, checks=None):
78
  n_dim = len(dim1)
79
  table = create_header(n_dim, checks)
80
  # tensor 1
81
- table += create_row(dim1)
 
 
 
 
82
  # tensor 2
83
- table += create_row(dim2)
 
 
 
84
  return table
85
 
86
 
 
58
  return out
59
 
60
 
61
+ def create_row(dim,is_dim=None,checks=None):
62
  out = "| "
63
+ n_dim = len(dim)
64
+ for i in range(n_dim):
65
+ if (is_dim ==1 and i != n_dim-1) or (is_dim ==2 and i ==n_dim-1):
66
+ color = "green" if checks[i] == "V" else "red"
67
+ out += f"<strong style='color: {color}'> {dim[i]} </strong>| "
68
+ elif (is_dim ==1 and i == n_dim-1) or (is_dim ==2 and i ==n_dim-2):
69
+ color = "blue" if checks[i] == "V" else "red"
70
+ out += f"<strong style='color: {color}'> {dim[i]} </strong>| "
71
+ else :
72
+ out+= f"{dim[i]} | "
73
  return out + "\n"
74
 
75
 
 
86
  n_dim = len(dim1)
87
  table = create_header(n_dim, checks)
88
  # tensor 1
89
+ if not checks :
90
+ table += create_row(dim1)
91
+ else :
92
+ table += create_row(dim1,1,checks)
93
+
94
  # tensor 2
95
+ if not checks :
96
+ table += create_row(dim2)
97
+ else :
98
+ table += create_row(dim2,2,checks)
99
  return table
100
 
101