notrito commited on
Commit
794e8a6
·
1 Parent(s): 4939391
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -11,29 +11,26 @@ cached_data = {}
11
 
12
 
13
  def format_vector(vector, title):
14
- """Format vector as HTML table (first 100 dims)."""
15
  sample = vector[:100]
16
 
17
  html = f"<h3>{title}</h3>"
18
- html += "<div style='font-family: monospace; font-size: 11px; max-height: 400px; overflow-y: scroll;'>"
19
  html += "<table style='border-collapse: collapse;'>"
 
20
 
21
- # 10 columns x 10 rows
22
- for row in range(10):
23
- html += "<tr>"
24
- for col in range(10):
25
- idx = row * 10 + col
26
- val = sample[idx]
27
- color = "red" if val < 0 else "blue" if val > 0 else "gray"
28
- html += f"<td style='padding: 4px; text-align: right; color: {color};'>{val:.2f}</td>"
29
- html += "</tr>"
30
 
 
31
  html += "</table></div>"
32
  return html
33
 
34
 
35
  def format_matrix(matrix, title):
36
- """Format matrix as HTML table (100x100)."""
37
  sample = matrix[:100, :100]
38
 
39
  html = f"<h3>{title}</h3>"
@@ -45,7 +42,7 @@ def format_matrix(matrix, title):
45
  for col in range(100):
46
  val = sample[row, col]
47
  color = "red" if val < 0 else "blue" if val > 0 else "gray"
48
- html += f"<td style='padding: 2px; text-align: right; color: {color}; border: 1px solid #eee;'>{val:.2f}</td>"
49
  html += "</tr>"
50
 
51
  html += "</table></div>"
 
11
 
12
 
13
  def format_vector(vector, title):
14
+ """Format vector as HTML table (1 row x 100 columns)."""
15
  sample = vector[:100]
16
 
17
  html = f"<h3>{title}</h3>"
18
+ html += "<div style='font-family: monospace; font-size: 11px; max-width: 100%; overflow-x: scroll;'>"
19
  html += "<table style='border-collapse: collapse;'>"
20
+ html += "<tr>"
21
 
22
+ # Single row with 100 columns
23
+ for idx, val in enumerate(sample):
24
+ color = "red" if val < 0 else "blue" if val > 0 else "gray"
25
+ html += f"<td style='padding: 4px; text-align: right; color: {color}; border: 1px solid #eee;'>{val:.3f}</td>"
 
 
 
 
 
26
 
27
+ html += "</tr>"
28
  html += "</table></div>"
29
  return html
30
 
31
 
32
  def format_matrix(matrix, title):
33
+ """Format matrix as HTML table (100x100) with 3 decimals."""
34
  sample = matrix[:100, :100]
35
 
36
  html = f"<h3>{title}</h3>"
 
42
  for col in range(100):
43
  val = sample[row, col]
44
  color = "red" if val < 0 else "blue" if val > 0 else "gray"
45
+ html += f"<td style='padding: 2px; text-align: right; color: {color}; border: 1px solid #eee;'>{val:.3f}</td>"
46
  html += "</tr>"
47
 
48
  html += "</table></div>"