PolicyEngine / policyengine-app

PolicyEngine's free web app for computing the impact of public policy.
GNU Affero General Public License v3.0
41 stars 108 forks source link

Default US Python code from Streamlit app fails #246

Open MaxGhenis opened 1 year ago

MaxGhenis commented 1 year ago

After replacing null with None, in both a Colab notebook and local iPython session. UK succeeds.

This is because people needs to be nested in households (thanks for the catch @pavelmakarchuk)

{
    "error": "No household provided.",
    "status": "error"
}

running:

import requests
import json

situation = {
    "people": {
        "parent": {
            "age": {
                "2023": 35
            },
            "employment_income": {
                "2023": 30000
            }
        },
        "child": {
            "age": {
                "2023": 10
            }
        }
    },
    "households": {
        "household": {
            "members": [
                "parent",
                "child"
            ],
            "household_net_income": {
                "2023": None
            },
            "household_benefits": {
                "2023": None
            },
            "household_tax": {
                "2023": None
            }
        }
    }
}
result = requests.post("https://api.policyengine.org/us/calculate", json=situation).json()
print(json.dumps(result, indent=4))
anth-volk commented 11 months ago

Is this still the case?

MaxGhenis commented 11 months ago

Yes. Select the Code snippet tab in the API playground at https://policyengine.org/us/api. This notebook shows it fails.

anth-volk commented 8 months ago

If I change the various null values to None in the Colab link provided in that earlier comment, the notebook actually succeeds, but the result is an empty object.