From d0bc842a2a17af4fe7442fce5aa9d3c41ecd00c1 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Thu, 23 Mar 2017 09:23:55 +0300 Subject: [PATCH] Simplify name multiplicy ckeck in Student --- notes_tools/tools/term_tools.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/notes_tools/tools/term_tools.py b/notes_tools/tools/term_tools.py index 7dd984e..14a664a 100644 --- a/notes_tools/tools/term_tools.py +++ b/notes_tools/tools/term_tools.py @@ -25,17 +25,16 @@ class Student(object): 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") - elif len(exo_df["Eleve"].unique()) != 1: - raise ValueError("Can't initiate Student: exo_df contains different student names") - 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 \ - quest_df["Eleve"].iloc[0] != eval_df["Eleve"].iloc[0]: + + name = {*quest_df["Eleve"].unique(), + *exo_df["Eleve"].unique(), + *eval_df["Eleve"].unique(), + } + + if len(name) != 1: 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.exo_df = exo_df @@ -47,8 +46,9 @@ class Student(object): try: self._marks_tabular except AttributeError: - self._marks_tabular = self.eval_df[["Nom", "Mark_barem"]].to_latex() - return self._marks_tabular + self._marks_tabular = self.eval_df[["Nom", "Mark_barem"]] + self._marks_tabular.columns = ["Devoir", "Note"] + return self._marks_tabular.to_latex() @property def pies_on_competence(self):