Skip to content

Commit

Permalink
#950 tweaks to plots and putting int(x) back in batch exec
Browse files Browse the repository at this point in the history
This is better because if the fold lists are defined with strings it's
limiting on the lambdas. The user has to user whichever string
identifier the fold lists's isnt using and he has no idea until the
program crashes when evaluating lambdas
  • Loading branch information
brunofavs committed May 12, 2024
1 parent 4530c52 commit 8248a2f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
6 changes: 5 additions & 1 deletion atom_batch_execution/scripts/batch_execution
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,18 @@ def main():
folds = list(folds)

# Transforming indexes of collections into collection keys
fold_list = [[[collection_keys[element] for element in split] for split in fold] for fold in folds]
fold_list = [[[int(collection_keys[element]) for element in split] for split in fold] for fold in folds]

# Dataset is no longer needed
del dataset

# Add folds to data
data['folds'] = fold_list

# Add dataset dirname to data
dataset_dirname = os.path.dirname(data["dataset_path"])
data["dataset_dirname"] = dataset_dirname

# Template engine1 setup
file_loader = FileSystemLoader(os.path.dirname(args['template_filename']))
env = Environment(loader=file_loader, undefined=jinja2.StrictUndefined)
Expand Down
14 changes: 12 additions & 2 deletions atom_batch_execution/scripts/plot_graphs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ def main():
grid = plot_options['grid']
markersizes = plot_options['markersizes']
markers = plot_options['markers']
xscale = plot_options['xscale']
yscale = plot_options['yscale']


# Normalizing options to allow them to be defined as lists or individual str/int
#Strs
Expand Down Expand Up @@ -243,12 +246,19 @@ def main():
plt.xlabel(xlabel)
plt.ylabel(ylabel)
plt.grid(grid)
plt.xscale(xscale) # Set x-scale
plt.yscale(yscale) # Set y-scale
if legend is not None:
plt.legend()
plt.legend(prop={'size': 6})

# Save figure in output folder

image_file_name = f'{title.replace(" ", "_")}.png'
image_file_name = f'{title.replace(" ", "_")}'
image_file_name = f'{image_file_name.replace("/", "_")}'
# Some characters like / are problematic in filenames
# image_file_name = ''.join(filter(lambda x : str.isalnum(x) or x == "_",image_file_name))
image_file_name = ''.join(filter(lambda x : x != "," and x != "\n",image_file_name))
image_file_name = f'{image_file_name}.png'

if os.path.isfile(image_file_name) and not args['overwrite']:
atomWarn(f'Plot with name {Fore.YELLOW}{image_file_name}{Style.RESET_ALL} found in {Fore.YELLOW}{args["output_folder"]}{Style.RESET_ALL}, not saving')
Expand Down

0 comments on commit 8248a2f

Please sign in to comment.