def test_complex_and_valid_in_fluent(self): res = Format().align(f.Align.center).fill('.').group( f.Group.yes ).padding(True).padding_width(10).precision(6).scheme('s').sign( f.Sign.parantheses).symbol( f.Symbol.yes).symbol_prefix('a').symbol_suffix( 'bc').decimal_delimiter('x').group_delimiter('y').groups( [2, 2, 2, 3]).nully('N/A').si_prefix(f.Prefix.none) self.validate_complex(res.to_plotly_json())
def test_complex_and_valid_in_ctor(self): res = Format(align=f.Align.center, fill='.', group=f.Group.yes, padding=True, padding_width=10, precision=6, scheme='s', sign=f.Sign.parantheses, symbol=f.Symbol.yes, symbol_prefix='a', symbol_suffix='bc', decimal_delimiter='x', group_delimiter='y', groups=[2, 2, 2, 3], nully='N/A', si_prefix=f.Prefix.none) self.validate_complex(res.to_plotly_json())
def test_complex_and_valid_in_ctor(self): res = Format( align=f.Align.center, fill=".", group=f.Group.yes, padding=True, padding_width=10, precision=6, scheme="s", sign=f.Sign.parantheses, symbol=f.Symbol.yes, symbol_prefix="a", symbol_suffix="bc", decimal_delimiter="x", group_delimiter="y", groups=[2, 2, 2, 3], nully="N/A", si_prefix=f.Prefix.none, ) self.validate_complex(res.to_plotly_json())
def update_format_table( fixed_checkbox, decimal_char, precision, si_prefix, options_checklist, nan, scheme_dd, symbol_pct_radio, prefix, suffix, width, fill_char, align_val, group_checkbox, group_char, groupings, ): code = {} formatted = Format() if fixed_checkbox: formatted = formatted.scheme(Scheme.fixed) code[1] = ".scheme(Scheme.fixed)" if decimal_char: formatted = formatted.decimal_delimiter(decimal_char) code[2] = f".decimal_delimiter('{decimal_char}')" if precision: formatted = formatted.precision(int(precision)) code[3] = f".precision({int(precision)})" if si_prefix: si_prefix = None if si_prefix == "None" else si_prefix formatted = formatted.si_prefix(si_prefix) code[4] = f".si_prefix({si_prefix})" if symbol_pct_radio == "percentage": formatted = formatted.scheme(Scheme.percentage) code[5] = f".scheme(Scheme.percentage)" if "plus_minus" in options_checklist: formatted = formatted.sign(Sign.positive) code[6] = f".sign(Sign.positive)" if "parantheses" in options_checklist: formatted = formatted.sign(Sign.parantheses) code[7] = f".sign(Sign.parantheses)" if "trim" in options_checklist: formatted = formatted.trim(Trim.yes) code[8] = f".trim(Trim.yes)" if nan: print("nan", nan) formatted = formatted.nully(nan) code[9] = f".nully('{nan}')" if scheme_dd: formatted = formatted.scheme(scheme_dd) code[10] = f".scheme('{scheme_dd}')" if symbol_pct_radio == "symbol": formatted = formatted.symbol(Symbol.yes) code[11] = f".symbol(Symbol.yes)" if symbol_pct_radio == "none": code[11] = None code[5] = None if prefix: formatted = formatted.symbol_prefix(prefix) code[12] = f".symbol_prefix('{prefix}')" if suffix: formatted = formatted.symbol_suffix(suffix) code[13] = f".symbol_suffix('{suffix}')" if width: formatted = formatted.padding_width(int(width)) code[14] = f".padding_width({int(width)})" if fill_char: formatted = formatted.fill(fill_char) code[15] = f".fill('{fill_char}')" if align_val: formatted = formatted.align(align_val) code[16] = f".align('{align_val}')" if group_checkbox: formatted = formatted.group(Group.yes) code[17] = f".group(Group.yes)" if group_char: formatted = formatted.group_delimiter(group_char) code[18] = f".group_delimiter('{group_char}')" if groupings: formatted = formatted.groups(int(groupings)) code[19] = f".groups({int(groupings)})" columns = [ {"name": i, "id": i, "type": "numeric", "format": formatted} for i in df.columns ] code = ["formatted = formatted"] + list(code.values()) code = [] if code == ["formatted = formatted", None, None] else code to_json = ["formatted = "] + [str(formatted.to_plotly_json())] return columns, code, to_json