forked from ScoDoc/ScoDoc
Fix: calcul moy. gen. classique si aucun coef (mauvaise gestion du NaN).
This commit is contained in:
parent
75232a18a3
commit
15aa786ddb
@ -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 UE_SPORT
|
||||
from app.scodoc.sco_utils import ModuleType
|
||||
from app.scodoc.sco_codes_parcours import NOTES_TOLERANCE, UE_SPORT
|
||||
from app.scodoc.sco_utils import NOTES_PRECISION, ModuleType
|
||||
|
||||
|
||||
def df_load_module_coefs(formation_id: int, semestre_idx: int = None) -> pd.DataFrame:
|
||||
@ -358,10 +358,12 @@ 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)
|
||||
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
|
||||
# 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
|
||||
etud_moy_ue_df = pd.DataFrame(
|
||||
etud_moy_ue, index=modimpl_inscr_df.index, columns=[ue.id for ue in ues]
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user