Example #1
0
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)
Example #2
0
 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),
     ]
Example #3
0
 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)
Example #4
0
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)
Example #5
0
 def _format_sd_value(self, name, item):
     el_name, values = item
     value = values.get(name)
     if value is None:
         return ''
     return format_quantity(value)