Skip to content

Commit

Permalink
Enough plotting for today
Browse files Browse the repository at this point in the history
  • Loading branch information
daquintero committed Aug 13, 2024
1 parent e161cca commit bcdf1cd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
18 changes: 15 additions & 3 deletions piel/experimental/visual/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
)


def truncate_filename(filename, max_length=100):
# TODO move this out of here.
"""
Truncate the filename if it exceeds max_length, appending a hash to ensure uniqueness.
"""
if len(filename) > max_length:
filename = filename[: max_length - 1]
return filename


def auto_plot_from_measurement_data(
measurement_data: MeasurementDataTypes,
**kwargs,
Expand Down Expand Up @@ -55,10 +65,12 @@ def auto_plot_from_measurement_data_collection(
i = 0
# We iterate through the corresponding plotting methods and generate the plots, and save them to the parent directory.
for plot_method_i in plot_methods:
plot_file_i = (
plot_output_directory
/ f"{measurement_data_collection.name}_{plot_prefix[i]}.png"
file_name = truncate_filename(
f"{plot_prefix}_{measurement_data_collection.name}"
)

plot_file_i = plot_output_directory / f"{file_name}.png"

plot_i = plot_method_i(measurement_data_collection, path=plot_file_i, **kwargs)
plots.append(plot_i)
plot_path_list.append(plot_file_i)
Expand Down
6 changes: 5 additions & 1 deletion piel/experimental/visual/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def auto_function_name_list_from_module(module) -> list[str]:
# Remove "plot_" prefix from the function names
function_name_list = [name.replace("plot_", "") for name in functions_list]

return function_name_list
# Ensure each function name length is limited to a reasonable length
# while still ensuring the total file name is under 100 characters
truncated_function_name_list = [name[:20] for name in function_name_list]

return truncated_function_name_list


"""
Expand Down

0 comments on commit bcdf1cd

Please sign in to comment.