Fix: calculs si aucun module

This commit is contained in:
Emmanuel Viennet 2022-02-10 22:19:15 +01:00
parent 9f8bfd3e21
commit 3dfb6f07bd
3 changed files with 22 additions and 5 deletions

View File

@ -87,6 +87,8 @@ class BonusSport:
for m in formsemestre.modimpls_sorted for m in formsemestre.modimpls_sorted
] ]
) )
if not len(modimpl_mask):
modimpl_mask = np.s_[:] # il n'y a rien, on prend tout donc rien
self.modimpls_spo = [ self.modimpls_spo = [
modimpl modimpl
for i, modimpl in enumerate(formsemestre.modimpls_sorted) for i, modimpl in enumerate(formsemestre.modimpls_sorted)
@ -134,6 +136,9 @@ class BonusSport:
modimpl_inscr_spo, sem_modimpl_moys_no_nan, 0.0 modimpl_inscr_spo, sem_modimpl_moys_no_nan, 0.0
) )
modimpl_coefs_spo = modimpl_coefs_spo.T modimpl_coefs_spo = modimpl_coefs_spo.T
if nb_etuds == 0:
modimpl_coefs_etuds = modimpl_inscr_spo # vide
else:
modimpl_coefs_etuds = np.where( modimpl_coefs_etuds = np.where(
modimpl_inscr_spo, np.stack([modimpl_coefs_spo] * nb_etuds), 0.0 modimpl_inscr_spo, np.stack([modimpl_coefs_spo] * nb_etuds), 0.0
) )

View File

@ -310,6 +310,15 @@ def compute_ue_moys_classic(
les coefficients effectifs de chaque UE pour chaque étudiant les coefficients effectifs de chaque UE pour chaque étudiant
(sommes de coefs de modules pris en compte) (sommes de coefs de modules pris en compte)
""" """
if not len(modimpl_mask): # aucun module
# etud_moy_gen_s, etud_moy_ue_df, etud_coef_ue_df
return (
pd.Series(
[0.0] * len(modimpl_inscr_df.index), index=modimpl_inscr_df.index
),
pd.DataFrame(),
pd.DataFrame(),
)
# Restreint aux modules sélectionnés: # Restreint aux modules sélectionnés:
sem_matrix = sem_matrix[:, modimpl_mask] sem_matrix = sem_matrix[:, modimpl_mask]
modimpl_inscr = modimpl_inscr_df.values[:, modimpl_mask] modimpl_inscr = modimpl_inscr_df.values[:, modimpl_mask]
@ -415,6 +424,7 @@ def compute_malus(
for m in formsemestre.modimpls_sorted for m in formsemestre.modimpls_sorted
] ]
) )
if len(modimpl_mask):
malus_moys = sem_modimpl_moys[:, modimpl_mask].sum(axis=1) malus_moys = sem_modimpl_moys[:, modimpl_mask].sum(axis=1)
malus[ue.id] = malus_moys malus[ue.id] = malus_moys

View File

@ -209,6 +209,8 @@ def notes_sem_assemble_matrix(modimpls_notes: list[pd.Series]) -> np.ndarray:
(Series rendus par compute_module_moy, index: etud) (Series rendus par compute_module_moy, index: etud)
Resultat: ndarray (etud x module) Resultat: ndarray (etud x module)
""" """
if not len(modimpls_notes):
return np.zeros((0, 0), dtype=float)
modimpls_notes_arr = [s.values for s in modimpls_notes] modimpls_notes_arr = [s.values for s in modimpls_notes]
modimpls_notes = np.stack(modimpls_notes_arr) modimpls_notes = np.stack(modimpls_notes_arr)
# passe de (mod x etud) à (etud x mod) # passe de (mod x etud) à (etud x mod)