From b8b3185901d43513dd049acb236d3f7583cd8222 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 17 Jan 2022 00:06:21 +0100 Subject: [PATCH] Traite #276 --- app/comp/moy_ue.py | 18 ++++++++++++------ sco_version.py | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/comp/moy_ue.py b/app/comp/moy_ue.py index a707633fd..44dbe3cfd 100644 --- a/app/comp/moy_ue.py +++ b/app/comp/moy_ue.py @@ -121,6 +121,7 @@ def notes_sem_assemble_cube(modimpls_notes: list[pd.DataFrame]) -> np.ndarray: (DataFrames rendus par compute_module_moy, (etud x UE)) Resultat: ndarray (etud x module x UE) """ + assert len(modimpls_notes) modimpls_notes_arr = [df.values for df in modimpls_notes] modimpls_notes = np.stack(modimpls_notes_arr) # passe de (mod x etud x ue) à (etud x mod x UE) @@ -156,8 +157,13 @@ def notes_sem_load_cube(formsemestre): modimpls_evaluations[modimpl.id] = evaluations modimpls_evaluations_complete[modimpl.id] = evaluations_completes modimpls_notes.append(etuds_moy_module) + if len(modimpls_notes): + cube = notes_sem_assemble_cube(modimpls_notes) + else: + nb_etuds = formsemestre.etuds.count() + cube = np.zeros((nb_etuds, 0, 0), dtype=float) return ( - notes_sem_assemble_cube(modimpls_notes), + cube, modimpls_evals_poids, modimpls_evals_notes, modimpls_evaluations, @@ -191,8 +197,12 @@ def compute_ue_moys( Resultat: DataFrame columns UE, rows etudid """ nb_etuds, nb_modules, nb_ues = sem_cube.shape - assert len(etuds) == nb_etuds assert len(modimpls) == nb_modules + if nb_modules == 0 or nb_etuds == 0: + return pd.DataFrame( + index=modimpl_inscr_df.index, columns=modimpl_coefs_df.index + ) + assert len(etuds) == nb_etuds assert len(ues) == nb_ues assert modimpl_inscr_df.shape[0] == nb_etuds assert modimpl_inscr_df.shape[1] == nb_modules @@ -200,10 +210,6 @@ def compute_ue_moys( assert modimpl_coefs_df.shape[1] == nb_modules modimpl_inscr = modimpl_inscr_df.values modimpl_coefs = modimpl_coefs_df.values - if nb_etuds == 0: - return pd.DataFrame( - index=modimpl_inscr_df.index, columns=modimpl_coefs_df.index - ) # Duplique les inscriptions sur les UEs: modimpl_inscr_stacked = np.stack([modimpl_inscr] * nb_ues, axis=2) # Enlève les NaN du numérateur: diff --git a/sco_version.py b/sco_version.py index 64e77bf1b..cab845d19 100644 --- a/sco_version.py +++ b/sco_version.py @@ -1,7 +1,7 @@ # -*- mode: python -*- # -*- coding: utf-8 -*- -SCOVERSION = "9.1.24" +SCOVERSION = "9.1.25" SCONAME = "ScoDoc"