Skip to content

Commit

Permalink
Fix basic income child age bug (#775)
Browse files Browse the repository at this point in the history
* Add failing unit test

* Fix test

* Versioning
  • Loading branch information
nikhilwoodruff authored Oct 27, 2023
1 parent 66728c0 commit 4873f75
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
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:
- Bug causing child minimum basic income ages to function incorrectly when the adult UBI is nonzero.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- name: Minimum child age functions correctly when adult is non zero.
period: 2021
input:
gov.contrib.ubi_center.basic_income.amount.child_min_age: 16
gov.contrib.ubi_center.basic_income.amount.by_age.working_age: 1
people:
child:
age: 14
output:
basic_income: 0
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ def formula(person, period, parameters):
is_child_for_bi = (age < bi.amount.adult_age) * (
age >= bi.amount.child_min_age
)
is_adult_for_bi = (age >= bi.amount.adult_age) * ~is_senior_for_bi
weekly_amount_by_age = select(
[is_child_for_bi, is_senior_for_bi],
[bi.amount.by_age.child, bi.amount.by_age.senior],
default=bi.amount.by_age.working_age,
[is_child_for_bi, is_senior_for_bi, is_adult_for_bi],
[
bi.amount.by_age.child,
bi.amount.by_age.senior,
bi.amount.by_age.working_age,
],
)
return (weekly_flat_amount + weekly_amount_by_age) * WEEKS_IN_YEAR

0 comments on commit 4873f75

Please sign in to comment.