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,68 +102,48 @@ 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
|
index = "Level",
|
||||||
except AttributeError:
|
columns = "Competence",
|
||||||
self._pies_on_competence = pie_pivot_table(self.quest_df,
|
values = "Eleve",
|
||||||
index = "Level",
|
aggfunc = len,
|
||||||
columns = "Competence",
|
fill_value = 0,
|
||||||
values = "Eleve",
|
)
|
||||||
aggfunc = len,
|
|
||||||
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
|
index = "Level",
|
||||||
except AttributeError:
|
columns = "Domaine",
|
||||||
self._pies_on_domaine = pie_pivot_table(self.quest_df,
|
values = "Eleve",
|
||||||
index = "Level",
|
aggfunc = len,
|
||||||
columns = "Domaine",
|
fill_value = 0,
|
||||||
values = "Eleve",
|
)
|
||||||
aggfunc = len,
|
|
||||||
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 = "Competence",
|
||||||
except AttributeError:
|
columns = ["Exercice", "Question"],
|
||||||
comp = pd.pivot_table(self.quest_df,
|
values = ["Normalized"],
|
||||||
index = "Competence",
|
aggfunc = np.mean,
|
||||||
columns = ["Exercice", "Question"],
|
)
|
||||||
values = ["Normalized"],
|
comp.columns = [f"{i['Exercice']} {i['Question']}" for _,i in self.quest_df[["Exercice", "Question"]].drop_duplicates().iterrows()]
|
||||||
aggfunc = np.mean,
|
return sns.heatmap(comp)
|
||||||
)
|
|
||||||
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 self._heatmap_on_domain
|
|
||||||
|
|
||||||
class Classe(object):
|
class Classe(object):
|
||||||
|
|
||||||
@ -201,45 +181,38 @@ 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:
|
pv = pd.pivot_table(self.quest_df,
|
||||||
self._level_heatmap
|
index = "Eleve",
|
||||||
except AttributeError:
|
columns = ["Exercice", "Question", "Commentaire"],
|
||||||
pv = pd.pivot_table(self.quest_df,
|
values = ["Normalized"],
|
||||||
index = "Eleve",
|
aggfunc = "mean",
|
||||||
columns = ["Exercice", "Question", "Commentaire"],
|
)
|
||||||
values = ["Normalized"],
|
|
||||||
aggfunc = "mean",
|
|
||||||
)
|
|
||||||
|
|
||||||
def lines_4_heatmap(c):
|
def lines_4_heatmap(c):
|
||||||
lines = []
|
lines = []
|
||||||
ini = ''
|
ini = ''
|
||||||
for k,v in enumerate(c.labels[1][::-1]):
|
for k,v in enumerate(c.labels[1][::-1]):
|
||||||
if v != ini:
|
if v != ini:
|
||||||
lines.append(k)
|
lines.append(k)
|
||||||
ini = v
|
ini = v
|
||||||
return lines[1:]
|
return lines[1:]
|
||||||
exercice_sep = lines_4_heatmap(pv.columns)
|
exercice_sep = lines_4_heatmap(pv.columns)
|
||||||
|
|
||||||
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,69 +53,60 @@ 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"],
|
||||||
comp = pd.pivot_table(self.quest_df,
|
values = ["Normalized"],
|
||||||
index = "Competence",
|
aggfunc = np.mean,
|
||||||
columns = ["Date","Nom"],
|
)
|
||||||
values = ["Normalized"],
|
comp.columns = [i[1].strftime("%Y-%m-%d") + "\n" + i[2] for i in comp.columns]
|
||||||
aggfunc = np.mean,
|
return sns.heatmap(comp)
|
||||||
)
|
|
||||||
comp.columns = [i[1].strftime("%Y-%m-%d") + "\n" + i[2] for i in comp.columns]
|
|
||||||
self._heatmap_on_domain = sns.heatmap(comp)
|
|
||||||
return self._heatmap_on_domain
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def heatmap_on_competence(self):
|
||||||
|
""" Heatmap over evals on competences """
|
||||||
|
comp = pd.pivot_table(self.quest_df,
|
||||||
|
index = "Competence",
|
||||||
|
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)
|
||||||
|
|
||||||
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