diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 87111db7..814f1f2b 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -27,7 +27,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] python-version: ["3.10", "3.11"] steps: @@ -35,10 +35,6 @@ jobs: uses: actions/checkout@v4 with: persist-credentials: false - - name: Set up R ${{ matrix.r-version }} - uses: r-lib/actions/setup-r@v2 - with: - r-version: release - name: Setup Miniconda using Python ${{ matrix.python-version }} uses: conda-incubator/setup-miniconda@v3 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a84450a..84791ccb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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.1.10] - 2024-06-10 12:00:00 + +### Added + +- Removes the `rpy2` dependency from the `environment.yml` and `setup.py` files, and modifies use of PSID data to avoid needing this package in OG-USA. + + ## [0.1.9] - 2024-06-07 12:00:00 ### Added @@ -111,6 +119,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 +[0.1.10]: https://github.com/PSLmodels/OG-USA/compare/v0.1.9...v0.1.10 [0.1.9]: https://github.com/PSLmodels/OG-USA/compare/v0.1.8...v0.1.9 [0.1.8]: https://github.com/PSLmodels/OG-USA/compare/v0.1.7...v0.1.8 [0.1.7]: https://github.com/PSLmodels/OG-USA/compare/v0.1.6...v0.1.7 diff --git a/cs-config/cs_config/functions.py b/cs-config/cs_config/functions.py index 064fa946..47365eba 100644 --- a/cs-config/cs_config/functions.py +++ b/cs-config/cs_config/functions.py @@ -1,3 +1,4 @@ +import ogusa from ogusa.calibrate import Calibration from ogcore.parameters import Specifications from ogusa.constants import ( @@ -82,7 +83,7 @@ class MetaParams(paramtools.Parameters): def get_version(): - return "0.1.9" + return ogusa.__version__ def get_inputs(meta_param_dict): diff --git a/data/PSID/psid1968to2015.RData b/data/PSID/psid1968to2015.csv.gz similarity index 59% rename from data/PSID/psid1968to2015.RData rename to data/PSID/psid1968to2015.csv.gz index 06fa28ce..6b77d309 100644 Binary files a/data/PSID/psid1968to2015.RData and b/data/PSID/psid1968to2015.csv.gz differ diff --git a/data/PSID/psid1968to2017.RData b/data/PSID/psid1968to2017.csv.gz similarity index 52% rename from data/PSID/psid1968to2017.RData rename to data/PSID/psid1968to2017.csv.gz index d2220514..3bdc1f58 100644 Binary files a/data/PSID/psid1968to2017.RData and b/data/PSID/psid1968to2017.csv.gz differ diff --git a/data/PSID/psid_download.R b/data/PSID/psid_download.R index 35ac6ce7..73b68c5e 100644 --- a/data/PSID/psid_download.R +++ b/data/PSID/psid_download.R @@ -176,4 +176,5 @@ for (var in names(ind_var_names)){ print('Beginning to build panel') # Build PSID panel psid_df <- build.panel(datadir=mydir, fam.vars=famvars, ind.vars=indvars, sample="SRC", design='all') -save(psid_df,file=file.path(script.dir, 'psid1968to2017.RData')) + +write.csv(psid_df, file=gzfile("psid1968to2017.csv.gz")) diff --git a/environment.yml b/environment.yml index a7cbd2d4..022db456 100644 --- a/environment.yml +++ b/environment.yml @@ -30,7 +30,6 @@ dependencies: - black>=24.1.1 - pip - pip: - - rpy2>=3.5.12 - openpyxl>=3.1.2 - cs-kit - cs2tc diff --git a/ogusa/__init__.py b/ogusa/__init__.py new file mode 100644 index 00000000..bf366028 --- /dev/null +++ b/ogusa/__init__.py @@ -0,0 +1,14 @@ +""" +Specify what is available to import from the ogusa package. +""" + +from ogusa.calibrate import * +from ogusa.bequest_transmission import * +from ogusa.get_micro_data import * +from ogusa.income import * +from ogusa.macro_params import * +from ogusa.transfer_distribution import * +from ogusa.utils import * +from ogusa.wealth import * + +__version__ = "0.1.10" diff --git a/ogusa/psid_data_setup.py b/ogusa/psid_data_setup.py index 1507fb7f..d2c5ac00 100644 --- a/ogusa/psid_data_setup.py +++ b/ogusa/psid_data_setup.py @@ -5,17 +5,9 @@ from pandas_datareader import data as web import datetime from linearmodels import PanelOLS -from rpy2.robjects import r -from rpy2.robjects import conversion -from rpy2.robjects import default_converter -from rpy2.robjects import pandas2ri -from rpy2.robjects.packages import importr from ogusa.constants import PSID_NOMINAL_VARS, PSID_CONSTANT_VARS -pandas2ri.activate() -pd.options.mode.chained_assignment = "raise" - try: # This is the case when a separate script is calling this function in # this module @@ -29,7 +21,9 @@ os.makedirs(output_dir) -def prep_data(data="psid1968to2015.RData"): +def prep_data( + data=os.path.join(CURDIR, "..", "data", "PSID", "psid1968to2015.csv.gz") +): """ This script takes PSID data created from psid_download.R and: 1) Creates variables at the "tax filing unit" (equal to family @@ -47,10 +41,7 @@ def prep_data(data="psid1968to2015.RData"): income groups defined """ # Read data from R into pandas dataframe - r["load"](os.path.join(CURDIR, "..", "data", "PSID", data)) - raw_r_df = r("psid_df") - with (default_converter + pandas2ri.converter).context(): - raw_df = conversion.get_conversion().rpy2py(raw_r_df) + raw_df = pd.read_csv(data, compression="gzip") # Create unique identifier for each household # note that will define a new household if head or spouse changes diff --git a/setup.py b/setup.py index 3b96a49a..844e718b 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="ogusa", - version="0.1.9", + version="0.1.10", author="Jason DeBacker and Richard W. Evans", license="CC0 1.0 Universal (CC0 1.0) Public Domain Dedication", description="USA calibration for OG-Core", @@ -37,7 +37,6 @@ "paramtools>=0.15.0", "taxcalc>=3.0.0", "requests", - "rpy2>=3.5.12", "pandas-datareader", "xlwt", "openpyxl>=3.1.2", diff --git a/tests/test_utils.py b/tests/test_utils.py index 80755cf8..d94f38f1 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,4 +1,4 @@ -from ogusa import utils +from ogusa.utils import read_cbo_forecast import numpy as np @@ -6,7 +6,7 @@ def test_read_cbo_forecast(): """ Test that CBO data read as expected. """ - test_df = utils.read_cbo_forecast() + test_df = read_cbo_forecast() assert np.allclose( test_df.loc[test_df["year"] == 2017, "Y"].values[0], 20344