コード例 #1
0
def write_table_subfig(nrows, ncols, allcells={},
                allcols=None, allrows=None, introws=None, intcols=None,
                firstrow=None, firstcol=None, intcells={},
                label_prefix=None):
    """ Like write_table(), but use subfigures """
    
    param_table = get_param_table(nrows, ncols, allcells, allcols, allrows,
                                  introws, intcols, firstrow, firstcol, intcells)

#    with latex_fragment(sys.stdout, graphics_path=get_resources_dir()) as frag:
#        for r, param_row in enumerate(param_table):
#            for c, param_cell in enumerate(param_row):
#                internal = c > 0 and r > 0
#                if internal:
#                    if label_prefix is not None:
#                        label = '%s-%s' % (r, c)
#                        label = label_prefix + '-' + label
#                    else:
#                        label = None
#                        
#                    with frag.subfigure(caption="", label=label) as subfigure:
#                        call_template(subfigure, param_cell)                    
#                else:
# #                    with frag.minipage() as minip:
#                    call_template(frag, param_cell)
#            frag.parbreak()
    
    
    alignment = ['r'] + ['c'] * ncols   
    with latex_fragment(sys.stdout, graphics_path=get_resources_dir()) as frag:
        with frag.tabular(alignment=alignment) as tabular:
            for r, param_row in enumerate(param_table):
                with tabular.row() as tex_row:
                    for c, param_cell in enumerate(param_row):
                        with tex_row.cell() as cell:
                            # print r, c, param_cell
                            logger.debug('%s %s : %s' % (r, c, param_cell))
#                            call_template(cell, param_cell)
                            internal = c > 0 and r > 0
                            if label_prefix is not None:
                                label = '%s-%s' % (r, c)
                                label = label_prefix + '-' + label
                            else:
                                label = None
                            if internal:
                                with cell.subfigure(caption="", label=label) as subfigure:
                                    call_template(subfigure, param_cell)
                            else:
                                call_template(cell, param_cell)
コード例 #2
0
def write_table(nrows, ncols, allcells={},
                allcols=None, allrows=None, introws=None, intcols=None,
                firstrow=None, firstcol=None, intcells={}):
    """
        Use as follows:
        
        Example 1: show correlation table
        
          write_table(common=dict(id_set='id_set'),
                      rows=[dict(id_robot='robot1'),
                            dict(id_robot='robot2')],
                      cols=[dict(id_agent='bdse1'),
                            dict(id_agent='bdse2')],
                      header_row = dict(template='agent_name'),
                      header_col = dict(template='robot_name'),
                      cells=dict(template='predict_y_dot_corr'))
            
        Example 2: show P and correlation for one agent
        
          write_table(common=dict(id_set='id_set', id_agent='id_agent'),
                      rows=[dict(id_robot='robot1'),
                            dict(id_robot='robot2')],
                      cols=[dict(template='bds_P'),
                            dict(template='bds_T0'),
                            dict(template='predict_y_dot_corr')],
                      header_row = dict(template='empty'),
                      header_col = dict(template='robot_name'),
                      cells=dict())
                      
    """
    
    param_table = get_param_table(nrows, ncols, allcells, allcols, allrows,
                                  introws, intcols, firstrow, firstcol, intcells)

    alignment = ['r'] + ['c'] * ncols   
    with latex_fragment(sys.stdout, graphics_path=get_resources_dir()) as frag:
        with frag.tabular(alignment=alignment) as tabular:
            for r, param_row in enumerate(param_table):
                with tabular.row() as tex_row:
                    for c, param_cell in enumerate(param_row):
                        with tex_row.cell() as cell:
                            # print r, c, param_cell
                            logger.debug('%s %s : %s' % (r, c, param_cell))
                            call_template(cell, param_cell)