notrito commited on
Commit
aeb4847
·
1 Parent(s): 794e8a6
Files changed (1) hide show
  1. app.py +73 -12
app.py CHANGED
@@ -11,18 +11,30 @@ cached_data = {}
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>"
@@ -30,19 +42,68 @@ def format_vector(vector, title):
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>"
37
  html += "<div style='font-family: monospace; font-size: 9px; max-height: 600px; overflow: scroll;'>"
38
  html += "<table style='border-collapse: collapse;'>"
39
 
40
- for row in range(100):
 
41
  html += "<tr>"
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>"
 
11
 
12
 
13
  def format_vector(vector, title):
14
+ """Format vector as HTML table (first 50 + ... + last 50)."""
15
+ first_vals = vector[:50]
16
+ last_vals = vector[-50:]
17
+ sample = np.concatenate([first_vals, last_vals])
18
 
19
  html = f"<h3>{title}</h3>"
20
  html += "<div style='font-family: monospace; font-size: 11px; max-width: 100%; overflow-x: scroll;'>"
21
  html += "<table style='border-collapse: collapse;'>"
22
  html += "<tr>"
23
 
24
+ # First 50 dimensions
25
+ for idx in range(50):
26
+ val = sample[idx]
27
+ color = "gray"
28
+ html += f"<td style='padding: 4px; text-align: right; color: {color}; border: 1px solid #eee;'>{val:.4f}</td>"
29
+
30
+ # Separator
31
+ html += "<td style='padding: 4px; text-align: center; font-weight: bold;'>...</td>"
32
+
33
+ # Last 50 dimensions
34
+ for idx in range(50, 100):
35
+ val = sample[idx]
36
+ color = "gray"
37
+ html += f"<td style='padding: 4px; text-align: right; color: {color}; border: 1px solid #eee;'>{val:.4f}</td>"
38
 
39
  html += "</tr>"
40
  html += "</table></div>"
 
42
 
43
 
44
  def format_matrix(matrix, title):
45
+ """Format matrix as HTML table (first 50x50 + ... + last 50x50)."""
46
+ first_first = matrix[:50, :50]
47
+ first_last = matrix[:50, -50:]
48
+ last_first = matrix[-50:, :50]
49
+ last_last = matrix[-50:, -50:]
50
+ sample_first = np.concatenate([first_first, first_last], axis=1)
51
+ sample_last = np.concatenate([last_first, last_last], axis=1)
52
+ sample = np.concatenate([sample_first, sample_last], axis=0)
53
 
54
  html = f"<h3>{title}</h3>"
55
  html += "<div style='font-family: monospace; font-size: 9px; max-height: 600px; overflow: scroll;'>"
56
  html += "<table style='border-collapse: collapse;'>"
57
 
58
+ # First 50 rows
59
+ for row in range(50):
60
  html += "<tr>"
61
+
62
+ # First 50 columns
63
+ for col in range(50):
64
+ val = sample[row, col]
65
+ color = "gray"
66
+ html += f"<td style='padding: 2px; text-align: right; color: {color}; border: 1px solid #eee;'>{val:.4f}</td>"
67
+
68
+ # Column separator
69
+ html += "<td style='padding: 2px; text-align: center; font-weight: bold;'>...</td>"
70
+
71
+ # Last 50 columns
72
+ for col in range(50, 100):
73
  val = sample[row, col]
74
+ color = "gray"
75
+ html += f"<td style='padding: 2px; text-align: right; color: {color}; border: 1px solid #eee;'>{val:.4f}</td>"
76
+
77
+ html += "</tr>"
78
+
79
+ # Row separator
80
+ html += "<tr>"
81
+ for _ in range(50):
82
+ html += "<td style='padding: 2px; text-align: center; font-weight: bold;'>⋮</td>"
83
+ html += "<td style='padding: 2px; text-align: center; font-weight: bold;'>⋱</td>"
84
+ for _ in range(50):
85
+ html += "<td style='padding: 2px; text-align: center; font-weight: bold;'>⋮</td>"
86
+ html += "</tr>"
87
+
88
+ # Last 50 rows
89
+ for row in range(50, 100):
90
+ html += "<tr>"
91
+
92
+ # First 50 columns
93
+ for col in range(50):
94
+ val = sample[row, col]
95
+ color = "gray"
96
+ html += f"<td style='padding: 2px; text-align: right; color: {color}; border: 1px solid #eee;'>{val:.4f}</td>"
97
+
98
+ # Column separator
99
+ html += "<td style='padding: 2px; text-align: center; font-weight: bold;'>...</td>"
100
+
101
+ # Last 50 columns
102
+ for col in range(50, 100):
103
+ val = sample[row, col]
104
+ color = "gray"
105
+ html += f"<td style='padding: 2px; text-align: right; color: {color}; border: 1px solid #eee;'>{val:.4f}</td>"
106
+
107
  html += "</tr>"
108
 
109
  html += "</table></div>"