Beispiel #1
0

if __name__ == '__main__':
    parser = OptionParser("usage: %prog FACTOR-MODEL")
    parser.add_option('-o',
                      dest='output_filename',
                      help='file to store the output in')
    parser.add_option('--latex',
                      dest='latex',
                      help='output in LaTeX format',
                      action='store_true')
    options, args = parser.parse_args()
    if len(args) != 1:
        parser.error('Incorrect number of arguments')
    factor_model_file, = args
    factor_model = cpa.util.unpickle1(factor_model_file)

    loadings = get_loadings(factor_model)

    def write_loadings(f):
        if options.latex:
            write_loadings_latex(f, loadings)
        else:
            write_loadings_text(f, loadings)

    if options.output_filename:
        with replace_atomically(options.output_filename) as f:
            write_loadings(f)
    else:
        write_loadings(sys.stdout)
        if i > 0:
            print('\\addlinespace', file=f)
        for j, (weight, variable) in enumerate(l):
            label = factor if j == 0 else ''
            print('%s & %f & %s \\\\' % (label, weight, variable), file=f)

if __name__ == '__main__':
    parser = OptionParser("usage: %prog FACTOR-MODEL")
    parser.add_option('-o', dest='output_filename', help='file to store the output in')
    parser.add_option('--latex', dest='latex', help='output in LaTeX format', action='store_true')
    options, args = parser.parse_args()
    if len(args) != 1:
        parser.error('Incorrect number of arguments')
    factor_model_file, = args
    factor_model = cpa.util.unpickle1(factor_model_file)

    loadings = get_loadings(factor_model)

    def write_loadings(f):
        if options.latex:
            write_loadings_latex(f, loadings)
        else:
            write_loadings_text(f, loadings)
    
    if options.output_filename:
        with replace_atomically(options.output_filename) as f:
            write_loadings(f)
    else:
        write_loadings(sys.stdout)