Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrappedJsonParse may be causing an issue with certain reforms #2125

Open
anth-volk opened this issue Oct 22, 2024 · 2 comments
Open

wrappedJsonParse may be causing an issue with certain reforms #2125

anth-volk opened this issue Oct 22, 2024 · 2 comments

Comments

@anth-volk
Copy link
Collaborator

Unclear yet as to what, but if running locally and following the below link, it appears that wrappedJsonParse fails. This is a bit strange, since all it's doing is running JSON.parse(), with an added reviver to convert String-typed "Infinity" into Number-typed Infinity.

https://policyengine.org/us/policy?focus=policyOutput.policyBreakdown&reform=68885&region=enhanced_us&timePeriod=2027&baseline=2

@anth-volk
Copy link
Collaborator Author

Update: The driver of this is that the labor supply response output JSON looks like this:

"labour_supply_response":{

    "decile":{
        "average":{
            "income":{
                "-1":NaN,
                "1":-48.93527871776658,
                "10":NaN,
                "11":-24206.024536132812,
                "2":-37.216324919117525,
                "3":-86.54665984815182,
                "4":-96.5405980100208,
                "5":-56.012575550693974,
                "6":-102.77201754264017,
                "7":-259.22769252592616,
                "8":-203.0575553074983,
                "9":NaN
            },
            "substitution":{
                "-1":NaN,
                "1":-16.772775765148758,
                "10":NaN,
                "11":10033.5498046875,
                "2":135.2102566632799,
                "3":291.95311872481824,
                "4":329.4938602823555,
                "5":544.2274791417112,
                "6":843.8244649543509,
                "7":1135.2899706275562,
                "8":1360.4161738391067,
                "9":NaN
            }
        },
        "relative":{
            "income":{
                "1":-0.00819899891009717,
                "10":-0.0014287310635835839,
                "11":-0.0008203730248428343,
                "2":-0.001921439058765296,
                "3":-0.0028371393053804807,
                "4":-0.002506329162501017,
                "5":-0.0011766715687877645,
                "6":-0.0014595756832002148,
                "7":-0.0029570151845276166,
                "8":-0.0015332458198454061,
                "9":-0.0017363859954538327
            },
            "substitution":{
                "1":-0.002810241891354151,
                "10":0.009497578431097173,
                "11":0.0003400497917737693,
                "2":0.006980760966138592,
                "3":0.009570694812669703,
                "4":0.008554122181892679,
                "5":0.011432736226876709,
                "6":0.011984056549496074,
                "7":0.012950274136517434,
                "8":0.010272222615062025,
                "9":0.01029823076995405
            }
        }
    },

We get an 11th decile (could be fixed by PolicyEngine/microdf#234) and we get NaN values for deciles 1, 9, and 10 of the total average income and substitution effects.

This will almost certainly be either -us or -api. I'll transfer the issue when that becomes clear.

@anth-volk
Copy link
Collaborator Author

Finally got some clarity on this. This may be a -us issue, as even when running the country package locally, household_market_income returns NaN for a small subset of records. This is then scaled up to entire deciles being equal to NaN due to the formulas that are used within the API, and then these deciles are returned as NaN, which JSON has no way of deserializing, causing the front-end crash.

I'll look more into the individual components of household_market_income either Saturday or Sunday and see if I can figure out what's going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

1 participant