2024-03-07 19:41:30 +01:00
|
|
|
"""
|
|
|
|
Test calcul moyennes pour les poursuites d'études
|
|
|
|
"""
|
|
|
|
import numpy as np
|
2024-03-13 11:20:33 +01:00
|
|
|
import pytest
|
|
|
|
|
2024-03-07 19:41:30 +01:00
|
|
|
from tests.unit import setup
|
|
|
|
|
|
|
|
from app import db
|
|
|
|
|
|
|
|
import app.pe.moys.pe_rcstag as pe_rcstag
|
|
|
|
|
|
|
|
|
2024-03-13 11:20:33 +01:00
|
|
|
@pytest.mark.parametrize(
|
|
|
|
"notes_S1, notes_S2, coeffs_S1, coeffs_S2, "
|
|
|
|
"coeffs_rcues_S1, coeffs_rcues_S2, inscr_S1, inscr_S2,"
|
|
|
|
"moyenne, coeffs_aggreges",
|
|
|
|
[
|
|
|
|
pytest.param(
|
|
|
|
[17.0, 15.0, 12.0],
|
|
|
|
[16.0, 14.0, 13.0], # notes
|
|
|
|
[1.0, 2.0, 3.0],
|
|
|
|
[4.0, 5.0, 6.0], # coeffs moy gen
|
|
|
|
[2.0, 4.0, 6.0],
|
|
|
|
[8.0, 10.0, 12.0], # coeffs recus
|
|
|
|
[1.0, 1.0, 1.0],
|
|
|
|
[1.0, 1.0, 1.0], # inscr
|
|
|
|
[
|
|
|
|
(17.0 * 2.0 + 16.0 * 8.0) / (2.0 + 8.0),
|
|
|
|
(15.0 * 4.0 + 14.0 * 10.0) / (4.0 + 10.0),
|
|
|
|
(12.0 * 6.0 + 13.0 * 12.0) / (6.0 + 12.0),
|
|
|
|
],
|
|
|
|
[1.0 + 4.0, 2.0 + 5.0, 3.0 + 6.0],
|
|
|
|
id="etudiant_parfait",
|
|
|
|
),
|
|
|
|
pytest.param(
|
|
|
|
[17.0, 15.0, 12.0],
|
|
|
|
[16.0, 14.0, 13.0], # notes
|
|
|
|
[1.0, 2.0, 3.0],
|
|
|
|
[4.0, 5.0, 6.0], # coeffs moy gen
|
|
|
|
[2.0, 4.0, 6.0],
|
|
|
|
[8.0, 10.0, 12.0], # coeffs recus
|
|
|
|
[np.nan, 1.0, np.nan],
|
|
|
|
[1.0, np.nan, np.nan], # inscr
|
|
|
|
[
|
|
|
|
(16.0 * 8.0) / (8.0),
|
|
|
|
(15.0 * 4.0) / (4.0),
|
|
|
|
np.nan,
|
|
|
|
],
|
|
|
|
[4.0, 2.0, np.nan],
|
|
|
|
id="etudiant_non_inscrit",
|
|
|
|
),
|
|
|
|
pytest.param(
|
|
|
|
[0.0, 15.0, 0.0],
|
|
|
|
[0.0, 0.0, 0.0], # notes
|
|
|
|
[1.0, 2.0, 3.0],
|
|
|
|
[4.0, 5.0, 6.0], # coeffs moy gen
|
|
|
|
[2.0, 4.0, 6.0],
|
|
|
|
[8.0, 10.0, 12.0], # coeffs recus
|
|
|
|
[np.nan, 1.0, 1.0],
|
|
|
|
[1.0, np.nan, 1.0], # inscr
|
|
|
|
[0.0, 15.0, 0.0],
|
|
|
|
[4.0, 2.0, 3.0 + 6.0],
|
|
|
|
id="etudiant_avec_0",
|
|
|
|
),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
def test_compute_moyennes_par_RCS(
|
|
|
|
notes_S1,
|
|
|
|
notes_S2,
|
|
|
|
coeffs_S1,
|
|
|
|
coeffs_S2,
|
|
|
|
coeffs_rcues_S1,
|
|
|
|
coeffs_rcues_S2,
|
|
|
|
inscr_S1,
|
|
|
|
inscr_S2,
|
|
|
|
moyenne,
|
|
|
|
coeffs_aggreges,
|
|
|
|
):
|
|
|
|
"""Test de pe_rcstag.compute_moyennes_par_RCS"""
|
|
|
|
notes_cube = np.stack([np.array([notes_S1]), np.array([notes_S2])], axis=-1)
|
|
|
|
# Vérifie les dimensions
|
|
|
|
dim1, dim2, dim3 = notes_cube.shape
|
|
|
|
assert dim1 == 1, "La dim 0 doit être le nombre d'étudiants"
|
|
|
|
assert dim2 == 3, "La dim 1 doit être le nombre d'UEs/Compétences"
|
|
|
|
assert dim3 == 2, "La dim 2 doit être le nombre de semestres"
|
|
|
|
|
|
|
|
coeffs_cube = np.stack([np.array([coeffs_S1]), np.array([coeffs_S2])], axis=-1)
|
|
|
|
coeffs_rcue_cube = np.stack(
|
|
|
|
[np.array([coeffs_rcues_S1]), np.array([coeffs_rcues_S2])], axis=-1
|
|
|
|
)
|
|
|
|
inscr_cube = np.stack([np.array([inscr_S1]), np.array([inscr_S2])], axis=-1)
|
|
|
|
moys, coeffs = pe_rcstag.compute_moyennes_par_RCS(
|
|
|
|
notes_cube, coeffs_cube, coeffs_rcue_cube, inscr_cube
|
|
|
|
)
|
|
|
|
|
|
|
|
moy_resultat = np.array([moyenne])
|
|
|
|
assert (
|
|
|
|
(moys == moy_resultat) | (np.isnan(moys) & np.isnan(moy_resultat))
|
|
|
|
).all(), "Moyenne erronée"
|
|
|
|
coeffs_resultat = np.array([coeffs_aggreges])
|
|
|
|
assert (
|
|
|
|
(coeffs == coeffs_resultat) | (np.isnan(coeffs) & np.isnan(coeffs_resultat))
|
|
|
|
).all(), "Coeffs (pour moyenne générale sur toutes les UE) erronés"
|