From b501233ba4fb3dc177892479b5c87b0d033f0977 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Wed, 21 Jun 2023 17:25:40 +0200 Subject: [PATCH] Improve critical error handling in moy_ue --- app/comp/moy_ue.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/comp/moy_ue.py b/app/comp/moy_ue.py index 5d6e27b4..30d8466b 100644 --- a/app/comp/moy_ue.py +++ b/app/comp/moy_ue.py @@ -30,6 +30,7 @@ import numpy as np import pandas as pd +import app from app import db from app import models from app.models import ( @@ -167,8 +168,14 @@ def notes_sem_assemble_cube(modimpls_notes: list[pd.DataFrame]) -> np.ndarray: """ assert len(modimpls_notes) modimpls_notes_arr = [df.values for df in modimpls_notes] - modimpls_notes = np.stack(modimpls_notes_arr) - # passe de (mod x etud x ue) à (etud x mod x ue) + try: + modimpls_notes = np.stack(modimpls_notes_arr) + # passe de (mod x etud x ue) à (etud x mod x ue) + except ValueError: + app.critical_error( + f"""notes_sem_assemble_cube: shapes { + ", ".join([x.shape for x in modimpls_notes_arr])}""" + ) return modimpls_notes.swapaxes(0, 1)