Пример #1
0
    """Ensure that numbers are aligned in table by appending a blank space to postive values if 'parenthesis' are
    used to denote negative numbers"""

    def check_and_append(*args, **kwargs):
        result = fmtfct(*args, **kwargs)
        if fmtfct.parens and not result.endswith(')'):
            result += ' '
        return result

    return check_and_append


IntFormatter = pad_positive_wrapper(fmt.new_int_formatter(nan='-'))
FloatFormatter = pad_positive_wrapper(fmt.new_float_formatter(nan='-'))
PercentFormatter = pad_positive_wrapper(fmt.new_percent_formatter(nan='-'))
ThousandsFormatter = pad_positive_wrapper(fmt.new_thousands_formatter(nan='-'))
MillionsFormatter = pad_positive_wrapper(fmt.new_millions_formatter(nan='-'))
BillionsFormatter = pad_positive_wrapper(fmt.new_billions_formatter(nan='-'))
# Don't attempt to pad
DynamicNumberFormatter = fmt.DynamicNumberFormat(nan='-', pcts=1, trunc_dot_zeros=1)

DollarCentsFormatter = pad_positive_wrapper(fmt.new_float_formatter(prefix='$', nan='-'))
DollarFormatter = pad_positive_wrapper(fmt.new_int_formatter(prefix='$', nan='-'))
ThousandDollarsFormatter = pad_positive_wrapper(fmt.new_thousands_formatter(prefix='$', nan='-'))
MillionDollarsFormatter = pad_positive_wrapper(fmt.new_millions_formatter(prefix='$', nan='-'))
BillionDollarsFormatter = pad_positive_wrapper(fmt.new_billions_formatter(prefix='$', nan='-'))
YmdFormatter = fmt.new_datetime_formatter('%Y%m%d', True)
Y_m_dFormatter = fmt.new_datetime_formatter('%Y_%m_%d', True)
mdYFormatter = fmt.new_datetime_formatter('%m/%d/%Y', True)

Пример #2
0
 def thousands(self, precision=1):
     fct = fmt.new_thousands_formatter(precision=precision)
     wrapper = lambda x, pos: fct(x)
     self.axis.set_major_formatter(FuncFormatter(wrapper))
     return self
Пример #3
0
def pad_positive_wrapper(fmtfct):
    """Ensure that numbers are aligned in table by appending a blank space to postive values if 'parenthesis' are
    used to denote negative numbers"""
    def check_and_append(*args, **kwargs):
        result = fmtfct(*args, **kwargs)
        if fmtfct.parens and not result.endswith(')'):
            result += ' '
        return result

    return check_and_append


IntFormatter = pad_positive_wrapper(fmt.new_int_formatter(nan='-'))
FloatFormatter = pad_positive_wrapper(fmt.new_float_formatter(nan='-'))
PercentFormatter = pad_positive_wrapper(fmt.new_percent_formatter(nan='-'))
ThousandsFormatter = pad_positive_wrapper(fmt.new_thousands_formatter(nan='-'))
MillionsFormatter = pad_positive_wrapper(fmt.new_millions_formatter(nan='-'))
BillionsFormatter = pad_positive_wrapper(fmt.new_billions_formatter(nan='-'))
# Don't attempt to pad
DynamicNumberFormatter = fmt.DynamicNumberFormat(method='col',
                                                 nan='-',
                                                 pcts=1,
                                                 trunc_dot_zeros=1)

DollarCentsFormatter = pad_positive_wrapper(
    fmt.new_float_formatter(prefix='$', nan='-'))
DollarFormatter = pad_positive_wrapper(
    fmt.new_int_formatter(prefix='$', nan='-'))
ThousandDollarsFormatter = pad_positive_wrapper(
    fmt.new_thousands_formatter(prefix='$', nan='-'))
MillionDollarsFormatter = pad_positive_wrapper(
Пример #4
0
    """Ensure that numbers are aligned in table by appending a blank space to postive values if 'parenthesis' are
    used to denote negative numbers"""

    def check_and_append(*args, **kwargs):
        result = fmtfct(*args, **kwargs)
        if fmtfct.parens and not result.endswith(")"):
            result += " "
        return result

    return check_and_append


IntFormatter = pad_positive_wrapper(fmt.new_int_formatter(nan="-"))
FloatFormatter = pad_positive_wrapper(fmt.new_float_formatter(nan="-"))
PercentFormatter = pad_positive_wrapper(fmt.new_percent_formatter(nan="-"))
ThousandsFormatter = pad_positive_wrapper(fmt.new_thousands_formatter(nan="-"))
MillionsFormatter = pad_positive_wrapper(fmt.new_millions_formatter(nan="-"))
BillionsFormatter = pad_positive_wrapper(fmt.new_billions_formatter(nan="-"))
# Don't attempt to pad
DynamicNumberFormatter = fmt.DynamicNumberFormat(method="col", nan="-", pcts=1, trunc_dot_zeros=1)

DollarCentsFormatter = pad_positive_wrapper(fmt.new_float_formatter(prefix="$", nan="-"))
DollarFormatter = pad_positive_wrapper(fmt.new_int_formatter(prefix="$", nan="-"))
ThousandDollarsFormatter = pad_positive_wrapper(fmt.new_thousands_formatter(prefix="$", nan="-"))
MillionDollarsFormatter = pad_positive_wrapper(fmt.new_millions_formatter(prefix="$", nan="-"))
BillionDollarsFormatter = pad_positive_wrapper(fmt.new_billions_formatter(prefix="$", nan="-"))
YmdFormatter = fmt.new_datetime_formatter("%Y%m%d", True)
Y_m_dFormatter = fmt.new_datetime_formatter("%Y-%m-%d", True)
mdYFormatter = fmt.new_datetime_formatter("%m/%d/%Y", True)

Пример #5
0
 def thousands(self, precision=1):
     fct = fmt.new_thousands_formatter(precision=precision)
     wrapper = lambda x, pos: fct(x)
     self.axis.set_major_formatter(FuncFormatter(wrapper))
     return self
Пример #6
0
def pad_positive_wrapper(fmtfct):
    """Ensure that numbers are aligned in table by appending a blank space to postive values if 'parenthesis' are
    used to denote negative numbers"""
    def check_and_append(*args, **kwargs):
        result = fmtfct(*args, **kwargs)
        if fmtfct.parens and not result.endswith(")"):
            result += " "
        return result

    return check_and_append


IntFormatter = pad_positive_wrapper(fmt.new_int_formatter(nan="-"))
FloatFormatter = pad_positive_wrapper(fmt.new_float_formatter(nan="-"))
PercentFormatter = pad_positive_wrapper(fmt.new_percent_formatter(nan="-"))
ThousandsFormatter = pad_positive_wrapper(fmt.new_thousands_formatter(nan="-"))
MillionsFormatter = pad_positive_wrapper(fmt.new_millions_formatter(nan="-"))
BillionsFormatter = pad_positive_wrapper(fmt.new_billions_formatter(nan="-"))
# Don't attempt to pad
DynamicNumberFormatter = fmt.DynamicNumberFormat(method="col",
                                                 nan="-",
                                                 pcts=1,
                                                 trunc_dot_zeros=1)

DollarCentsFormatter = pad_positive_wrapper(
    fmt.new_float_formatter(prefix="$", nan="-"))
DollarFormatter = pad_positive_wrapper(
    fmt.new_int_formatter(prefix="$", nan="-"))
ThousandDollarsFormatter = pad_positive_wrapper(
    fmt.new_thousands_formatter(prefix="$", nan="-"))
MillionDollarsFormatter = pad_positive_wrapper(