Remove try:... for plots to free memory
This commit is contained in:
parent
db4d6c2b79
commit
2acdcc64b0
@ -4,6 +4,7 @@
|
|||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
from path import Path
|
from path import Path
|
||||||
import logging
|
import logging
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
def includegraphics(fig_ax, document_path="./", fig_path="fig/",
|
def includegraphics(fig_ax, document_path="./", fig_path="fig/",
|
||||||
@ -34,6 +35,7 @@ def includegraphics(fig_ax, document_path="./", fig_path="fig/",
|
|||||||
fig.tight_layout()
|
fig.tight_layout()
|
||||||
fig.savefig(path_to_file/filename)
|
fig.savefig(path_to_file/filename)
|
||||||
logger.info("Graphique {} sauvé à {}".format(filename, path_to_file))
|
logger.info("Graphique {} sauvé à {}".format(filename, path_to_file))
|
||||||
|
plt.close(fig)
|
||||||
return "\includegraphics[scale={sc}]{{{f}}}".format(sc = scale,
|
return "\includegraphics[scale={sc}]{{{f}}}".format(sc = scale,
|
||||||
f=Path(fig_path)/filename)
|
f=Path(fig_path)/filename)
|
||||||
|
|
||||||
|
@ -50,9 +50,12 @@ Compétences
|
|||||||
|
|
||||||
|
|
||||||
\vfill
|
\vfill
|
||||||
\Var{e.pies_on_competence | includegraphics(document_path=directory, scale=0.3)}
|
|
||||||
|
|
||||||
\Var{e.pies_on_domaine | includegraphics(document_path=directory, scale=0.3)}
|
\Var{e.heatmap_on_competence | includegraphics(document_path=directory, scale=0.6)}
|
||||||
|
|
||||||
|
\Var{e.heatmap_on_domain | includegraphics(document_path=directory, scale=0.6)}
|
||||||
|
%# \Var{e.pies_on_competence | includegraphics(document_path=directory, scale=0.3)}
|
||||||
|
%# \Var{e.pies_on_domaine | includegraphics(document_path=directory, scale=0.3)}
|
||||||
|
|
||||||
|
|
||||||
%#\Var{conn_df}
|
%#\Var{conn_df}
|
||||||
|
@ -102,59 +102,40 @@ class Student(object):
|
|||||||
@property
|
@property
|
||||||
def pies_on_competence(self):
|
def pies_on_competence(self):
|
||||||
""" Pies chart on competences """
|
""" Pies chart on competences """
|
||||||
try:
|
return pie_pivot_table(self.quest_df,
|
||||||
self._pies_on_competence
|
|
||||||
except AttributeError:
|
|
||||||
self._pies_on_competence = pie_pivot_table(self.quest_df,
|
|
||||||
index = "Level",
|
index = "Level",
|
||||||
columns = "Competence",
|
columns = "Competence",
|
||||||
values = "Eleve",
|
values = "Eleve",
|
||||||
aggfunc = len,
|
aggfunc = len,
|
||||||
fill_value = 0,
|
fill_value = 0,
|
||||||
)
|
)
|
||||||
return self._pies_on_competence
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pies_on_domaine(self):
|
def pies_on_domaine(self):
|
||||||
""" Pies chart on domaines """
|
""" Pies chart on domaines """
|
||||||
try:
|
return pie_pivot_table(self.quest_df,
|
||||||
self._pies_on_domaine
|
|
||||||
except AttributeError:
|
|
||||||
self._pies_on_domaine = pie_pivot_table(self.quest_df,
|
|
||||||
index = "Level",
|
index = "Level",
|
||||||
columns = "Domaine",
|
columns = "Domaine",
|
||||||
values = "Eleve",
|
values = "Eleve",
|
||||||
aggfunc = len,
|
aggfunc = len,
|
||||||
fill_value = 0,
|
fill_value = 0,
|
||||||
)
|
)
|
||||||
return self._pies_on_domaine
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def radar_on_competence(self):
|
def radar_on_competence(self):
|
||||||
""" Radar plot on competence """
|
""" Radar plot on competence """
|
||||||
try:
|
return radar_on(self.quest_df,
|
||||||
self._radar_on_competence
|
|
||||||
except AttributeError:
|
|
||||||
self._radar_on_competence = radar_on(self.quest_df,
|
|
||||||
"Competence")
|
"Competence")
|
||||||
return self._radar_on_competence
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def radar_on_domaine(self):
|
def radar_on_domaine(self):
|
||||||
""" Radar plot on domaine """
|
""" Radar plot on domaine """
|
||||||
try:
|
return radar_on(self.quest_df,
|
||||||
self._radar_on_domaine
|
|
||||||
except AttributeError:
|
|
||||||
self._radar_on_domaine = radar_on(self.quest_df,
|
|
||||||
"Domaine")
|
"Domaine")
|
||||||
return self._radar_on_domaine
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def heatmap_on_domain(self):
|
def heatmap_on_domain(self):
|
||||||
""" Heatmap over evals on domains """
|
""" Heatmap over evals on domains """
|
||||||
try:
|
|
||||||
self._heatmap_on_domain
|
|
||||||
except AttributeError:
|
|
||||||
comp = pd.pivot_table(self.quest_df,
|
comp = pd.pivot_table(self.quest_df,
|
||||||
index = "Competence",
|
index = "Competence",
|
||||||
columns = ["Exercice", "Question"],
|
columns = ["Exercice", "Question"],
|
||||||
@ -162,8 +143,7 @@ class Student(object):
|
|||||||
aggfunc = np.mean,
|
aggfunc = np.mean,
|
||||||
)
|
)
|
||||||
comp.columns = [f"{i['Exercice']} {i['Question']}" for _,i in self.quest_df[["Exercice", "Question"]].drop_duplicates().iterrows()]
|
comp.columns = [f"{i['Exercice']} {i['Question']}" for _,i in self.quest_df[["Exercice", "Question"]].drop_duplicates().iterrows()]
|
||||||
self._heatmap_on_domain = sns.heatmap(comp)
|
return sns.heatmap(comp)
|
||||||
return self._heatmap_on_domain
|
|
||||||
|
|
||||||
class Classe(object):
|
class Classe(object):
|
||||||
|
|
||||||
@ -201,18 +181,11 @@ class Classe(object):
|
|||||||
@property
|
@property
|
||||||
def hist_boxplot(self):
|
def hist_boxplot(self):
|
||||||
""" Marks histogram and associed box plot """
|
""" Marks histogram and associed box plot """
|
||||||
try:
|
return hist_boxplot(self.eval_df)
|
||||||
self._hist_boxplot
|
|
||||||
except AttributeError:
|
|
||||||
self._hist_boxplot = hist_boxplot(self.eval_df)
|
|
||||||
return self._hist_boxplot
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def level_heatmap(self):
|
def level_heatmap(self):
|
||||||
""" Heapmap on acheivement level """
|
""" Heapmap on acheivement level """
|
||||||
try:
|
|
||||||
self._level_heatmap
|
|
||||||
except AttributeError:
|
|
||||||
pv = pd.pivot_table(self.quest_df,
|
pv = pd.pivot_table(self.quest_df,
|
||||||
index = "Eleve",
|
index = "Eleve",
|
||||||
columns = ["Exercice", "Question", "Commentaire"],
|
columns = ["Exercice", "Question", "Commentaire"],
|
||||||
@ -232,14 +205,14 @@ class Classe(object):
|
|||||||
|
|
||||||
pv.columns = [f"{i[3]:.15} {i[1]} {i[2]}" for i in pv.columns.get_values()]
|
pv.columns = [f"{i[3]:.15} {i[1]} {i[2]}" for i in pv.columns.get_values()]
|
||||||
|
|
||||||
self._level_heatmap = sns.heatmap(pv.T)
|
level_heatmap = sns.heatmap(pv.T)
|
||||||
|
|
||||||
self._level_heatmap.hlines(exercice_sep,
|
level_heatmap.hlines(exercice_sep,
|
||||||
*self._level_heatmap.get_xlim(),
|
*self._level_heatmap.get_xlim(),
|
||||||
colors = "orange",
|
colors = "orange",
|
||||||
)
|
)
|
||||||
|
return level_heatmap
|
||||||
|
|
||||||
return self._level_heatmap
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pies_eff_pts_on_competence(self):
|
def pies_eff_pts_on_competence(self):
|
||||||
|
@ -53,59 +53,52 @@ class Student(object):
|
|||||||
@property
|
@property
|
||||||
def pies_on_competence(self):
|
def pies_on_competence(self):
|
||||||
""" Pies chart on competences """
|
""" Pies chart on competences """
|
||||||
try:
|
return pie_pivot_table(self.quest_df,
|
||||||
self._pies_on_competence
|
|
||||||
except AttributeError:
|
|
||||||
self._pies_on_competence = pie_pivot_table(self.quest_df,
|
|
||||||
index = "Level",
|
index = "Level",
|
||||||
columns = "Competence",
|
columns = "Competence",
|
||||||
values = "Eleve",
|
values = "Eleve",
|
||||||
aggfunc = len,
|
aggfunc = len,
|
||||||
fill_value = 0,
|
fill_value = 0,
|
||||||
)
|
)
|
||||||
return self._pies_on_competence
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pies_on_domaine(self):
|
def pies_on_domaine(self):
|
||||||
""" Pies chart on domaines """
|
""" Pies chart on domaines """
|
||||||
try:
|
return pie_pivot_table(self.quest_df,
|
||||||
self._pies_on_domaine
|
|
||||||
except AttributeError:
|
|
||||||
self._pies_on_domaine = pie_pivot_table(self.quest_df,
|
|
||||||
index = "Level",
|
index = "Level",
|
||||||
columns = "Domaine",
|
columns = "Domaine",
|
||||||
values = "Eleve",
|
values = "Eleve",
|
||||||
aggfunc = len,
|
aggfunc = len,
|
||||||
fill_value = 0,
|
fill_value = 0,
|
||||||
)
|
)
|
||||||
return self._pies_on_domaine
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def radar_on_competence(self):
|
def radar_on_competence(self):
|
||||||
""" Radar plot on competence """
|
""" Radar plot on competence """
|
||||||
try:
|
return radar_on(self.quest_df,
|
||||||
self._radar_on_competence
|
|
||||||
except AttributeError:
|
|
||||||
self._radar_on_competence = radar_on(self.quest_df,
|
|
||||||
"Competence")
|
"Competence")
|
||||||
return self._radar_on_competence
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def radar_on_domaine(self):
|
def radar_on_domaine(self):
|
||||||
""" Radar plot on domaine """
|
""" Radar plot on domaine """
|
||||||
try:
|
return radar_on(self.quest_df,
|
||||||
self._radar_on_domaine
|
|
||||||
except AttributeError:
|
|
||||||
self._radar_on_domaine = radar_on(self.quest_df,
|
|
||||||
"Domaine")
|
"Domaine")
|
||||||
return self._radar_on_domaine
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def heatmap_on_domain(self):
|
def heatmap_on_domain(self):
|
||||||
""" Heatmap over evals on domains """
|
""" Heatmap over evals on domains """
|
||||||
try:
|
comp = pd.pivot_table(self.quest_df,
|
||||||
self._heatmap_on_domain
|
index = "Domaine",
|
||||||
except AttributeError:
|
columns = ["Date","Nom"],
|
||||||
|
values = ["Normalized"],
|
||||||
|
aggfunc = np.mean,
|
||||||
|
)
|
||||||
|
comp.columns = [i[1].strftime("%Y-%m-%d") + "\n" + i[2] for i in comp.columns]
|
||||||
|
return sns.heatmap(comp)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def heatmap_on_competence(self):
|
||||||
|
""" Heatmap over evals on competences """
|
||||||
comp = pd.pivot_table(self.quest_df,
|
comp = pd.pivot_table(self.quest_df,
|
||||||
index = "Competence",
|
index = "Competence",
|
||||||
columns = ["Date","Nom"],
|
columns = ["Date","Nom"],
|
||||||
@ -113,9 +106,7 @@ class Student(object):
|
|||||||
aggfunc = np.mean,
|
aggfunc = np.mean,
|
||||||
)
|
)
|
||||||
comp.columns = [i[1].strftime("%Y-%m-%d") + "\n" + i[2] for i in comp.columns]
|
comp.columns = [i[1].strftime("%Y-%m-%d") + "\n" + i[2] for i in comp.columns]
|
||||||
self._heatmap_on_domain = sns.heatmap(comp)
|
return sns.heatmap(comp)
|
||||||
return self._heatmap_on_domain
|
|
||||||
|
|
||||||
|
|
||||||
def parallel_on_evals(self, classe_evals):
|
def parallel_on_evals(self, classe_evals):
|
||||||
""" Parallel coordinate plot of the class with student line highlight """
|
""" Parallel coordinate plot of the class with student line highlight """
|
||||||
|
Loading…
Reference in New Issue
Block a user