diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb2d..966790bff2e 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: patch + changes: + fixed: + - Invalid value when dividing employment_income by total_earnings in marginal tax rate calculation. diff --git a/policyengine_us/variables/household/marginal_tax_rate.py b/policyengine_us/variables/household/marginal_tax_rate.py index fd435b48b51..0c066d88fc4 100644 --- a/policyengine_us/variables/household/marginal_tax_rate.py +++ b/policyengine_us/variables/household/marginal_tax_rate.py @@ -19,9 +19,14 @@ def formula(person, period, parameters): employment_income = person("employment_income", period) self_employment_income = person("self_employment_income", period) total_earnings = employment_income + self_employment_income - emp_self_emp_ratio = where( - total_earnings > 0, employment_income / total_earnings, 1 + + emp_self_emp_ratio = np.divide( + employment_income, + total_earnings, + out=np.ones_like(total_earnings, dtype=np.float32), + where=total_earnings > 0, ) + for adult_index in range(1, 1 + adult_count): alt_sim = sim.get_branch(f"mtr_for_adult_{adult_index}") for variable in sim.tax_benefit_system.variables: