-
-
Notifications
You must be signed in to change notification settings - Fork 122
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
Add aggregate.py tests #315
Conversation
@hdoupe thanks for opening this PR. Re dimensions:
|
For the function Also, I'm not sure if I can get the case where Compared to the other functions in |
@hdoupe The docstring for
I think what you are saying is right. |
@jdebacker Thanks for the quick reply.
Ah right, I was thinking that we didn't need the if statement for |
I think this should be ready to merge if you guys are OK with the tests that I've added. When I call |
@hdoupe I prefer to keep things in the |
@jdebacker Ok that makes sense. The most recent commit uses T = 30 and S = 20. |
ogusa/tests/test_aggregates.py
Outdated
results | ||
""" | ||
T = 30 | ||
s, j = 20, 2 |
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.
@hdoupe Might use capital letters for S and J (lower case in the code refers to an item in a range from 0 to S (or J), while S/J give the max number in that dimension.
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.
Ok, sounds good to me.
ogusa/tests/test_aggregates.py
Outdated
|
||
b = -0.1 + (7 * np.random.rand(T * s * j).reshape(T, s, j)) | ||
omega = 0.5 * np.random.rand(T * s).reshape(T, s, 1) | ||
lambdas = 0.4 + (0.2 * np.random.rand(j).reshape(1, 1, j)) |
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.
@hdoupe Maybe doesn't matter for the calculations, but omega.sum()
and lambdas.sum()
should both be 1 in the model.
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.
Ok. I can normalize omega
and lambdas
so that they sum to 1. How does that sound?
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.
If I do normalize omega, which dimensions should sum to 1?
The sum over the S and J dimensions should be one.
…Sent from my iPhone
On Sep 1, 2017, at 2:17 PM, Henry Doupe ***@***.***> wrote:
@hdoupe commented on this pull request.
In ogusa/tests/test_aggregates.py:
> aggI_TPI_test = ((1 + g_n) * np.exp(g_y) *
(K_p1 - res_matrix.sum(1).sum(1) / (1 + g_n)) -
(1.0 - delta) * K)
aggI_TPI = aggr.get_I(b_splus1, K_p1, K,
(delta, g_y, omega, lambdas, imm_rates, g_n, 'TPI'))
assert (np.allclose(aggI_TPI, aggI_TPI_test))
+
+
+def test_get_K():
+ """
+ Simulate data similar to observed
+ """
+ T = 160
+ s, j = 40, 2
+
+ b = -0.1 + (7 * np.random.rand(T * s * j).reshape(T, s, j))
+ omega = 0.5 * np.random.rand(T * s).reshape(T, s, 1)
+ lambdas = 0.4 + (0.2 * np.random.rand(j).reshape(1, 1, j))
If I do normalize omega, which dimensions should sum to 1?
―
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@jdebacker I made the suggested changes. Do you think this is ready to merge? |
@hdoupe Yes - thanks. |
This PR adds tests for the remaining functions in
aggregate.py
.@jdebacker I'm having some trouble generating data with the right dimensions for the function
revenue
. What are the expected dimensions forw
,e
andn
?