forked from econ-ark/HARK
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consumer.yaml config file; yaml loader in HARK.parser; smoke test
- Loading branch information
Showing
3 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import os | ||
import unittest | ||
|
||
|
||
import HARK.parser as parser | ||
import yaml | ||
|
||
|
||
class test_consumption_parsing(unittest.TestCase): | ||
def setUp(self): | ||
this_file_path = os.path.dirname(__file__) | ||
consumer_yaml_path = os.path.join(this_file_path, "../models/consumer.yaml") | ||
|
||
self.consumer_yaml_file = open(consumer_yaml_path, "r") | ||
|
||
def test_parse(self): | ||
self.consumer_yaml_file | ||
|
||
config = yaml.load(self.consumer_yaml_file, Loader=parser.harklang_loader()) | ||
pass | ||
|
||
""" | ||
try: | ||
config = yaml.load(open('perfect_foresight_full_experimental.yaml', 'r'), Loader= get_loader()) | ||
# data is copied | ||
assert config['model']['blocks']['consumption'] == config['model']['strategies'][1]['block'] | ||
# data is maintained once in memory and referenced in both places | ||
assert config['model']['blocks']['consumption'] is config['model']['strategies'][1]['block'] | ||
# object created by parser | ||
c1 = config['model']['blocks']['consumption']['dynamics']['c'] | ||
c2 = config['model']['strategies'][1]['block']['dynamics']['c'] | ||
# objects are equal | ||
assert c1 == c2 | ||
# objects are identical in memory; the reference is shared. | ||
assert c1 is c2 | ||
a_str = config['model']['blocks']['consumption']['dynamics']['a'] | ||
a_expr = parse_expr(a_str) | ||
a_func = lambdify(list(a_expr.free_symbols), a_expr, "numpy") | ||
m = np.random.random(100) | ||
c = np.random.random(100) | ||
#import pdb; pdb.set_trace() | ||
except yaml.YAMLError as exc: | ||
print("Error in configuration file:", exc) | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ networkx>=3 | |
numba<0.60.0 | ||
numpy>=1.23 | ||
pandas>=1.5 | ||
pyyaml>=6.0 | ||
quantecon | ||
scipy>=1.10 | ||
seaborn>=0.12 | ||
|