-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.py
52 lines (44 loc) · 1.88 KB
/
script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os, sys, argparse
import matplotlib.pyplot as plt
import library
ROOT = '/home/lili/Dropbox/plots/'
#ROOT = '/Users/lilidworkin/Desktop/'
def make_plots(args):
print 'Group: %s' % args.group
print 'Fill Defect: %s' % args.fill_defect
group = int(args.group) if args.group else None
pathA = 'both' if not args.group else args.group
pathB = 'filled' if args.fill_defect else ''
path = ROOT + '%s-%s' % (pathA, pathB)
if not os.path.exists(path):
os.mkdir(path)
matrix_func = library.gen_matrix if not args.user_centric \
else library.gen_matrix_user_centric
matrix = matrix_func(group, args.fill_defect)
plot_funcs = [library.each_round_vs_supergame,
library.ave_round_vs_supergame,
library.grouped_supergames_vs_round,
library.all_data]
for func in plot_funcs:
func(matrix, path + '/')
plt.clf()
def player_games(args):
workerId = library.find_workerId(args.user) if args.user else args.worker
library.print_worker_games(workerId, args.batch)
def convert(args):
print library.find_workerId(args.user)
if __name__ == '__main__':
func_map = {'plots': lambda: make_plots(args),
'player': lambda: player_games(args),
'unfinished': lambda: library.print_unfinished_games(args.batch),
'convert': lambda: convert(args)}
parser = argparse.ArgumentParser()
parser.add_argument('type', choices=func_map.keys())
parser.add_argument('--batch', default=None)
parser.add_argument('--group', default=None)
parser.add_argument('-u', '--user')
parser.add_argument('-w', '--worker')
parser.add_argument('--fill-defect', dest='fill_defect', action='store_true')
parser.add_argument('--user-centric', dest='user_centric', action='store_true')
args = parser.parse_args()
func_map[args.type]()