fix(metrics): name the wrapper mock correctly and document NaN r2 with one valid pair (SIENTIAPDE-2215)

This commit is contained in:
PedroHMCosme
2026-10-22 10:57:53 -03:00
parent fcb9bb263b
commit 9fa1430d75
2 changed files with 3 additions and 3 deletions

View File

@@ -358,7 +358,7 @@ class DataManagerRepository(SientiaMonitoring):
behavior, assuming that predictions (y_pred/y_train_pred) are already on the
correct scale for metric calculation (any scaling is handled inside the
model wrapper). Pairs with a NaN target or a NaN prediction are left out of
mse/mae/r2.
mse/mae/r2. With a single valid pair left, r2_val is NaN (R² needs 2 samples).
Args:
tmr: Training result containing:

View File

@@ -343,10 +343,10 @@ def test_compute_regression_metrics_all_nan_pairs_raises():
val_data=pd.DataFrame({'t': [1.0, 2.0]}, index=idx),
y_pred=pd.DataFrame({'p': [np.nan, np.nan]}, index=idx),
)
metadata = MagicMock()
wrapper = MagicMock()
with pytest.raises(ValueError, match='No validation rows with both target and prediction'):
repo.compute_regression_metrics(tmr, metadata)
repo.compute_regression_metrics(tmr, wrapper)
def test_compute_regression_metrics_linear_equation():