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

Updates for compatibility with latest OG-Core #54

Merged
merged 41 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2d82183
update with optins to not plot
jdebacker May 2, 2024
8d8a1f9
testing to get rho shape to work
jdebacker May 2, 2024
523db00
add docstrings
jdebacker May 3, 2024
34dd7db
update CI test script
jdebacker May 3, 2024
bb90913
get capital share of income from FRED
jdebacker May 5, 2024
1472642
Update macro_params.py
SeaCelo May 7, 2024
bf76bd6
Merge pull request #1 from SeaCelo/jdebacker-updates_ogcore
jdebacker May 8, 2024
f27dde1
download data
jdebacker May 17, 2024
5ddb060
Merge remote-tracking branch 'origin/updates_for_ogcore' into updates…
jdebacker May 17, 2024
54817f9
only try codecov upload in upstream repo
jdebacker May 17, 2024
96105be
get data to 2100
jdebacker May 17, 2024
6bd7eb2
remove tax func stuff
jdebacker Jun 11, 2024
31cbbca
import requests into macro params
jdebacker Jun 11, 2024
a3e1b1c
use plot path:
jdebacker Jun 11, 2024
a917bb8
remove unused bits from example
jdebacker Jun 11, 2024
d282e75
update path arg
jdebacker Jun 11, 2024
a24aa4d
remvoe old data files
jdebacker Jun 11, 2024
02b57ce
version bump
jdebacker Jun 11, 2024
f017519
remove unused lines
jdebacker Jun 11, 2024
c09d462
add test of macro params
jdebacker Jun 11, 2024
c7c82c7
add note
jdebacker Jun 11, 2024
8d9442e
format
jdebacker Jun 12, 2024
f1a70ee
add tests of input output module
jdebacker Jun 12, 2024
2066ce0
remove unused constant and args
jdebacker Jun 14, 2024
c4cc712
remove unused constant and args
jdebacker Jun 14, 2024
ac1f068
remove unused path constants from income.py
jdebacker Jun 14, 2024
7a54015
remove unused import
jdebacker Jun 14, 2024
716e75d
Updated README.md
rickecon Jun 18, 2024
a20e944
Updated intro.md
rickecon Jun 18, 2024
c528878
Updated environment.yml
rickecon Jun 18, 2024
ea057f4
Updated setup.py
rickecon Jun 18, 2024
aaa4bf9
Updated build_and_test.yml
rickecon Jun 18, 2024
f5687d8
Updated CHANGELOG.md
rickecon Jun 18, 2024
a6e10fe
Updated Makefile
rickecon Jun 18, 2024
d8d1bb5
Updated GH Actions
rickecon Jun 18, 2024
e92f3d4
Black formatted setup.py
rickecon Jun 18, 2024
bd22d18
Added __init__.py file
rickecon Jun 18, 2024
cfa3ff7
Merge pull request #3 from rickecon/jdebacker-updates_for_ogcore
jdebacker Jun 18, 2024
bc97cb5
set tax rates
jdebacker Jun 18, 2024
192bfbb
Merge remote-tracking branch 'origin/updates_for_ogcore' into updates…
jdebacker Jun 18, 2024
0a43488
don't update iit params
jdebacker Jun 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
name: Build and test [Python 3.9, 3.10]

on: [push, pull_request]

name: Build and test
on:
push:
paths:
- '**.yml'
- '**.toml'
- '**.ini'
- '**.py'
- '**.json'
- '**.csv'
- '**.pkl'
pull_request:
paths:
- '**.yml'
- '**.toml'
- '**.ini'
- '**.py'
- '**.json'
- '**.csv'
- '**.pkl'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.9", "3.10"]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.10", "3.11"]

steps:
- name: Checkout
Expand All @@ -17,7 +33,7 @@ jobs:
persist-credentials: false

- name: Setup Miniconda using Python ${{ matrix.python-version }}
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
auto-update-conda: true
Expand All @@ -30,18 +46,18 @@ jobs:
shell: bash -l {0}
run: |
pip install -e .
pip install pytest-cov
pip install pytest-pycodestyle
- name: Test
shell: bash -l {0}
working-directory: ./
run: |
pytest -m 'not local' --cov=./ --cov-report=xml
python -m pytest -m 'not local' --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
if: matrix.os == 'ubuntu-latest' && contains(github.repository, 'EAPD-DRB/OG-ZAF')
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml
flags: unittests
name: codecov-umbrella
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
verbose: true
13 changes: 11 additions & 2 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ on:
push:
branches:
- main
paths:
- './docs/**.png'
- './docs/book/content/calibration/images/**.png'
- './docs/README.md'
- './docs/book/**.yml'
- './docs/book/**.bib'
- '**.md'
- './docs/book/content/api/**.rst'
- './ogzaf/**.py'
jobs:
build-and-deploy:
if: github.repository == 'EAPD-DRB/OG-ZAF'
Expand All @@ -14,12 +23,12 @@ jobs:
persist-credentials: false

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
activate-environment: ogzaf-dev
environment-file: environment.yml
python-version: "3.10"
python-version: "3.11"
auto-activate-base: false

- name: Build # Build Jupyter Book
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/docs_check.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
name: Check that docs build
on: [push, pull_request]
on:
pull_request:
paths:
- './docs/**.png'
- './docs/book/content/calibration/images/**.png'
- './docs/README.md'
- './docs/book/**.yml'
- './docs/book/**.bib'
- '**.md'
- './docs/book/content/api/**.rst'
- './ogzaf/**.py'

jobs:
build:
Expand All @@ -11,12 +21,12 @@ jobs:
persist-credentials: false

- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
activate-environment: ogzaf-dev
environment-file: environment.yml
python-version: "3.10"
python-version: "3.11"
auto-activate-base: false

- name: Build # Build Jupyter Book
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"
- name: Build package
shell: bash -l {0}
run: |
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.2] - 2024-06-18 12:00:00

### Added

- Updates to `Calibration` to work with OG-Core 0.11.10
- Removal of unused lines of code throughout the package


## [0.0.1] - 2023-10-30 8:00:00

### Added
Expand All @@ -24,4 +32,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0



[0.0.2]: https://github.com/EAPD-DRB/OG-ZAF/compare/v0.0.1...v0.0.2
[0.0.1]: https://github.com/EAPD-DRB/OG-ZAF/compare/v0.0.0...v0.0.1
6 changes: 1 addition & 5 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
include ogzaf/data/demographic/un_zaf_deaths.csv
include ogzaf/data/demographic/un_zaf_fert.csv
include ogzaf/data/demographic/un_zaf_infmort.csv
include ogzaf/data/demographic/un_zaf_mort.csv
include ogzaf/data/demographic/un_zaf_pop.csv
include ogzaf/ogzaf_default_parameters.json
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ format:
install:
pip install -e .
test:
pip install pytest-cov
pip install pytest-pycodestyle
pytest -m 'not local' --cov=./ --cov-report=xml
documentation:
jupyter-book clean docs/book
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
| | |
| --- | --- |
| Org | [![United Nations DESA](https://img.shields.io/badge/United%20Nations%20DESA-blue)](https://www.un.org/en/desa) [![PSL cataloged](https://img.shields.io/badge/PSL-cataloged-a0a0a0.svg)](https://www.PSLmodels.org) [![OS License: CC0-1.0](https://img.shields.io/badge/OS%20License-CC0%201.0-yellow)](https://github.com/EAPD-DRB/OG-ZAF/blob/main/LICENSE) |
| Package | [![Python 3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-3917/) [![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-31013/) [![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-3116/) [![PyPI Latest Release](https://img.shields.io/pypi/v/ogzaf.svg)](https://pypi.org/project/ogzaf/) [![PyPI Downloads](https://img.shields.io/pypi/dm/ogzaf.svg?label=PyPI%20downloads)](https://pypi.org/project/ogzaf/) |
| Package | [![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-31013/) [![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-3116/) [![PyPI Latest Release](https://img.shields.io/pypi/v/ogzaf.svg)](https://pypi.org/project/ogzaf/) [![PyPI Downloads](https://img.shields.io/pypi/dm/ogzaf.svg?label=PyPI%20downloads)](https://pypi.org/project/ogzaf/) |
| Testing | ![example event parameter](https://github.com/EAPD-DRB/OG-ZAF/actions/workflows/build_and_test.yml/badge.svg?branch=main) ![example event parameter](https://github.com/EAPD-DRB/OG-ZAF/actions/workflows/deploy_docs.yml/badge.svg?branch=main) ![example event parameter](https://github.com/EAPD-DRB/OG-ZAF/actions/workflows/check_format.yml/badge.svg?branch=main) [![Codecov](https://codecov.io/gh/EAPD-DRB/OG-ZAF/branch/main/graph/badge.svg)](https://codecov.io/gh/EAPD-DRB/OG-ZAF) |

OG-ZAF is an overlapping-generations (OG) model that allows for dynamic general equilibrium analysis of fiscal policy for South Africa. OG-ZAF is built on the OG-Core framework. The model output includes changes in macroeconomic aggregates (GDP, investment, consumption), wages, interest rates, and the stream of tax revenues over time. Regularly updated documentation of the model theory--its output, and solution method--and the Python API is available at https://pslmodels.github.io/OG-Core and documentation of the specific South African calibration of the model will be available soon.
Expand Down
6 changes: 6 additions & 0 deletions docs/book/content/intro/intro.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
(Chap_Intro)=
# OG-ZAF

| | |
| --- | --- |
| Org | [![United Nations DESA](https://img.shields.io/badge/United%20Nations%20DESA-blue)](https://www.un.org/en/desa) [![PSL cataloged](https://img.shields.io/badge/PSL-cataloged-a0a0a0.svg)](https://www.PSLmodels.org) [![OS License: CC0-1.0](https://img.shields.io/badge/OS%20License-CC0%201.0-yellow)](https://github.com/EAPD-DRB/OG-ZAF/blob/main/LICENSE) |
| Package | [![Python 3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-31013/) [![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-3116/) [![PyPI Latest Release](https://img.shields.io/pypi/v/ogzaf.svg)](https://pypi.org/project/ogzaf/) [![PyPI Downloads](https://img.shields.io/pypi/dm/ogzaf.svg?label=PyPI%20downloads)](https://pypi.org/project/ogzaf/) |
| Testing | ![example event parameter](https://github.com/EAPD-DRB/OG-ZAF/actions/workflows/build_and_test.yml/badge.svg?branch=main) ![example event parameter](https://github.com/EAPD-DRB/OG-ZAF/actions/workflows/deploy_docs.yml/badge.svg?branch=main) ![example event parameter](https://github.com/EAPD-DRB/OG-ZAF/actions/workflows/check_format.yml/badge.svg?branch=main) [![Codecov](https://codecov.io/gh/EAPD-DRB/OG-ZAF/branch/main/graph/badge.svg)](https://codecov.io/gh/EAPD-DRB/OG-ZAF) |

[`OG-ZAF`](https://github.com/EAPD-DRB/OG-ZAF) is a package that provides code and data to calibrate an overlapping-generations (OG) model to the economy of South Africa (ZAF), the code of which is hosted on GitHub at https://github.com/EAPD-DRB/OG-ZAF. `OG-ZAF` uses as a dependency the [`OG-Core`](https://pslmodels.github.io/OG-Core/) package, which contains the core theory and logic of a general OG model. The `OG-ZAF` calibration package and the `OG-Core` theory and logic make the model that allows for dynamic general equilibrium analysis of federal fiscal policy in South Africa. The model output focuses on changes in macroeconomic aggregates (GDP, investment, consumption), wages, interest rates, and the stream of tax revenues over time. This documentation of the `OG-ZAF` package contains the following major sections, which are regularly updated.

* Contributing to `OG-ZAF`
Expand Down
12 changes: 6 additions & 6 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ name: ogzaf-dev
channels:
- conda-forge
dependencies:
- python>=3.7.7
- python>=3.7.7, <3.12
- numpy
- setuptools
- wheel
- numba>=0.54
- scipy>=1.7.1
- pandas>=1.2.5
Expand All @@ -14,11 +16,10 @@ dependencies:
- paramtools>=0.15.0
- sphinx>=3.5.4
- sphinx-book-theme>=0.1.3
- pip
- jupyter-book>=0.11.3
- pytest>=6.0
- pytest-pep8
- pytest-cov
- pytest-xdist
- pycodestyle
- pylint
- coverage
- requests
Expand All @@ -28,9 +29,8 @@ dependencies:
- black
- jupyter
- ipython
- setuptools
- pip
- pip:
- jupyter-book>=0.9.1
- openpyxl>=3.1.2
- pandas-datareader
- linecheck
Expand Down
33 changes: 22 additions & 11 deletions examples/run_og_zaf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,26 @@
import json
import time
import copy
import numpy as np

# from taxcalc import Calculator
import matplotlib.pyplot as plt
from ogzaf.calibrate import Calibration
from ogcore.parameters import Specifications
from ogcore import output_tables as ot
from ogcore import output_plots as op
from ogcore.execute import runner
from ogcore.utils import safe_read_pickle
from ogcore.utils import safe_read_pickle, param_dump_json

# Use a custom matplotlib style file for plots
style_file_url = (
"https://raw.githubusercontent.com/PSLmodels/OG-Core/"
+ "master/ogcore/OGcorePlots.mplstyle"
)
plt.style.use(style_file_url)


def main():
# Define parameters to use for multiprocessing
client = Client()
num_workers = min(multiprocessing.cpu_count(), 7)
client = Client(n_workers=num_workers, threads_per_worker=1)
print("Number of workers = ", num_workers)

# Directories to save data
Expand Down Expand Up @@ -54,12 +59,18 @@ def main():
c = Calibration(p)
updated_params = c.get_dict()
p.update_specifications(updated_params)
updated_params_tax = {
"etr_params": (np.ones((1, p.S, 1)) * 0.35).tolist(),
"mtrx_params": (np.ones((1, p.S, 1)) * 0.35).tolist(),
"mtry_params": (np.ones((1, p.S, 1)) * 0.35).tolist(),
}
p.update_specifications(updated_params_tax)
# set tax rates
p.update_specifications(
{
"cit_rate": [[0.27]],
"tax_func_type": "linear",
"age_specific": False,
# "etr_params": [[[0.22]]],
# "mtrx_params": [[[0.31]]],
# "mtry_params": [[[0.25]]],
"tau_c": [[0.15]],
}
)

# Run model
start_time = time.time()
Expand Down
11 changes: 11 additions & 0 deletions ogzaf/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
Specify what is available to import from the ogzaf package.
"""

from ogzaf.calibrate import *
from ogzaf.income import *
from ogzaf.input_output import *
from ogzaf.macro_params import *
from ogzaf.utils import *

__version__ = "0.0.2"
Loading
Loading