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

move data from cstwMPC to datasets #622

Merged
merged 10 commits into from
Apr 28, 2020
1 change: 1 addition & 0 deletions HARK/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from HARK.datasets.load_data import *
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions HARK/datasets/load_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import csv
import numpy as np
from copy import deepcopy
import os

DATASETS = os.path.dirname(os.path.abspath(__file__)) + "/data/"


def load_SCF_wealth_weights():
""" U.S. Survey of Consumer Finances data

Returns
-------
SCF_wealth, SCF_weights: np.ndarray, np.ndarray
"""
with open(DATASETS + "SCFwealthDataReduced.txt", "r") as f:
SCF_reader = csv.reader(f, delimiter="\t")
SCF_raw = list(SCF_reader)
SCF_wealth = np.zeros(len(SCF_raw)) + np.nan
SCF_weights = deepcopy(SCF_wealth)
for j in range(len(SCF_raw)):
SCF_wealth[j] = float(SCF_raw[j][0])
SCF_weights[j] = float(SCF_raw[j][1])
return SCF_wealth, SCF_weights
11 changes: 11 additions & 0 deletions HARK/datasets/tests/test_load_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import unittest
from HARK.datasets import load_SCF_wealth_weights


class test_load_SCF_wealth_weights(unittest.TestCase):
def setUp(self):
self.SCF_wealth, self.SCF_weights = load_SCF_wealth_weights()

def test_shape(self):
self.assertEqual(self.SCF_wealth.shape, (3553,))
self.assertEqual(self.SCF_weights.shape, (3553,))
16 changes: 1 addition & 15 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,7 @@ include MANIFEST.in
include setup.cfg

# include data files
recursive-include HARK/cstwMPC *.txt

# Include most files
# recursive-include ConsumptionSaving *
# recursive-include Demos *
# recursive-include dist *
# recursive-include FashionVictim *
# recursive-include SolvingMicroDSOPs *

# We plan to store the full archive of a paper implemented in Econ-ARK
# separately from the codebase that reproduces the paper's results.

# At present we have not separated these things out for either the
# cAndCwithStickyE paper or the cstwMPC paper.
# Therefore those papers are left out in the current version.
recursive-include HARK/datasets/data *.txt

# except build files
global-exclude *.pyc
Expand Down