def _format_val(item): val = item[1] if isinstance(val, list): return '[ {} ]'.format( ",".join(_format_val((None, v)) for v in val) ) elif isinstance(val, (float, unit.units.Quantity)): return unit.format_quantity(val, '.3f') elif isinstance(val, basestring): return val else: return str(val)
def GetTwissCols(self): """Column description for the calculated initial conditions.""" return [ ColumnInfo( "Param", lambda item: item[0], wx.LIST_FORMAT_LEFT, wx.LIST_AUTOSIZE), ColumnInfo( "Value", lambda item: format_quantity(item[1]), wx.LIST_FORMAT_RIGHT, wx.LIST_AUTOSIZE), ]
def display(self, value): if value is None: return "" if self.unit is None else unit.get_raw_label(self.unit) if isinstance(value, (float, unit.units.Quantity)): return unit.format_quantity(value, self.fmtspec) return format(value)
def format_dvm_value(param, value, prec=None): value = tounit(value, param.ui_unit) fmt_code = '.{}f'.format(param.ui_prec if prec is None else prec) return format_quantity(value, fmt_code)
def _format_sd_value(self, name, item): el_name, values = item value = values.get(name) if value is None: return '' return format_quantity(value)