Commit 00ab6266 authored by Sebastian Heimann's avatar Sebastian Heimann
Browse files

listener: align numbers by dot

parent 040cce1f
from pyrocko import util
import progressbar as pbar
from .base import Listener
......@@ -19,20 +20,23 @@ class TerminalListener(Listener):
col_width = 15
row_name = color.BOLD + '{:<{col_param_width}s}' + color.END
parameter_fmt = '{:>{col_width}{type}}'
parameter_fmt = '{:{col_width}s}'
def __init__(self):
self.current_state = None
self.pbars = {}
def progress_start(self, name, niter):
self.pbars[name] = pbar.start(name, niter)
pbar = util.progressbar('analysing problem', niter)
self.pbars[name] = pbar
pbar.start()
def progress_update(self, name, iiter):
self.pbars[name].update(iiter)
def progress_finish(self, name):
self.pbars[name].finish()
del self.pbars[name]
def state(self, state):
lines = []
......@@ -57,13 +61,15 @@ class TerminalListener(Listener):
col_width=self.col_width,
type='s'))
def fmt(s):
return util.gform(s, significant_digits=(self.col_width-1-6)/2)
for ip, parameter_name in enumerate(state.parameter_names):
l(out_ln.format(
parameter_name,
*[v[ip] for v in state.parameter_sets.values()],
*[fmt(v[ip]) for v in state.parameter_sets.values()],
col_param_width=col_param_width,
col_width=self.col_width,
type='.4g'))
col_width=self.col_width))
l(state.extra_text.format(
col_param_width=col_param_width,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment