From 0e9202a9defe168bac978f1f301a073e57630373 Mon Sep 17 00:00:00 2001 From: Tom Andersson Date: Sun, 20 Oct 2024 15:52:38 +0100 Subject: [PATCH] Add forecast error to unit test --- tests/test_model.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_model.py b/tests/test_model.py index f418f7c8..37bb0ff4 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -684,7 +684,12 @@ def test_forecasting_model_predict_return_valid_times(self): pred_var = pred[self.var_ID] - if isinstance(pred_var, pd.DataFrame): + if isinstance(pred_var, xr.Dataset): + # Check we can compute errors using the valid time coord ('time') + errors = pred_var["mean"] - self.da.sel(time=pred_var.time) + assert errors.dims == ("lead_time", "init_time", "x1", "x2") + assert errors.shape == pred_var.shape + elif isinstance(pred_var, pd.DataFrame): # Makes coordinate checking easier by avoiding repeat values pred_var = pred_var.to_xarray().isel(x1=0, x2=0)