forked from ScoDoc/ScoDoc
Fix: calculs si aucun module
This commit is contained in:
parent
9f8bfd3e21
commit
3dfb6f07bd
@ -87,6 +87,8 @@ class BonusSport:
|
||||
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 = [
|
||||
modimpl
|
||||
for i, modimpl in enumerate(formsemestre.modimpls_sorted)
|
||||
@ -134,9 +136,12 @@ class BonusSport:
|
||||
modimpl_inscr_spo, sem_modimpl_moys_no_nan, 0.0
|
||||
)
|
||||
modimpl_coefs_spo = modimpl_coefs_spo.T
|
||||
modimpl_coefs_etuds = np.where(
|
||||
modimpl_inscr_spo, np.stack([modimpl_coefs_spo] * nb_etuds), 0.0
|
||||
)
|
||||
if nb_etuds == 0:
|
||||
modimpl_coefs_etuds = modimpl_inscr_spo # vide
|
||||
else:
|
||||
modimpl_coefs_etuds = np.where(
|
||||
modimpl_inscr_spo, np.stack([modimpl_coefs_spo] * nb_etuds), 0.0
|
||||
)
|
||||
# Annule les coefs des modules NaN (nb_etuds x nb_mod_sport)
|
||||
modimpl_coefs_etuds_no_nan = np.where(
|
||||
np.isnan(sem_modimpl_moys_spo), 0.0, modimpl_coefs_etuds
|
||||
|
@ -310,6 +310,15 @@ def compute_ue_moys_classic(
|
||||
les coefficients effectifs de chaque UE pour chaque étudiant
|
||||
(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:
|
||||
sem_matrix = sem_matrix[:, modimpl_mask]
|
||||
modimpl_inscr = modimpl_inscr_df.values[:, modimpl_mask]
|
||||
@ -415,8 +424,9 @@ def compute_malus(
|
||||
for m in formsemestre.modimpls_sorted
|
||||
]
|
||||
)
|
||||
malus_moys = sem_modimpl_moys[:, modimpl_mask].sum(axis=1)
|
||||
malus[ue.id] = malus_moys
|
||||
if len(modimpl_mask):
|
||||
malus_moys = sem_modimpl_moys[:, modimpl_mask].sum(axis=1)
|
||||
malus[ue.id] = malus_moys
|
||||
|
||||
malus.fillna(0.0, inplace=True)
|
||||
return malus
|
||||
|
@ -209,6 +209,8 @@ def notes_sem_assemble_matrix(modimpls_notes: list[pd.Series]) -> np.ndarray:
|
||||
(Series rendus par compute_module_moy, index: etud)
|
||||
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 = np.stack(modimpls_notes_arr)
|
||||
# passe de (mod x etud) à (etud x mod)
|
||||
|
Loading…
Reference in New Issue
Block a user