Coverage for HARK / Calibration / load_data.py: 100%
15 statements
« prev ^ index » next coverage.py v7.12.0, created at 2025-12-07 05:16 +0000
« prev ^ index » next coverage.py v7.12.0, created at 2025-12-07 05:16 +0000
1import csv
2import os
3from copy import deepcopy
5import numpy as np
7DATASETS = os.path.dirname(os.path.abspath(__file__)) + "/data/"
10def load_SCF_wealth_weights():
11 """U.S. Survey of Consumer Finances data
13 Returns
14 -------
15 SCF_wealth, SCF_weights: np.ndarray, np.ndarray
16 """
17 with open(DATASETS + "SCFwealthDataReduced.txt") as f:
18 SCF_reader = csv.reader(f, delimiter="\t")
19 SCF_raw = list(SCF_reader)
20 SCF_wealth = np.zeros(len(SCF_raw)) + np.nan
21 SCF_weights = deepcopy(SCF_wealth)
22 for j in range(len(SCF_raw)):
23 SCF_wealth[j] = float(SCF_raw[j][0])
24 SCF_weights[j] = float(SCF_raw[j][1])
25 return SCF_wealth, SCF_weights