PSLmodels / OG-Core

An overlapping generations model framework for evaluating fiscal policies.
https://pslmodels.github.io/OG-Core/
Creative Commons Zero v1.0 Universal
68 stars 119 forks source link

Fix to `demographics.py` for case of no token prompt #938

Closed jdebacker closed 5 months ago

jdebacker commented 5 months ago

This PR fixes an issue with the recently updated demographics.py. When working with the module directly, users were prompted for a token. But when this function is called through other packages, this prompt doesn't seem to always appear. In case that happens, a try and except statement has been added so that even if the input prompt is not given, you the demographics still runs, resorting the the Population-Data repo.

In addition, a new utility is added that allows users to dump all the parameters from an instance of the Specifications class object into a JSON string. Among other uses, this makes it easy to create JSON files for the default parameters of different calibrations of OG-Core.

codecov-commenter commented 5 months ago

Codecov Report

Attention: Patch coverage is 83.33333% with 4 lines in your changes missing coverage. Please review.

Project coverage is 71.93%. Comparing base (4e6ae04) to head (7255bbe).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/PSLmodels/OG-Core/pull/938/graphs/tree.svg?width=650&height=150&src=pr&token=98mQCVhspd&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels)](https://app.codecov.io/gh/PSLmodels/OG-Core/pull/938?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels) ```diff @@ Coverage Diff @@ ## master #938 +/- ## ========================================== + Coverage 71.92% 71.93% +0.01% ========================================== Files 19 19 Lines 4716 4725 +9 ========================================== + Hits 3392 3399 +7 - Misses 1324 1326 +2 ``` | [Flag](https://app.codecov.io/gh/PSLmodels/OG-Core/pull/938/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/PSLmodels/OG-Core/pull/938/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels) | `71.93% <83.33%> (+0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/PSLmodels/OG-Core/pull/938?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels) | Coverage Δ | | |---|---|---| | [ogcore/\_\_init\_\_.py](https://app.codecov.io/gh/PSLmodels/OG-Core/pull/938?src=pr&el=tree&filepath=ogcore%2F__init__.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels#diff-b2djb3JlL19faW5pdF9fLnB5) | `100.00% <100.00%> (ø)` | | | [ogcore/parameters.py](https://app.codecov.io/gh/PSLmodels/OG-Core/pull/938?src=pr&el=tree&filepath=ogcore%2Fparameters.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels#diff-b2djb3JlL3BhcmFtZXRlcnMucHk=) | `84.30% <100.00%> (ø)` | | | [ogcore/utils.py](https://app.codecov.io/gh/PSLmodels/OG-Core/pull/938?src=pr&el=tree&filepath=ogcore%2Futils.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels#diff-b2djb3JlL3V0aWxzLnB5) | `86.49% <93.33%> (-0.05%)` | :arrow_down: | | [ogcore/demographics.py](https://app.codecov.io/gh/PSLmodels/OG-Core/pull/938?src=pr&el=tree&filepath=ogcore%2Fdemographics.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=PSLmodels#diff-b2djb3JlL2RlbW9ncmFwaGljcy5weQ==) | `56.97% <50.00%> (+0.08%)` | :arrow_up: |
rickecon commented 5 months ago

@jdebacker. Awesome.