Skip to content

Commit

Permalink
fix font size and add pre/post/add_parser_args tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Cleveland committed Jan 30, 2025
1 parent 58e2e90 commit e935bfd
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
4 changes: 2 additions & 2 deletions opppy/plotting_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def add_plot_options(parser):
parser.add_argument('-lpo','--last_point_only', dest='last_point_only', help='only plot the last data point', nargs='?', type=bool, default=False, const=True )
parser.add_argument('-ltv','--last_time_value', dest='last_time_value', help='only plot the last time value', nargs=1, type=float)
parser.add_argument('-fr','--figure_resolution', dest='figure_resolution', help='figure resolution in dpi', nargs='?', type=float, default=300.0)
parser.add_argument('-fs','--font_size', dest='font size', help='set the plot font size', type=float, default=None, nargs="?")
parser.add_argument('-fs','--font_size', dest='font_size', help='set the plot font size', type=float, default=None, nargs="?")
parser.add_argument('-yev','--y_exceeds_value', dest='y_exceeds_value', help='y arrival value', nargs=1, type=float, default=0.0)
parser.add_argument('-sy','--scale_y', dest='scale_y', help='scale y values', type=float, default=[], action="append")
parser.add_argument('-sx','--scale_x', dest='scale_x', help='scale x values', type=float, default=[], action="append")
Expand All @@ -302,7 +302,7 @@ def add_2d_plot_options(parser):
parser.add_argument('-xlab','--xlab', dest='x_label', help='x axis label')
parser.add_argument('-ylab','--ylabl', dest='y_label', help='y axis label')
parser.add_argument('-fr','--figure_resolution', dest='figure_resolution', help='figure resolution in dpi', nargs='?', type=float, default=300.0)
parser.add_argument('-fs','--font_size', dest='font size', help='set the plot font size', type=float, default=None, nargs="?")
parser.add_argument('-fs','--font_size', dest='font_size', help='set the plot font size', type=float, default=None, nargs="?")
parser.add_argument('-sv','--scale_value', dest='scale_value', help='scale values', type=float, default=1.0)
parser.add_argument('-sx','--scale_x', dest='scale_x', help='scale x values', type=float, default=1.0)
parser.add_argument('-sy','--scale_y', dest='scale_y', help='scale y values', type=float, default=1.0)
Expand Down
1 change: 1 addition & 0 deletions tests/my_test_opppy_dump_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ def build_data_dictionary(self, filename, dump_keys=None):
return data



18 changes: 16 additions & 2 deletions tests/my_test_opppy_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ def __init__(self):
self.file_end_string = None
print("Initializing my_test_opppy_parser")

def add_parser_args(self, parser):
parser.add_argument('-ppt', '--pre_parser_test', dest="pre_parser_test", nargs="?", default=None)

def pre_parse(self, args):
if(args.pre_parser_test is not None):
print("pre_parse hook works: args.pre_parser_test")
else:
print("pre_parse hook works: None")

def parse_cycle_string(self,cycle_string):
# return dictionary of dictionaries
data_dict = {}
Expand Down Expand Up @@ -53,8 +62,13 @@ def parse_cycle_string(self,cycle_string):
# append dictionary with multiple entries
data_dict['density'] = density_data

return data_dict

def post_parse(self, args, data):
if(args.pre_parser_test is not None):
data["post_parse_test_"+args.pre_parser_test]=data['test_data1']
else:
data['post_parser_test']=data['test_data1']


return data_dict


16 changes: 15 additions & 1 deletion tests/my_test_opppy_tally_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ def __init__(self):
self.file_end_string = None
print("Initializing my_test_opppy_tally_parser")

def add_parser_args(self, parser):
parser.add_argument('-ppt', '--pre_parser_test', dest="pre_parser_test", nargs="?", default=None)

def pre_parse(self, args):
if(args.pre_parser_test is not None):
print("pre_parse hook works: args.pre_parser_test")
else:
print("pre_parse hook works: None")


def parse_cycle_string(self,cycle_string):
cycle_data_keys = ['bins','odd_counts','even_counts']
cycle_info_keys = ['time', 'cycle']
Expand Down Expand Up @@ -58,4 +68,8 @@ def parse_cycle_string(self,cycle_string):
data_dict['cool_counts'] = counts

return data_dict


def post_parse(self, args, data):
print("Post Parse Test Data keys: ",data.keys())


0 comments on commit e935bfd

Please sign in to comment.