File indexing completed on 2026-04-10 07:58:46
0001 import argparse
0002 import json
0003
0004
0005
0006 parser = argparse.ArgumentParser()
0007 parser.add_argument('--max_points', action='store', type=int, required=True, help='max number of points to be generated')
0008 parser.add_argument('--num_points', action='store', type=int, required=True, help='number of points to be generated')
0009 parser.add_argument('--input', action='store', required=True, help='input json file which includes all pre-generated points')
0010 parser.add_argument('--output', action='store', required=True, help='output json file where outputs will be wrote')
0011
0012 args = parser.parse_args()
0013
0014
0015 def get_input_points(input):
0016 points = []
0017 opt_space = {}
0018 with open(input) as input_json:
0019 opt_points = json.load(input_json)
0020 if 'points' in opt_points:
0021 points = opt_points['points']
0022 if 'opt_space' in opt_points:
0023 opt_space = opt_points['opt_space']
0024 return points, opt_space
0025
0026
0027 def write_output_points(new_points, output):
0028 with open(args.output, 'w') as output_json:
0029 json.dump(new_points, output_json)
0030
0031
0032 def generate_new_points(input_points, opt_space, max_points, num_points):
0033 if len(input_points) >= max_points:
0034 return []
0035 elif len(input_points) >= max_points - 1:
0036 return [{'point_type': 'stat'}]
0037
0038 num_points = min(num_points, max_points - 1 - len(input_points))
0039
0040 new_points = []
0041 for _ in range(num_points):
0042 point = {'point_type': 'toy'}
0043 new_points.append(point)
0044
0045 return new_points
0046
0047
0048 input_points, opt_space = get_input_points(args.input)
0049 new_points = generate_new_points(input_points, opt_space, args.max_points, args.num_points)
0050 write_output_points(new_points, args.output)