Spaces:
Sleeping
Sleeping
format
Browse files
app.py
CHANGED
|
@@ -11,29 +11,26 @@ cached_data = {}
|
|
| 11 |
|
| 12 |
|
| 13 |
def format_vector(vector, title):
|
| 14 |
-
"""Format vector as HTML table (
|
| 15 |
sample = vector[:100]
|
| 16 |
|
| 17 |
html = f"<h3>{title}</h3>"
|
| 18 |
-
html += "<div style='font-family: monospace; font-size: 11px; max-
|
| 19 |
html += "<table style='border-collapse: collapse;'>"
|
|
|
|
| 20 |
|
| 21 |
-
#
|
| 22 |
-
for
|
| 23 |
-
|
| 24 |
-
|
| 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:.
|
| 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>"
|