Skip to content

Commit

Permalink
Correct meets_school_meal_categorical_eligibility for vectorized inpu…
Browse files Browse the repository at this point in the history
…ts (#5318)

* fix: Correct meets_school_meal_categorical_eligibility for vectorized inputs

* fix: Refactor formula for meets_school_meal_categorical_eligibility
  • Loading branch information
anth-volk authored Nov 10, 2024
1 parent 3a0cfb8 commit fb94921
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
6 changes: 6 additions & 0 deletions changelog_entry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- bump: patch
changes:
fixed:
- Corrected meets_school_meal_categorical_eligilibity to properly calculate eligibility for vectorized inputs.
added:
- Test for meets_school_meal_categorical_eligibility with vectorized inputs.
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,12 @@
is_head_start_eligible: false
output:
meets_school_meal_categorical_eligibility: false

- name: Vectorized operations
period: 2024
input:
snap: [1, 0, 0, 0, 0, 0, 0, 0]
fdpir: [0, 1, 1, 0, 0, 0, 0, 0]
is_homeless: [False, False, True, True, False, False, False, False]
output:
meets_school_meal_categorical_eligibility: [True, True, True, True, False, False, False, False]
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,4 @@ class meets_school_meal_categorical_eligibility(Variable):
documentation = "Whether this SPM unit is eligible for free school meal via participation in other programs"
definition_period = YEAR
reference = "https://www.law.cornell.edu/cfr/text/7/245.2"

def formula(spm_unit, period, parameters):
p = parameters(period).gov.usda.school_meals
programs = add(spm_unit, period, p.categorical_eligibility)
return np.any(programs)
adds = "gov.usda.school_meals.categorical_eligibility"

0 comments on commit fb94921

Please sign in to comment.