From d6a9de93ff80f2cec1d9f874fc0d47ead369be24 Mon Sep 17 00:00:00 2001 From: Anthony Volk Date: Thu, 14 Mar 2024 19:32:48 +0200 Subject: [PATCH] fix: Repair func to find first date to include last piece of hard data --- .../parameters/operations/uprate_parameters.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/policyengine_core/parameters/operations/uprate_parameters.py b/policyengine_core/parameters/operations/uprate_parameters.py index 4802553a..c93c1970 100644 --- a/policyengine_core/parameters/operations/uprate_parameters.py +++ b/policyengine_core/parameters/operations/uprate_parameters.py @@ -84,7 +84,6 @@ def uprate_parameters(root: ParameterNode) -> ParameterNode: # Modify uprating parameter table to accord with cadence uprating_parameter = construct_cadence_uprater(uprating_parameter, cadence_options, uprating_first_date, uprating_last_date) - # Start from the latest value if "start_instant" in meta: last_instant = instant(meta["start_instant"]) @@ -142,15 +141,15 @@ def round_uprated_value(meta: dict, uprated_value: float) -> float: def find_cadence_first(parameter: Parameter, cadence_options: dict) -> Instant: """ - Determine earliest date to begin uprating. This should be the same (month, day) as - the uprating enactment date, but after the most recent non-uprated value + Find last hard value at enactment date. This should be the same (month, day) as + the uprating enactment date, but the last piece of active data in parameter >>> if enactment: "0002-04-01", last param value: "2022-10-01" - "2023-04-01" - >>> if enactment: "0002-04-01", last param value: "2022-02-01" "2022-04-01" + >>> if enactment: "0002-04-01", last param value: "2022-02-01" + "2021-04-01" >>> if enactment: "0002-04-01", last param value: "2022-04-01" - "2023-04-01" + "2022-04-01" """ @@ -182,9 +181,9 @@ def find_cadence_first(parameter: Parameter, cadence_options: dict) -> Instant: newest_param.day < cadence_options["enactment"]["day"] ) ): - cadence_start_year = newest_param.year + cadence_start_year = newest_param.year - 1 else: - cadence_start_year = newest_param.year + 1 + cadence_start_year = newest_param.year # Must pass date as tuple if not a string return instant((