Skip to content

Commit

Permalink
Change if to where
Browse files Browse the repository at this point in the history
  • Loading branch information
vahid-ahmadi committed Jan 14, 2025
1 parent cf7f6e6 commit d4ff3b2
Showing 1 changed file with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,21 @@ def formula(benunit, period, parameters):
meets_age_condition & meets_income_condition & childcare_eligible
)

# Determine the maximum eligible childcare cost for a single child
max_amount = 0
# Calculate maximum eligible childcare cost using vectorized operations
child_mask = benunit.members("is_child", period)
for member in benunit.members:
disabled = benunit.members("is_disabled", period)[member]
max_amount = where(
child_mask[member],
disabled = benunit.members("is_disabled", period)
max_amount = where(
child_mask,
where(
is_eligible,
where(
is_eligible,
where(
disabled,
p.disabled_child.values,
p.standard_child.values,
),
max_amount,
disabled,
p.disabled_child.values,
p.standard_child.values,
),
max_amount,
)
0,
),
0,
).max(axis=0)

return where(is_eligible, max_amount, 0)

0 comments on commit d4ff3b2

Please sign in to comment.