diff --git a/bfasst/utils/accumulate_metrics.py b/bfasst/utils/accumulate_metrics.py index 0d457652..3b163f00 100644 --- a/bfasst/utils/accumulate_metrics.py +++ b/bfasst/utils/accumulate_metrics.py @@ -44,6 +44,7 @@ def main(): def get_args(): + """Get the command line arguments.""" parser = argparse.ArgumentParser(description="Compute metrics on a graph.") parser.add_argument( "analysis_dir", help="The path to the folder containing all analysis files for all graphs." @@ -57,6 +58,7 @@ def get_args(): def compute_master_metrics(analysis_dir, master_metrics_output, stats_summary_output): + """Compute the master metrics from the analysis directory.""" master_metrics = {} for file in Path(analysis_dir).iterdir(): if file.is_dir(): @@ -100,9 +102,10 @@ def sort_metrics(metrics): return metrics -def get_stats_summary(metrics): +def get_stats_summary(master_metrics): + """Compute the 5-number summary, mean, and standard deviation for each metric.""" summary = {} - for ip, metrics in metrics.items(): + for ip, metrics in master_metrics.items(): for metric, values in metrics.items(): # Calculate statistics if values: # Check if the list is not empty @@ -129,6 +132,7 @@ def get_stats_summary(metrics): def five_number_summary(data): + """Compute the 5-number summary for the given data.""" n = len(data) min_val = data[0] max_val = data[-1] diff --git a/bfasst/utils/process_graph.py b/bfasst/utils/process_graph.py index 4b55df46..1170788d 100644 --- a/bfasst/utils/process_graph.py +++ b/bfasst/utils/process_graph.py @@ -182,10 +182,10 @@ def compute_metrics_per_ip(adj_lists, args): metrics_per_ip[ip]["local_clustering_coeff"].append(local_clustering) # Debug (verbose flag only) - logger.debug(f"IP: {ip}") - logger.debug(f"Component: {label}") - logger.debug(f"Nodes: {len(adj_list)}") - logger.debug(f"Edges: {edge_count}") + logger.debug("IP: %s", ip) + logger.debug("Component: %s", label) + logger.debug("Nodes: %s", len(adj_list)) + logger.debug("Edges: %s", edge_count) logger.debug("") return metrics_per_ip @@ -200,6 +200,7 @@ def compute_size(adj_list): def compute_average_diameter(adj_list): + """Compute the average diameter of a graph.""" uf = UnionFind() for u in adj_list: