diff --git a/_downloads/621e2c7711e8623173875c33222eddb6/changelog.yaml b/_downloads/621e2c7711e8623173875c33222eddb6/changelog.yaml
index 2785ca88..df487c52 100644
--- a/_downloads/621e2c7711e8623173875c33222eddb6/changelog.yaml
+++ b/_downloads/621e2c7711e8623173875c33222eddb6/changelog.yaml
@@ -619,3 +619,8 @@
removed:
- Removed nptyping, migrated to numpy.typing
date: 2024-08-08 15:16:12
+- bump: patch
+ changes:
+ fixed:
+ - fixed bug where uprating was causing nan.
+ date: 2024-08-08 15:17:05
diff --git a/_modules/policyengine_core/simulations/simulation.html b/_modules/policyengine_core/simulations/simulation.html
index c3bb1d20..41bd5c2a 100644
--- a/_modules/policyengine_core/simulations/simulation.html
+++ b/_modules/policyengine_core/simulations/simulation.html
@@ -907,43 +907,40 @@
Source code for policyengine_core.simulations.simulation
if array is None:
# Check if the variable has a previously defined value
known_periods = holder.get_known_periods()
- if variable.uprating is not None and len(known_periods) > 0:
- start_instants = [
- str(known_period.start)
- for known_period in known_periods
- if known_period.unit == variable.definition_period
- and known_period.start < period.start
+ start_instants = [
+ str(known_period.start)
+ for known_period in known_periods
+ if known_period.unit == variable.definition_period
+ and known_period.start < period.start
+ ]
+ if variable.uprating is not None and len(start_instants) > 0:
+ latest_known_period = known_periods[
+ np.argmax(start_instants)
]
- if len(start_instants) > 0:
- latest_known_period = known_periods[
- np.argmax(start_instants)
- ]
- try:
- uprating_parameter = get_parameter(
- self.tax_benefit_system.parameters,
- variable.uprating,
- )
- except:
- raise ValueError(
- f"Could not find uprating parameter {variable.uprating} when trying to uprate {variable_name}."
- )
- value_in_last_period = uprating_parameter(
- latest_known_period.start
+ try:
+ uprating_parameter = get_parameter(
+ self.tax_benefit_system.parameters,
+ variable.uprating,
)
- value_in_this_period = uprating_parameter(period.start)
- if value_in_last_period == 0:
- uprating_factor = 1
- else:
- uprating_factor = (
- value_in_this_period / value_in_last_period
- )
-
- array = (
- holder.get_array(
- latest_known_period, self.branch_name
- )
- * uprating_factor
+ except:
+ raise ValueError(
+ f"Could not find uprating parameter {variable.uprating} when trying to uprate {variable_name}."
)
+ value_in_last_period = uprating_parameter(
+ latest_known_period.start
+ )
+ value_in_this_period = uprating_parameter(period.start)
+ if value_in_last_period == 0:
+ uprating_factor = 1
+ else:
+ uprating_factor = (
+ value_in_this_period / value_in_last_period
+ )
+
+ array = (
+ holder.get_array(latest_known_period, self.branch_name)
+ * uprating_factor
+ )
elif (
self.tax_benefit_system.auto_carry_over_input_variables
and variable.calculate_output is None