From 1458cff95cd5c9b94bc049d96ddf9432070f2764 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Fri, 14 Nov 2025 23:04:10 +0000 Subject: [PATCH] handle empty pps matrix and low C and above for ewi, iwi and cwi --- backend/Funding.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/Funding.py b/backend/Funding.py index be3db0d4..bd4b2edf 100644 --- a/backend/Funding.py +++ b/backend/Funding.py @@ -542,6 +542,8 @@ class Funding: pps = filtered_pps_matrix[filtered_pps_matrix["Measure_Type"] == measure_code] if pps.shape[0] != 1: + if pps.empty and self.starting_sap_band in ["Low_C", "High_C", "Low_B", "High_B", "Low_A", "High_A"]: + return 0 raise ValueError(f"Invalid IWI category: {measure_code}") return pps.squeeze()["Cost Savings"] @@ -554,6 +556,8 @@ class Funding: pps = filtered_pps_matrix[filtered_pps_matrix["Measure_Type"] == measure_code] if pps.shape[0] != 1: + if pps.empty and self.starting_sap_band in ["Low_C", "High_C", "Low_B", "High_B", "Low_A", "High_A"]: + return 0 raise ValueError(f"Invalid EWI category: {measure_code}") return pps.squeeze()["Cost Savings"] @@ -562,6 +566,8 @@ class Funding: pps = filtered_pps_matrix[filtered_pps_matrix["Measure_Type"] == measure_code] if pps.shape[0] != 1: + if pps.empty and self.starting_sap_band in ["Low_C", "High_C", "Low_B", "High_B", "Low_A", "High_A"]: + return 0 raise ValueError(f"Invalid CWI category: {measure_code}") return pps.squeeze()["Cost Savings"]