Ver Fonte

Adding parametrization of table column name

Ali há 1 ano atrás
pai
commit
3d83b04014
1 ficheiros alterados com 6 adições e 4 exclusões
  1. 6 4
      thesis_analysis/genererTableau.py

+ 6 - 4
thesis_analysis/genererTableau.py

@@ -16,14 +16,16 @@ class genererTableau ():
             qualitative_string_format : format d'écriture du n et de la proportion des variables qualitatives
     """
     
-    def __init__ (self, data, precision = 2, quantitative_string_format = "{mean:.2f} +/- {std:.2f} ({n})", qualitative_string_format = "{n} ({p:.2%})"):
+    def __init__ (self, data, precision = 2, quantitative_column_title = "{variable} mean +/- std (n)", quantitative_string_format = "{mean:.2f} +/- {std:.2f} ({n})", qualitative_column_title="{variable} no. (%)", qualitative_string_format = "{n} ({p:.2%})"):
         
         """
             Data : data contenant les données aggrégées, généré par analyseStatistiques.analyse_univarie
         """
         
         # Parametres
+        self.quantitative_column_title = quantitative_column_title
         self.quantitative_string_format = quantitative_string_format
+        self.qualitative_column_title = qualitative_column_title
         self.qualitative_string_format = qualitative_string_format
         self.absence_test = "Absence de test effectué (CI des tests conventionnels non remplis)"
         self.precision = precision
@@ -72,7 +74,7 @@ class genererTableau ():
         """
         
         texte = self.quantitative_string_format.format(
-            mean = round(mean, self.precision), 
+            mean=round(mean, self.precision), 
             std=round(std, self.precision), 
             n=round(n, self.precision)
         )
@@ -322,7 +324,7 @@ class genererTableau ():
             # Ligne d'une variable quantitative : une seule ligne
             
             ligne = [] # On instancie la ligne
-            ligne.append(variable+" mean +/- std (n)") # Ajout du nom de variable
+            ligne.append(self.quantitative_column_title.format(variable=variable)) # Ajout du nom de variable
             ligne.append("") # Espace vide, technique
             ligne.append(self._generer_str_mean_std_n(
                 self.data[variable]["global"]["mean"],
@@ -351,7 +353,7 @@ class genererTableau ():
             
             ## On écrit la première ligne : nom de variable et test
             ligne = [] # On instancie la ligne
-            ligne.append(variable+" no. (%)") # Nom de variable
+            ligne.append(self.qualitative_string_format.format(variable=variable)) # Nom de variable
             ligne = ligne + ["", ""] # Variable vides
             
             # Données liées à chaque axe