Exemple #1
0
 def test_grouper_1(self):
     list = [i for i in range(9)]
     assert fu.grouper(2, list) == [(0, 1), (2, 3), (4, 5), (6, 7), (8, None)]
     assert fu.grouper(2, list, fillvalue=0) == [(0, 1), (2, 3), (4, 5), (6, 7), (8, 0)]
     assert fu.grouper(3, list, fillvalue=0) == [(0, 1, 2), (3, 4, 5), (6, 7, 8)]
Exemple #2
0
     fiducial.append( fu.significant_digits( (par, Bounds_68[num]), mode=1 ) )
 # get the names:
 if use_latex:
     parameter_names_latex = copy.deepcopy(fish.get_param_names_latex())
 else:
     parameter_names       = copy.deepcopy(fish.get_param_names())
 # do the printing:
 if use_latex:
     print_table = []
     for par,fid,bound in zip( parameter_names_latex,fiducial,Bounds_68 ):
         print_table.append( '$'+str(par)+' = '+str(fid)+' \pm '+str(bound)+'$' )
     if len(print_table)%latex_num_col == 0:
         table_length = len(print_table)/latex_num_col
     else:
         table_length = len(print_table)/latex_num_col +1
     print_table = fu.grouper( table_length, print_table,fillvalue='' )
     print_table = [ list(i) for i in print_table]      
     print_table = map(list, zip(*print_table))
     col_width = [max(len(str(x)) for x in col) for col in zip(*print_table)]
     
     if outroot is not None:
         out_file.write( '\hline'+'\n' )
         out_file.write( '\multicolumn{'+str(latex_num_col)+'}{|c|}{'+fish.name.replace('_',' ')+'} \\\[1mm]'+'\n' )
         out_file.write( '\hline'+'\n' )
         for line in print_table:
             out_file.write( " " + " & ".join("{:{}}".format(x, col_width[i]) for i, x in enumerate(line)) + " \\\[1mm]\n" )
     else:
         print '\hline'
         print '\multicolumn{'+str(latex_num_col)+'}{|c|}{'+fish.name.replace('_',' ')+'} \\\[1mm]'
         print '\hline'
         for line in print_table:
                        cent = 100
                        psign = '\%'
                        if isclose(fid, 0.0, rel_tol=1e-6, abs_tol=1e-6):
                            fid = 1
                            cent = 1
                            psign = ''
                        perc = abs((bound / fid) * cent)
                        print_table.append('$\sigma_{' + str(par) + '} = ' +
                                           str('{:.6f}'.format(perc)) + psign +
                                           ' $')
                    if len(print_table) % latex_num_col == 0:
                        table_length = len(print_table) / latex_num_col
                    else:
                        table_length = len(print_table) / latex_num_col + 1
                    print_table = fu.grouper(table_length,
                                             print_table,
                                             fillvalue='')
                    print_table = [list(i) for i in print_table]
                    print_table = map(list, zip(*print_table))
                    col_width = [
                        max(len(str(x)) for x in col)
                        for col in zip(*print_table)
                    ]

                    if outroot is not None:
                        out_file.write('\hline' + '\n')
                        out_file.write('\multicolumn{' + str(latex_num_col) +
                                       '}{|c|}{' +
                                       fish.name.replace('_', ' ') +
                                       '} \\\[1mm]' + '\n')
                        out_file.write('\hline' + '\n')
Exemple #4
0
 def test_grouper_1(self):
     list = [i for i in range(9)]
     assert fu.grouper(2, list) == [(0, 1), (2, 3), (4, 5), (6, 7), (8, None)]
     assert fu.grouper(2, list, fillvalue=0) == [(0, 1), (2, 3), (4, 5), (6, 7), (8, 0)]
     assert fu.grouper(3, list, fillvalue=0) == [(0, 1, 2), (3, 4, 5), (6, 7, 8)]