From 8c534e775607eb36d6232cbcb9532bcd60441c9f Mon Sep 17 00:00:00 2001
From: Olivier BICHLER <olivier.bichler@cea.fr>
Date: Thu, 14 Nov 2024 15:06:40 +0100
Subject: [PATCH] Make log function return series

---
 aidge_core/static_analysis.py | 38 ++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/aidge_core/static_analysis.py b/aidge_core/static_analysis.py
index add0c9910..c65a102a1 100644
--- a/aidge_core/static_analysis.py
+++ b/aidge_core/static_analysis.py
@@ -19,7 +19,9 @@ class StaticAnalysisExt(aidge_core.StaticAnalysis):
             series.append([name, self.get_nb_params(node)])
 
         if title is None: title = "log_nb_params"
-        self._log_bar(series, filename, title, legend, log_scale)
+        if filename is not None:
+            self._log_bar(series, filename, title, legend, log_scale)
+        return series
 
     def log_params_size(self, filename, title=None, log_scale=False):
         namePtrTable = self.get_graph().get_ranked_nodes_name("{0} ({1}#{3})");
@@ -35,38 +37,40 @@ class StaticAnalysisExt(aidge_core.StaticAnalysis):
             series.append([name, self.log_params_size(node)])
 
         if title is None: title = "log_params_size"
-        self._log_bar(series, filename, title, legend, log_scale)
+        if filename is not None:
+            self._log_bar(series, filename, title, legend, log_scale)
+        return series
 
     def log_nb_arithm_ops(self, filename, title=None, log_scale=False):
-        self._log_callback(aidge_core.OperatorStats.get_nb_arithm_ops, filename, title, log_scale)
+        return self._log_callback(aidge_core.OperatorStats.get_nb_arithm_ops, filename, title, log_scale)
 
     def log_nb_logic_ops(self, filename, title=None, log_scale=False):
-        self._log_callback(aidge_core.OperatorStats.get_nb_logic_ops, filename, title, log_scale)
+        return self._log_callback(aidge_core.OperatorStats.get_nb_logic_ops, filename, title, log_scale)
 
     def log_nb_comp_ops(self, filename, title=None, log_scale=False):
-        self._log_callback(aidge_core.OperatorStats.get_nb_comp_ops, filename, title, log_scale)
+        return self._log_callback(aidge_core.OperatorStats.get_nb_comp_ops, filename, title, log_scale)
 
     def log_nb_nl_ops(self, filename, title=None, log_scale=False):
-        self._log_callback(aidge_core.OperatorStats.get_nb_nl_ops, filename, title, log_scale)
+        return self._log_callback(aidge_core.OperatorStats.get_nb_nl_ops, filename, title, log_scale)
 
     def log_nb_mac_ops(self, filename, title=None, log_scale=False):
-        self._log_callback(aidge_core.OperatorStats.get_nb_mac_ops, filename, title, log_scale)
+        return self._log_callback(aidge_core.OperatorStats.get_nb_mac_ops, filename, title, log_scale)
 
     def log_nb_ops(self, filename, title=None, log_scale=False):
-        self._log_callback(aidge_core.OperatorStats.get_nb_ops, filename, title, log_scale)
+        return self._log_callback(aidge_core.OperatorStats.get_nb_ops, filename, title, log_scale)
 
     def log_nb_arithm_int_ops(self, filename, title=None, log_scale=False):
-        self._log_callback(aidge_core.OperatorStats.get_nb_arithm_int_ops, filename, title, log_scale)
+        return self._log_callback(aidge_core.OperatorStats.get_nb_arithm_int_ops, filename, title, log_scale)
 
     def log_nb_arithm_fp_ops(self, filename, title=None, log_scale=False):
-        self._log_callback(aidge_core.OperatorStats.get_nb_arithm_fp_ops, filename, title, log_scale)
+        return self._log_callback(aidge_core.OperatorStats.get_nb_arithm_fp_ops, filename, title, log_scale)
 
     def log_nb_ops_by_type(self, filename, title=None, log_scale=False):
-        self._log_callback([aidge_core.OperatorStats.get_nb_arithm_int_ops,
-                            aidge_core.OperatorStats.get_nb_arithm_fp_ops,
-                            aidge_core.OperatorStats.get_nb_logic_ops,
-                            aidge_core.OperatorStats.get_nb_comp_ops,
-                            aidge_core.OperatorStats.get_nb_nl_ops], filename, title, log_scale)
+        return self._log_callback([aidge_core.OperatorStats.get_nb_arithm_int_ops,
+                                  aidge_core.OperatorStats.get_nb_arithm_fp_ops,
+                                  aidge_core.OperatorStats.get_nb_logic_ops,
+                                  aidge_core.OperatorStats.get_nb_comp_ops,
+                                  aidge_core.OperatorStats.get_nb_nl_ops], filename, title, log_scale)
 
     def _log_callback(self, callback, filename, title=None, log_scale=False):
         """
@@ -115,7 +119,9 @@ class StaticAnalysisExt(aidge_core.StaticAnalysis):
                 if title is None: title = callback.__name__
 
         if title is None: title = str(callback)
-        self._log_bar(series, filename, title, legend, log_scale)
+        if filename is not None:
+            self._log_bar(series, filename, title, legend, log_scale)
+        return series
 
     def _log_bar(self, series, filename, title=None, legend=None, log_scale=False):
         names, values = zip(*series)
-- 
GitLab