-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix invalid value error in weekly_hours_worked file by using np.divide (
#5505) * Fix invalid value error in weekly_hours_workd file by using np.divide with out and where parameters * Made some changes in week hours worked file * Made small changes in changelog entry yaml file * made small changes in changelog entry yaml file and weekly hours worked py file * Added comment in weekly hours worked file * Made change on line 38 of the weekly_hours_worked file. * Added unit tests for the weekly_hours_worked file. * Fixed issue 4890 * Added a unit test for the weekly_hours_worked.py file and resolved issue #4890. * Made changes in unit test weekly_hours_worked.yaml file
- Loading branch information
1 parent
cd7aa1c
commit 3703022
Showing
3 changed files
with
83 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 and dividing substitution_effect by original_earnings in weekly hours worked calculation |
59 changes: 59 additions & 0 deletions
59
policyengine_us/tests/policy/baseline/household/income/person/weekly_hours_worked.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
- name: Weekly hours worked with labor supply response | ||
period: 2022 | ||
input: | ||
weekly_hours_worked_before_lsr: 40 | ||
labor_supply_behavioral_response: 1 | ||
income_elasticity_lsr: 0.1 | ||
substitution_elasticity_lsr: 0.2 | ||
employment_income_before_lsr: 100_000 | ||
self_employment_income_before_lsr: 50_000 | ||
output: | ||
# Calculation steps: | ||
# Total earnings: 100_000 + 50_000 = 150_000 | ||
# weekly_hours_worked_behavioural_response_income_elasticity = 40 * (0.1 / 150_000) | ||
# = 40 * 6.6666667e-07 | ||
# = 2.6666667e-05 | ||
weekly_hours_worked_behavioural_response_income_elasticity: 2.6666667e-05 | ||
|
||
# weekly_hours_worked_behavioural_response_substitution_elasticity = 40 * (0.2 / 150_000) | ||
# = 40 * 1.3333333e-06 | ||
# = 5.3333333e-05 | ||
weekly_hours_worked_behavioural_response_substitution_elasticity: 5.3333333e-05 | ||
|
||
# weekly_hours_worked_behavioural_response = 2.6666667e-05 + 5.3333333e-05 | ||
# = 8.0000000e-05 | ||
weekly_hours_worked_behavioural_response: 8.0000000e-05 | ||
|
||
- name: Weekly hours worked with zero earnings | ||
period: 2022 | ||
input: | ||
weekly_hours_worked_before_lsr: 40 | ||
labor_supply_behavioral_response: 1 | ||
income_elasticity_lsr: 0.1 | ||
substitution_elasticity_lsr: 0.2 | ||
employment_income_before_lsr: 0 | ||
self_employment_income_before_lsr: 0 | ||
output: | ||
# Calculation steps: | ||
# Total earnings: 0 + 0 = 0 | ||
# weekly_hours_worked_behavioural_response_income_elasticity = 0 (division by zero avoided in Python code) | ||
weekly_hours_worked_behavioural_response_income_elasticity: 0 | ||
|
||
# weekly_hours_worked_behavioural_response_substitution_elasticity = 0 (division by zero avoided in Python code) | ||
weekly_hours_worked_behavioural_response_substitution_elasticity: 0 | ||
|
||
# weekly_hours_worked_beha | ||
|
||
- name: Weekly hours worked with zero labor supply response | ||
period: 2022 | ||
input: | ||
weekly_hours_worked_before_lsr: 40 | ||
labor_supply_behavioral_response: 0 # Trigger the condition for np.zeros_like(original) | ||
income_elasticity_lsr: 0.1 | ||
substitution_elasticity_lsr: 0.2 | ||
employment_income_before_lsr: 100_000 | ||
self_employment_income_before_lsr: 50_000 | ||
output: | ||
weekly_hours_worked_behavioural_response_income_elasticity: 0 | ||
weekly_hours_worked_behavioural_response_substitution_elasticity: 0 | ||
weekly_hours_worked_behavioural_response: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters