⬅ datasets/gsn/utils_parsing.py source

1 import argparse
2  
  • E302 Expected 2 blank lines, found 1
3 def str2bool(v):
4 if v.lower() in ('yes', 'true', 't', 'y', '1'):
5 return True
6 elif v.lower() in ('no', 'false', 'f', 'n', '0'):
7 return False
8 else:
9 raise argparse.ArgumentTypeError('Boolean value expected.')
10  
11  
12 def str2ListOfListsOfLists2int(v):
  • E501 Line too long (118 > 79 characters)
13 return [[[[] if c == ' ' else int(c) for c in vii.split(',')] for vii in vi.split(',,')] for vi in v.split(',,,')]
14  
15  
16 def str2ListOfLists2int(v):
  • E501 Line too long (88 > 79 characters)
17 return [[[] if c == ' ' else int(c) for c in vi.split(',')] for vi in v.split(',,')]
18  
19  
20 def str2list2int(v):
21 return [int(c) for c in v.split(',')]
22  
23  
24 def str2list2float(v):
25 return [float(c) for c in v.split(',')]
26  
27  
28 def str2list2bool(v):
  • W292 No newline at end of file
29 return [str2bool(c) for c in v.split(',')]