PolicyEngine / openfisca-tools

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

Add mapping logic #50

Closed nikhilwoodruff closed 2 years ago

nikhilwoodruff commented 2 years ago

This ensures IndividualSim.deriv always operates on the given entities correctly.

When using deriv where wrt and target have different entities, you'll need to specify a target entity for at least the wrt variable. For example:

sim = IndividualSim(year=2022)
sim.add_person(name="adult", age=30, employment_income=250 * 12)
sim.add_person(name="child", age=10)
sim.add_spm_unit(
    name="spm_unit", members=["adult", "child"], is_tanf_enrolled=enrolled
)
sim.add_household(
    name="household", members=["adult", "child"], state_code=state_code
)

sim.vary("employment_income", max=1000 * 12, step=120)

sim.deriv("tanf", "employment_income", wrt_target="adult") # <- I've added "adult". I could've instead added "spm_unit".