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
Labeled income process #1189
Labeled income process #1189
Conversation
Codecov ReportBase: 73.61% // Head: 73.66% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #1189 +/- ##
==========================================
+ Coverage 73.61% 73.66% +0.05%
==========================================
Files 73 73
Lines 11998 12024 +26
==========================================
+ Hits 8832 8858 +26
Misses 3166 3166
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
HARK/distribution.py
Outdated
@@ -1192,6 +1192,10 @@ def RNG(self): | |||
""" | |||
return self.dataset.RNG | |||
|
|||
@RNG.setter | |||
def RNG(self,value): | |||
self.dataset.attrs['RNG'] = value |
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.
Should this be np.random.RandomState(value)
?
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.
I am not sure? What does this property do?
I wrote as it is because I thought that the get
and set
method should deal with exactly the same object. Since the getter is
Lines 1188 to 1193 in daf2afd
@property | |
def RNG(self): | |
""" | |
Returns the distribution's random number generator. | |
""" | |
return self.dataset.RNG |
I wrote the setter to the RNG property directly. What do you think?
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.
I think this is how we initialize a random state with a seed. When we initialize a DiscreteDsitribution object, we set RNG as follows
Line 1079 in daf2afd
attrs["RNG"] = np.random.RandomState(seed) |
so I guess we would have to do dist.RNG = np.random.RandomState(seed)
.
Actually I guess this isn't a problem, you just have to be more explicit that the value
parameter should be of type RandomState
. Maybe just a type check?
But also if we have a setter for dist.seed = value
it should also generate a new RNG.
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.
I like the typecheck solution.
You did not add a setter for the seed property (I think?) Should I create one? Would that go in a different PR?
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.
It might be useful to have a seed setter. I think it would be fine to go in this PR.
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.
Alrighty, added a typecheck.
I could not remember why I had to add this setter in the first place, but just ran some tests and found out. The reason was that methods like initialize_sim
call Distribution.reset()
on things like the income distribution. That method is
Lines 24 to 31 in 20645e2
def reset(self): | |
""" | |
Reset the random number generator of this distribution. | |
Parameters | |
---------- | |
""" | |
self.RNG = np.random.RandomState(self.seed) |
So without a setter, it failed
@Mv77 is this done? I can merge it once you resolve conflicts |
Not yet!
…On Wed, Dec 7, 2022, 2:09 PM alanlujan91 ***@***.***> wrote:
@Mv77 <https://github.com/Mv77> is this done? I can merge it once you
resolve conflicts
—
Reply to this email directly, view it on GitHub
<#1189 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGTULS4KZYPJHYP4FKPLOTTWMDOIPANCNFSM6AAAAAASIN2Z3I>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
# Conflicts: # HARK/tests/test_distribution.py
# Conflicts: # HARK/ConsumptionSaving/tests/test_ConsMarkovModel.py
This is ready for review and merge if it passes review. @llorracc I checked locally that it does not break DemARKs. It's much harder to know for REMARKs, but afaik version control for REMARKs is in the works. |
Yes, version control for REMARKs is in the works. I've asked @sbenthall to work on preparing for a new release (0.13) by the end of this month, and I hope by that time we will have nailed down the status of all the REMARKs: Either pinned to earlier versions of HARK, or added to the tests that are run when new PRs are submitted. PS. I'm a bit puzzled by the combination of the "Needs: Revision" and the "Ready-To-Merge" labels. Could you clarify what revisions you view as needed? I guess it's hard to see how to keep track of whether we get those revisions done after the PR is merged. Maybe the right approach is to make an "issue" containing the revisions that are needed, and link to the issue in this discussion of the merge request? |
What I wanted to express was "This is ready from my point of view. It would be good to get someone to look at it. If that someone approves, they can go ahead and merge without further questions." |
OK, I guess the right "someone" is @alanlujan91 Alan, go for it! |
I've removed the "Needs:revision" label. |
This PR changes the income process constructor in
ConsIndShockModel
to use @alanlujan91'sDiscreteDistributionLabeled
class. This:shocks[0]
becomesshocks['PermShk']
) when taking expectations.I have marked it as WIP because I want to extend the change to portfolio models, but tests are currently passing.
Please ensure your pull request adheres to the following guidelines: