add units to shopw digit length reabale
This commit is contained in:
parent
185962b4af
commit
642f79e1ff
@ -2,11 +2,19 @@ from __future__ import annotations
|
||||
|
||||
import curses
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
from typing import List, Tuple
|
||||
|
||||
from .colors import UIColors
|
||||
|
||||
|
||||
_DIGIT_UNITS: List[Tuple[int, str]] = [
|
||||
(10**12, "T digits"),
|
||||
(10**9, "G digits"),
|
||||
(10**6, "M digits"),
|
||||
(10**3, "K digits"),
|
||||
]
|
||||
|
||||
|
||||
class HeaderView:
|
||||
"""Top panel containing summary information."""
|
||||
|
||||
@ -28,9 +36,10 @@ class HeaderView:
|
||||
cols = max(1, cols)
|
||||
usable = max(1, cols - 1)
|
||||
bar = "─" * usable
|
||||
digits_line = self._format_digits_line(step, digits_len)
|
||||
lines = [
|
||||
" Collatz Stream Visualizer ",
|
||||
f" Step {step:,} • Digits {digits_len:,}",
|
||||
digits_line,
|
||||
f" Elapsed {elapsed:8.2f}s • Avg {avg_step:8.5f}s",
|
||||
f" Current calc {current_calc:6.2f}s {'⏳' if computing else '✓'} • Last {last_calc:6.2f}s",
|
||||
" ▲ green = 3n+1 • ▼ red = /2 • ↑↓ number scroll • PgUp/PgDn logs • q quit",
|
||||
@ -50,6 +59,14 @@ class HeaderView:
|
||||
|
||||
self.win.noutrefresh()
|
||||
|
||||
@staticmethod
|
||||
def _format_digits_line(step: int, digits_len: int) -> str:
|
||||
for threshold, label in _DIGIT_UNITS:
|
||||
if digits_len >= threshold:
|
||||
scaled = digits_len / float(threshold)
|
||||
return f" Step {step:,} • {scaled:,.2f} {label}"
|
||||
return f" Step {step:,} • Digits {digits_len:,}"
|
||||
|
||||
|
||||
class GraphView:
|
||||
"""Single-row sparkline showing how each step transformed the value."""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user