Skip to content

Commit

Permalink
Merge pull request #54 from jdebacker/updates_for_ogcore
Browse files Browse the repository at this point in the history
Merging
  • Loading branch information
rickecon authored Jun 19, 2024
2 parents 0025e6f + 0a43488 commit 8958699
Show file tree
Hide file tree
Showing 24 changed files with 309 additions and 2,017 deletions.
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

0 comments on commit 8958699

Please sign in to comment.