PolicyEngine / policyengine-api

PolicyEngine's REST API for computing policy impacts.
GNU Affero General Public License v3.0
10 stars 21 forks source link

Mixed-year requests return `nan` #1136

Open MaxGhenis opened 8 months ago

MaxGhenis commented 8 months ago

The below request from MyFriendBen gives a nan. @nikhilwoodruff verified that it works in the Python package, and works when replacing 2023-10 with 2024-01 for snap.

{
    'household': {
        'people': {
            '10221': {
                'is_pregnant': {'2024': False},
                'age': {'2024': 44, '2023': 44},
                'wic': {'2024': None},
                'wic_category': {'2024': None},
                'employment_income': {'2024': 0, '2023': 0},
                'medicaid': {'2024': None},
                'pell_grant_dependent_available_income': {'2024': 0},
                'pell_grant_countable_assets': {'2024': 0},
                'cost_of_attending_college': {'2024': 0},
                'pell_grant_months_in_school': {'2024': 9},
                'is_tax_unit_dependent': {'2024': False, '2023': False},
                'is_tax_unit_head': {'2024': True},
                'is_tax_unit_spouse': {'2024': False, '2023': False},
                'pell_grant': {'2024': None},
                'ssi_countable_resources': {'2024': 0},
                'ssi_reported': {'2024': 0},
                'is_blind': {'2024': False},
                'is_disabled': {'2024': False},
                'ssi_earned_income': {'2024': 0},
                'ssi_unearned_income': {'2024': 0},
                'ssi': {'2024': None},
                'co_state_supplement': {'2024': None},
                'co_oap': {'2024': None},
                'co_chp_eligible': {'2024': None},
            }
        },
        'tax_units': {
            'tax_unit': {
                'members': ['10221'],
                'pell_grant_primary_income': {'2024': 0},
                'pell_grant_dependents_in_college': {'2024': 0},
                'eitc': {'2023': None},
                'co_eitc': {'2023': None},
                'ctc': {'2023': None},
            }
        },
        'families': {'family': {'members': ['10221']}},
        'households': {
            'household': {
                'state_code_str': {'2024': 'CO', '2023': 'CO'},
                'members': ['10221'],
            }
        },
        'spm_units': {
            'spm_unit': {
                'members': ['10221'],
                'broadband_cost': {'2024': 500},
                'acp': {'2024': None},
                'lifeline': {'2024': None},
                'school_meal_daily_subsidy': {'2024': None},
                'school_meal_tier': {'2024': None},
                'snap_child_support_deduction': {'2023': 0.0},
                'snap_gross_income': {'2023': 0},
                'snap_assets': {'2023': 0},
                'meets_snap_categorical_eligibility': {'2023': False},
                'snap_emergency_allotment': {'2023': 0},
                'housing_cost': {'2023': 0},
                'meets_snap_gross_income_test': {'2023': True},
                'has_phone_expense': {'2023': False},
                'has_heating_cooling_expense': {'2023': False},
                'heating_cooling_expense': {'2023': 0.0},
                'electricity_expense': {'2023': 0.0},
                'snap_earned_income': {'2023': 0.0},
                'meets_snap_asset_test': {'2023': True},
                'childcare_expenses': {'2023': 0.0},
                'snap': {'2023-10': None},
                'co_tanf_countable_gross_earned_income': {'2024': 0},
                'co_tanf_countable_gross_unearned_income': {'2024': 0},
                'co_tanf': {'2024': None},
            }
        },
        'marital_units': {},
    }
}
MaxGhenis commented 8 months ago

Also affects tax credits. Seems like the issue is the mixing of 2023 and 2024 in the same request.

{
    'household': {
        'people': {
            '10227': {
                'is_pregnant': {'2024': False},
                'age': {'2024': 44, '2023': 44},
                'wic': {'2024': None},
                'wic_category': {'2024': None},
                'employment_income': {'2024': 0, '2023': 0},
                'medicaid': {'2024': None},
                'pell_grant_dependent_available_income': {'2024': 0},
                'pell_grant_countable_assets': {'2024': 0},
                'cost_of_attending_college': {'2024': 0},
                'pell_grant_months_in_school': {'2024': 9},
                'is_tax_unit_dependent': {'2024': False, '2023': False},
                'is_tax_unit_head': {'2024': True},
                'is_tax_unit_spouse': {'2024': False, '2023': False},
                'pell_grant': {'2024': None},
                'ssi_countable_resources': {'2024': 0},
                'ssi_reported': {'2024': 0},
                'is_blind': {'2024': False},
                'is_disabled': {'2024': False},
                'ssi_earned_income': {'2024': 0},
                'ssi_unearned_income': {'2024': 0},
                'ssi': {'2024': None},
                'co_state_supplement': {'2024': None},
                'co_oap': {'2024': None},
                'co_chp_eligible': {'2024': None},
            }
        },
        'tax_units': {
            'tax_unit': {
                'members': ['10227'],
                'pell_grant_primary_income': {'2024': 0},
                'pell_grant_dependents_in_college': {'2024': 0},
                'eitc': {'2023': None},
                'co_eitc': {'2023': None},
                'ctc': {'2023': None},
            }
        },
        'families': {'family': {'members': ['10227']}},
        'households': {
            'household': {
                'state_code_str': {'2024': 'CO', '2023': 'CO'},
                'members': ['10227'],
            }
        },
        'spm_units': {
            'spm_unit': {
                'members': ['10227'],
                'broadband_cost': {'2024': 500},
                'acp': {'2024': None},
                'lifeline': {'2024': None},
                'school_meal_daily_subsidy': {'2024': None},
                'school_meal_tier': {'2024': None},
                'snap_child_support_deduction': {'2024': 0.0},
                'snap_gross_income': {'2024': 0},
                'snap_assets': {'2024': 0},
                'meets_snap_categorical_eligibility': {'2024': False},
                'snap_emergency_allotment': {'2024': 0},
                'housing_cost': {'2024': 0},
                'meets_snap_gross_income_test': {'2024': True},
                'has_phone_expense': {'2024': False},
                'has_heating_cooling_expense': {'2024': False},
                'heating_cooling_expense': {'2024': 0.0},
                'electricity_expense': {'2024': 0.0},
                'snap_earned_income': {'2024': 0.0},
                'meets_snap_asset_test': {'2024': True},
                'childcare_expenses': {'2024': 0.0},
                'snap_excess_shelter_expense_deduction': {'2024': None},
                'snap': {'2024-01': None},
                'co_tanf_countable_gross_earned_income': {'2024': 0},
                'co_tanf_countable_gross_unearned_income': {'2024': 0},
                'co_tanf': {'2024': None},
            }
        },
        'marital_units': {},
    }
}