PolicyEngine / openfisca-tools

Python tools for enhancing OpenFisca country packages.
1 stars 1 forks source link

Add `multiply`, `and_`, and `or_` #12

Closed MaxGhenis closed 2 years ago

MaxGhenis commented 2 years ago

e.g. to replace this:

would_claim_CTC = benunit("would_claim_CTC", period)
claims_legacy_benefits = benunit("claims_legacy_benefits", period)
return would_claim_CTC & claims_legacy_benefits

with this:

return and_(benunit, period, ["would_claim_CTC", "claims_legacy_benefits"])

or if an or condition:

return or_(benunit, period, ["would_claim_CTC", "claims_legacy_benefits"])
nikhilwoodruff commented 2 years ago

Adding all but multiply_ - can we think of an example that wouldn't be covered by and_?

MaxGhenis commented 2 years ago

Not actual policy but something like this (suppose CB is means-tested so the amount is a variable rather than parameter):

total_child_benefit = multiply_(
    benunit,
    period,
    ["child_benefit_eligible", "number_of_children", "child_benefit_amount_per_child"]
)
nikhilwoodruff commented 2 years ago

OK, not sure that specific example works (number of children is probably group-level, amount per child probably person-level) but I've added multiply (as an alias of and_).