Exemple #1
0
def make_control(argv):
    # return a Bunch

    print argv
    parser = argparse.ArgumentParser()
    parser.add_argument('invocation')
    parser.add_argument('--data', help='reduce input and create data file in WORKING', action='store_true')
    parser.add_argument('--test', help='set internal test flag', action='store_true')
    arg = Bunch.from_namespace(parser.parse_args(argv))
    base_name = arg.invocation.split('.')[0]

    random_seed = 123
    random.seed(random_seed)

    dir_working = Path().dir_working()

    debug = False

    reduced_file_name = '0data.pickle'

    # assure output directory exists
    dir_path = dir_working + 'chart01/'
    if not os.path.exists(dir_path):
        os.makedirs(dir_path)

    return Bunch(
        arg=arg,
        base_name=base_name,
        debug=debug,
        path_in_samples=dir_working + 'samples-train.csv',
        path_out_graph=dir_path + 'median-price.pdf',
        path_out_price_volume=dir_path + 'price-volume.pdf',
        path_out_stats_all=dir_path + 'price-stats-all.txt',
        path_out_stats_2006_2008=dir_path + 'price-stats-2006-2008.txt',
        path_reduction=dir_path + reduced_file_name,
        random_seed=random_seed,
        test=arg.test,
    )