From 15a59749505b685ff915c1ed3f8b319ede4f7b5d Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Tue, 15 Feb 2022 13:30:22 +0100 Subject: [PATCH] Revert "Fix: calcul moy. gen. classique si aucun coef (mauvaise gestion du NaN)." This reverts commit 15aa786ddb7b91aac27f508d36acca24aefd2750. --- app/comp/moy_ue.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/comp/moy_ue.py b/app/comp/moy_ue.py index e4aac335..b0a534e5 100644 --- a/app/comp/moy_ue.py +++ b/app/comp/moy_ue.py @@ -38,8 +38,8 @@ from app.comp import moy_mod from app.models.formsemestre import FormSemestre from app.scodoc import sco_codes_parcours from app.scodoc import sco_preferences -from app.scodoc.sco_codes_parcours import NOTES_TOLERANCE, UE_SPORT -from app.scodoc.sco_utils import NOTES_PRECISION, ModuleType +from app.scodoc.sco_codes_parcours import UE_SPORT +from app.scodoc.sco_utils import ModuleType def df_load_module_coefs(formation_id: int, semestre_idx: int = None) -> pd.DataFrame: @@ -358,12 +358,10 @@ def compute_ue_moys_classic( ) # nb_ue x nb_etuds x nb_mods : coefs prenant en compte NaN et inscriptions coefs = (modimpl_coefs_etuds_no_nan_stacked * ue_modules).swapaxes(1, 2) - # Ici c'est une division apr un scalaire, pas NumPy: il faut tester - sum_coefs = np.sum(coefs, axis=2) - if abs(sum_coefs) > NOTES_PRECISION: - etud_moy_ue = (np.sum(coefs * sem_matrix_inscrits, axis=2) / sum_coefs).T - else: - etud_moy_ue = np.nan + with np.errstate(invalid="ignore"): # ignore les 0/0 (-> NaN) + etud_moy_ue = ( + np.sum(coefs * sem_matrix_inscrits, axis=2) / np.sum(coefs, axis=2) + ).T etud_moy_ue_df = pd.DataFrame( etud_moy_ue, index=modimpl_inscr_df.index, columns=[ue.id for ue in ues] )