Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix invalid value error in weekly_hours_worked file by using np.divide #5505

Merged
merged 10 commits into from
Jan 27, 2025
4 changes: 4 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- bump: patch
changes:
fixed:
- Invalid value encountered when dividing income_effect by original_earnings in weekly hours worked calculation
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@
if (lsr != 0).any():
income_effect = person("income_elasticity_lsr", period)
else:
income_effect = 0
income_effect = np.zeros_like(original)

Check warning on line 38 in policyengine_us/variables/household/income/person/weekly_hours_worked.py

View check run for this annotation

Codecov / codecov/patch

policyengine_us/variables/household/income/person/weekly_hours_worked.py#L38

Added line #L38 was not covered by tests
original_emp = person("employment_income_before_lsr", period)
original_self_emp = person("self_employment_income_before_lsr", period)
original_earnings = original_emp + original_self_emp
lsr_relative_change = np.where(
original_earnings == 0, 0, income_effect / original_earnings
lsr_relative_change = np.divide(

Check warning on line 42 in policyengine_us/variables/household/income/person/weekly_hours_worked.py

View check run for this annotation

Codecov / codecov/patch

policyengine_us/variables/household/income/person/weekly_hours_worked.py#L42

Added line #L42 was not covered by tests
income_effect,
original_earnings,
# Assign no LSR change to people with no original earnings to avoid dividing by zero.
out=np.zeros_like(income_effect, dtype=np.float32),
where=original_earnings != 0,
)
return original * lsr_relative_change

Expand Down
Loading