-
-
Notifications
You must be signed in to change notification settings - Fork 197
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
light touch Market class refactoring #765
Conversation
Another reason to store Market state in this way is that this kind of representation is needed by the https://github.com/econ-ark/HARK/blob/master/HARK/core.py#L1058-L1065 |
@@ -1678,12 +1680,12 @@ def update(self): | |||
self.KtoLnow_init = self.kSS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did I miss one here? i think so
HARK/core.py
Outdated
setattr(self, this_var, this_product) | ||
|
||
for sow_var in self.sow_state: | ||
this_product = getattr(product, sow_var) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This simplifies if millRule
returns a dict-like: self.sow_state.update(product)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chose for millRule
to return a tuple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(closer to Dolo, supposed to be good for numba)
self.sow_init['Mnow'] = self.MSS | ||
self.sow_init['Aprev'] = self.KSS | ||
self.sow_init['Rnow'] = self.RSS | ||
self.sow_init['Wnow'] = self.WSS | ||
self.PermShkAggNow_init = 1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, not missing because these are not sow_vars in KS
'TranShkAggNow', | ||
'KtoLnow', | ||
'MrkvNow' # This one is new | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When all the sow_vars are "Now", "Now" can be left out of the name...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I don't dare.
@@ -2455,81 +2526,6 @@ def calcAFunc(self, Mnow, Aprev): | |||
return AggShocksDynamicRule(AFunc_list) | |||
|
|||
|
|||
class CobbDouglasAggVars(HARKobject): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced these container classes with tuples same size/order as sow_vars
@@ -48,6 +48,9 @@ def test_macro(self): | |||
self.assertAlmostEqual(self.economy.AFunc.slope, | |||
1.116259456228145) | |||
|
|||
self.assertAlmostEqual(self.economy.history['MaggNow'][10], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are added in #773, which should be merged first
This PR is now ready for review. |
Can use regular dicts instead of OrderedDict for Python 3.7+ |
0.10.6 supports Python 3.6: I think in our meeting today we agreed 0.10.7 would drop Python 3.6 support |
OrderedDict replaced with dict in recent commit |
I expect this to be merged AFTER the 0.10.7 release, since there seems to be a feature freeze there. |
CDC has asked me to familiarize myself with the Market code because of a certain project.
In this PR, I'll try to do some light maintenance based on previously established design principles.
Some considerations:
The current step in this PR, meant to be illustrative, is moving the storage of initial and state values for
sow_vars
into dictionaries. The trajectory of this work is to make similar adjustments for thereap_vars
, etc. The Market class is a nice place to do these changes because the variables are already categorized in the class constructor. (I'd recommend similar changes to the Agent classes, but these are not yet written in as abstract a way.)The current PR passes the
test_ConsAggShockModel.py
tests. I'd like to note that this is without changes to e.g. theSmallOpenEconomy
that would be necessary to retain functionality. This indicates a gap in the current test suite. If this PR's direction gets approval, I would write tests for those other classes as part of this PR.