From 33b5621af74fff4cc31720bdf90996049fd3c99d Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 30 Jun 2022 15:22:53 +0200 Subject: [PATCH] Fix: calcul du malus BUT par UE. Close #417 --- app/comp/moy_ue.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/comp/moy_ue.py b/app/comp/moy_ue.py index df0e1a79d..f1dba24d8 100644 --- a/app/comp/moy_ue.py +++ b/app/comp/moy_ue.py @@ -496,18 +496,25 @@ def compute_malus( """ ues_idx = [ue.id for ue in ues] malus = pd.DataFrame(index=modimpl_inscr_df.index, columns=ues_idx, dtype=float) + + if len(sem_modimpl_moys.shape) > 2: + # BUT: ne retient que la 1er composante du malus qui est scalaire + # au sens ou chaque note de malus n'affecte que la moyenne de l'UE + # de rattachement de son module. + sem_modimpl_moys_scalar = sem_modimpl_moys[:, :, 0] + else: # classic + sem_modimpl_moys_scalar = sem_modimpl_moys for ue in ues: if ue.type != UE_SPORT: modimpl_mask = np.array( [ (m.module.module_type == ModuleType.MALUS) - and (m.module.ue.id == ue.id) + and (m.module.ue.id == ue.id) # UE de rattachement for m in formsemestre.modimpls_sorted ] ) if len(modimpl_mask): - # somme 1er composante du malus qui est scalaire - malus_moys = sem_modimpl_moys[:, modimpl_mask, 0].sum(axis=1) + malus_moys = sem_modimpl_moys_scalar[:, modimpl_mask].sum(axis=1) malus[ue.id] = malus_moys malus.fillna(0.0, inplace=True)