Skip to content

Commit

Permalink
fix: Add rounding back into cadence-based uprating
Browse files Browse the repository at this point in the history
  • Loading branch information
anth-volk committed Mar 14, 2024
1 parent e7a4b14 commit e248d42
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions policyengine_core/parameters/operations/uprate_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def uprate_parameters(root: ParameterNode) -> ParameterNode:
# the preceding value
cadence_uprater = construct_cadence_uprater(uprating_parameter, cadence_options, uprating_first_date, uprating_last_date)

uprated_data = uprate_by_cadence(parameter, cadence_uprater, uprating_first_date)
uprated_data = uprate_by_cadence(parameter, cadence_uprater, uprating_first_date, meta)
parameter.values_list.extend(uprated_data)

else:
Expand Down Expand Up @@ -146,7 +146,7 @@ def round_uprated_value(meta: dict, uprated_value: float) -> float:
)
return uprated_value

def uprate_by_cadence(parameter: Parameter, cadence_uprater: Parameter, uprating_first_date: Instant) -> list[ParameterAtInstant]:
def uprate_by_cadence(parameter: Parameter, cadence_uprater: Parameter, uprating_first_date: Instant, meta: dict) -> list[ParameterAtInstant]:

# Pull out the value that occurred most recently in the parameter
# at the enactment month, date; this will be changed in future to support
Expand All @@ -158,6 +158,8 @@ def uprate_by_cadence(parameter: Parameter, cadence_uprater: Parameter, uprating

# Calculate uprated value
uprated_value = uprater_entry.value * reference_value
if "rounding" in meta:
uprated_value = round_uprated_value(meta, uprated_value)

Check warning on line 162 in policyengine_core/parameters/operations/uprate_parameters.py

View check run for this annotation

Codecov / codecov/patch

policyengine_core/parameters/operations/uprate_parameters.py#L162

Added line #L162 was not covered by tests

# Add uprated value to data list
uprated_data.append(
Expand Down

0 comments on commit e248d42

Please sign in to comment.