Commit 39870016e9bb7d9ed165eefb345cd9bcbfae2c78

Authored by Brice COLOMBIER
1 parent 5b421499d1
Exists in master

Add squared-addition and absolute-difference as possible operations

Showing 1 changed file with 9 additions and 5 deletions

preprocessing.py View file @ 3987001
... ... @@ -77,22 +77,26 @@
77 77 return args[0] * args[1]
78 78 def addition(*args):
79 79 return args[0] + args[1]
  80 +def squared_addition(*args):
  81 + return (args[0] + args[1])*(args[0] + args[1])
  82 +def absolute_difference(*args):
  83 + return abs(args[0] - args[1])
80 84  
81 85 if __name__ == "__main__":
82 86  
83 87 parser = argparse.ArgumentParser(description='Preprocess traces')
84 88 parser.add_argument("traces_name", type=str)
85   - parser.add_argument("--op", type=str, choices=['addition', 'multiplication', '', '', ''])
  89 + parser.add_argument("--op", type=str, choices=['addition', 'multiplication', 'squared_addition', 'absolute_difference'])
86 90 parser.add_argument("--window_size", type=int)
87 91 parser.add_argument("--min_dist", type=int)
88 92 parser.add_argument("--dtype", type=str)
89 93 parser.add_argument("--ncores", type=int)
90 94 parser.add_argument('-v', '--verbose', action='store_true')
91 95 args = parser.parse_args()
92   - if args.op == 'multiplication':
93   - operation = multiplication
94   - elif args.op == 'addition':
95   - operation = addition
  96 + if args.op == 'multiplication': operation = multiplication
  97 + elif args.op == 'addition': operation = addition
  98 + elif args.op == 'squared_addition': operation = squared_addition
  99 + elif args.op == 'absolute_difference': operation = absolute_difference
96 100 dtype = np.dtype(args.dtype).type
97 101  
98 102 data_set_width = 1000