1
0
forked from ScoDoc/ScoDoc

Revert "Fix: calcul moy. gen. classique si aucun coef (mauvaise gestion du NaN)."

This reverts commit 15aa786ddb.
This commit is contained in:
Emmanuel Viennet 2022-02-15 13:30:22 +01:00
parent 15aa786ddb
commit 15a5974950

View File

@ -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 NOTES_TOLERANCE, UE_SPORT
from app.scodoc.sco_utils import NOTES_PRECISION, ModuleType
from app.scodoc.sco_codes_parcours import UE_SPORT
from app.scodoc.sco_utils import ModuleType
def df_load_module_coefs(formation_id: int, semestre_idx: int = None) -> pd.DataFrame:
@ -358,12 +358,10 @@ 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)
# 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
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
etud_moy_ue_df = pd.DataFrame(
etud_moy_ue, index=modimpl_inscr_df.index, columns=[ue.id for ue in ues]
)