Simplify name multiplicy ckeck in Student

This commit is contained in:
Benjamin Bertrand 2017-03-23 09:23:55 +03:00
parent 59cd8e2aba
commit d0bc842a2a

View File

@ -25,17 +25,16 @@ class Student(object):
Description of a student from quest, exo and eval Description of a student from quest, exo and eval
""" """
if len(quest_df["Eleve"].unique()) != 1:
raise ValueError("Can't initiate Student: quest_df contains different student names") name = {*quest_df["Eleve"].unique(),
elif len(exo_df["Eleve"].unique()) != 1: *exo_df["Eleve"].unique(),
raise ValueError("Can't initiate Student: exo_df contains different student names") *eval_df["Eleve"].unique(),
elif len(eval_df["Eleve"].unique()) != 1: }
raise ValueError("Can't initiate Student: eval_df contains different student names")
elif quest_df["Eleve"].iloc[0] != exo_df["Eleve"].iloc[0] or \ if len(name) != 1:
quest_df["Eleve"].iloc[0] != eval_df["Eleve"].iloc[0]:
raise ValueError("Can't initiate Student: dfs contains different student names") raise ValueError("Can't initiate Student: dfs contains different student names")
self.name = quest_df["Eleve"].iloc[0] self.name = name.pop()
self.quest_df = quest_df self.quest_df = quest_df
self.exo_df = exo_df self.exo_df = exo_df
@ -47,8 +46,9 @@ class Student(object):
try: try:
self._marks_tabular self._marks_tabular
except AttributeError: except AttributeError:
self._marks_tabular = self.eval_df[["Nom", "Mark_barem"]].to_latex() self._marks_tabular = self.eval_df[["Nom", "Mark_barem"]]
return self._marks_tabular self._marks_tabular.columns = ["Devoir", "Note"]
return self._marks_tabular.to_latex()
@property @property
def pies_on_competence(self): def pies_on_competence(self):