Exemple #1
0
def long_table(num=2, title=("符号", "说明")):
    data_table = LongTable("l " * num)
    data_table.add_hline()
    data_table.add_hline()
    data_table.add_row(title)
    data_table.add_hline()
    data_table.end_table_header()
    data_table.add_hline()
    data_table.end_table_footer()
    data_table.add_hline()
    data_table.add_hline()
    data_table.end_table_last_footer()
    return data_table
Exemple #2
0
    def make_table(headers: List, *args):
        table = LongTable('|l| l| l| p{10cm}|')
        table.add_hline()
        table.add_row([
            NoEscape(f'\\textbf{{\\textcolor{{black}}{{{i}}}}}')
            for i in headers
        ])
        table.add_hline()
        table.end_table_header()
        table.add_hline()
        table.add_row((MultiColumn(4, align='r',
                                   data='Continued on next page'), ))
        # table.add_hline()
        table.end_table_footer()
        # table.add_hline()
        # table.add_row((MultiColumn(n_cols, align='r', data=''),))
        # table.add_hline()
        table.end_table_last_footer()

        for i in range(len(args[0])):
            table.add_row([NoEscape(j[i]) for j in args])
            table.add_hline()

        return table
Exemple #3
0
def make_table_of_symbols(symbols: List[str], units: List[str],
                          descriptions: List[str]):
    table_symbols_content = LongTable("l l l")
    table_symbols_content.add_hline()
    table_symbols_content.add_row(["Symbol", "Unit", "Description"])
    table_symbols_content.add_hline()
    table_symbols_content.end_table_header()
    table_symbols_content.add_hline()
    table_symbols_content.add_row(
        (MultiColumn(3, align='r', data='Continued on Next Page'), ))
    table_symbols_content.add_hline()
    table_symbols_content.end_table_footer()
    table_symbols_content.add_hline()
    table_symbols_content.add_row((MultiColumn(3, align='r', data='***End'), ))
    table_symbols_content.add_hline()
    table_symbols_content.end_table_last_footer()

    for i in range(len(symbols)):
        try:
            symbol = py2tex(symbols[i], print_latex=False,
                            print_formula=False).replace('$', '')
        except:
            symbol = symbols[i]
        try:
            unit = py2tex(units[i],
                          print_latex=False,
                          print_formula=False,
                          simplify_fractions=True).replace('$', '')
        except:
            unit = units[i]
        table_symbols_content.add_row([
            NoEscape(f'${symbol}$'),
            NoEscape(f'${unit}$'),
            NoEscape(descriptions[i])
        ])

    table_symbols_content.add_hline()

    return table_symbols_content
Exemple #4
0
path = os.path.dirname(os.path.abspath(__file__))
dataset = [
    'vehicle', 'ionosphere', 'ecoli', 'german', 'breast_cancer', 'cmc',
    'hepatitis', 'haberman', 'transfusion', 'car', 'glass', 'abalone16_29',
    'heart_cleveland', 'balance_scale', 'postoperative'
]

sections = [
    "Accuracy", "Sensitivity", "Specificity", "F-1 klasa mniejszosciowa",
    'G-mean'
]
random_state = 5
tables = []
for tab in range(5):
    table = LongTable('c|c|cccccc')
    table.add_hline()
    table.add_row(('Zbior danych', 'Glebokosc drzewa.', "-", "5", "10", "20",
                   "50", "100"))
    table.add_hline()
    tables.append(table)

# liczba powtorzen klasyfikacji
iterations = 10

# liczba fold w sprawdzianie krzyzowym
folds = 10
#glebokosc drzewa i liczba estymatorow
depths = [None, 1, 3, 5]
estimators = [5, 10, 20, 50, 100]
depths_name = ['-']
depths_name.extend(depths[1:])
Exemple #5
0
def write_file(m_l=3, m_u=70, s_l=3, s_u=60, findProc=False):
    doc = Document('BIGRUN_ALL')
    doc_one = Document('BIGRUN_ONE')
    doc_open = Document('Open')
    doc_non_FC = Document('Non_FC')
    doc_V3 = Document('V3')
    doc_gaps = Document('GAPS')

    table = LongTable('|c|c|c|c|c|c|c|c|')
    table.add_hline()
    table.add_row((bold('M'), bold('S'), bold('Method'), bold('Open?'),
                   bold('LB'), bold('UB'), bold('LB-CD'), bold('UB-CD')))
    table.add_hline()
    table.add_hline()

    table_one = LongTable('|c|c|c|c|c|c|c|c|')
    table_one.add_hline()
    table_one.add_row((bold('M'), bold('S'), bold('Method'), bold('Open?'),
                   bold('LB'), bold('UB'), bold('LB-CD'), bold('UB-CD')))
    table_one.add_hline()
    table_one.add_hline()

    table_open = LongTable('|c|c|c|c|c|c|c|c|')
    table_open.add_hline()
    table_open.add_row((bold('M'), bold('S'), bold('Method'), bold('Open?'),
                        bold('LB'), bold('UB'), bold('LB-CD'), bold('UB-CD')))
    table_open.add_hline()
    table_open.add_hline()

    table_non_FC = LongTable('|c|c|c|c|c|c|c|c|')
    table_non_FC.add_hline()
    table_non_FC.add_row((bold('M'), bold('S'), bold('Method'), bold('Open?'),
                          bold('LB'), bold('UB'), bold('LB-CD'), bold('UB-CD')))
    table_non_FC.add_hline()
    table_non_FC.add_hline()

    table_V3 = LongTable('|c|c|c|c|c|c|c|c|')
    table_V3.add_hline()
    table_V3.add_row((bold('M'), bold('S'), bold('Method'), bold('Open?'),
                      bold('LB'), bold('UB'), bold('LB-CD'), bold('UB-CD')))
    table_V3.add_hline()
    table_V3.add_hline()

    table_gaps = LongTable('|c|c|c|c|c|c|c|c|')
    table_gaps.add_hline()
    table_gaps.add_row((bold('M'), bold('S'), bold('Method'), bold('Open?'),
                      bold('LB'), bold('UB'), bold('LB-CD'), bold('UB-CD')))
    table_gaps.add_hline()
    table_gaps.add_hline()

    bigrun_csv = open('data/bigrun_all.csv', 'w')
    csv_writer = csv.writer(bigrun_csv)
    csv_writer.writerow(['M', 'S', 'FC', 'HALF', 'INT', 'MID', 'EBM', 'HBM', 'VHBM'])

    for s in range(s_l, s_u + 1):
        m_start = s + 1 if s + 1 > m_l else m_l
        for m in range(m_start, m_u + 1):
            if relatively_prime(m, s):
                ub, ans_types, all_results = f(m, s, bigrun=True)
                csv_writer.writerow([m, s] + all_results)
                open_prob = ''
                lb = ''
                lb_cd = ''
                ub_cd = ''
                used_gaps = False
                try:
                    if checkProc(findProc, m, s, ub):
                        open_prob = ''
                    else:
                        used_gaps = True
                        lb = Fraction(ub.numerator - 2, ub.denominator)
                        lb = lb if lb > Fraction(1, 3) else Fraction(1, 3)
                        lb, lb_type = closer_bounds(m, s, lb, ub, max_denom=750)
                        if lb_type == 'Open':
                            open_prob = 'Open'
                            lb_cd, ub_cd = convert_den(lb, ub)
                        else:
                            ans_types = [lb_type]
                            ub = lb
                            lb = ''
                except procedures.TimeoutError:
                    open_prob = 'Timeout'
                except KeyError:
                    open_prob = 'Timeout'
                ans_types_str = functools.reduce(lambda a, b: a + ',' + str(b), ans_types)
                row = (m, s, ans_types_str, open_prob, str(lb), str(ub), lb_cd, ub_cd)
                table.add_row(row)
                row_one = (m, s, ans_types[0], open_prob, str(lb), str(ub), lb_cd, ub_cd)
                table_one.add_row(row_one)
                print(row_one)
                table.add_hline()
                table_one.add_hline()
                if len(open_prob) > 0:
                    table_open.add_row(row)
                    table_open.add_hline()
                if len(open_prob) > 0 or 'FC' not in ans_types_str:
                    table_non_FC.add_row(row)
                    table_non_FC.add_hline()
                V, _, _ = calcSv(m, s)
                if V == 3:
                    if not used_gaps:
                        _, ans_types_all = f(m, s, bigrun=False)
                        ans_types_all_str = functools.reduce(lambda a, b: a + ',' + str(b), ans_types)
                        row = (m, s, ans_types_all_str, open_prob, str(lb), str(ub), lb_cd, ub_cd)
                    table_V3.add_row(row)
                    table_V3.add_hline()
                if len(open_prob) == 0 and used_gaps:
                    table_gaps.add_row(row)
                    table_gaps.add_hline()

    doc.append(table)
    doc.generate_pdf('bigrun/BIGRUN_all', clean_tex=False)
    doc_one.append(table_one)
    doc_one.generate_pdf('bigrun/BIGRUN_one', clean_tex=False)
    doc_open.append(table_open)
    doc_open.generate_pdf('bigrun/BIGRUN_opens', clean_tex=False)
    doc_non_FC.append(table_non_FC)
    doc_non_FC.generate_pdf('bigrun/BIGRUN_non_FC', clean_tex=False)
    doc_V3.append(table_V3)
    doc_V3.generate_pdf('bigrun/BIGRUN_V3', clean_tex=False)
    doc_gaps.append(table_gaps)
    doc_gaps.generate_pdf('bigrun/BIGRUN_GAPS', clean_tex=False)