-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
[arellano] get rid of jitclass #131
Conversation
✅ Deploy Preview for incomparable-parfait-2417f8 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@shlff , this is labeled as "in-work". Is it ready to review? |
Thanks @jstac . I've been reviewing this PR, and I will get back to you very soon. |
Thanks @jstac . This PR is ready to review. Here is a preview: https://65e521825ca446fa847b6ccd--incomparable-parfait-2417f8.netlify.app/arellano In addition to using namedtuple, I also modified the words previously mentioning the class and corrected some typos. |
Thanks @shlff , appreciated. @HumphreyYang , can you please review? |
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.
Many thanks @shlff for the careful changes. Please find my minor comments below.
lectures/arellano.md
Outdated
def create_arellano(B_size=251, # Grid size for bonds | ||
B_min=-0.45, # Smallest B value | ||
B_max=0.45, # Largest B value | ||
y_size=51, # Grid size for income | ||
β=0.953, # Time discount parameter | ||
γ=2.0, # Utility parameter | ||
r=0.017, # Lending rate | ||
ρ=0.945, # Persistence in the income process | ||
η=0.025, # Standard deviation of the income process | ||
θ=0.282, # Prob of re-entering financial markets | ||
def_y_param=0.969): # Parameter governing income in default |
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 we prefer to comment on parameters when they are defined for the first time. Please move these comments on parameters to where we define the namedtuple
.
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.
Thanks @HumphreyYang , I will add the comments to both places, given the comments from another PR.
lectures/arellano.md
Outdated
probabilities. | ||
|
||
```{code-cell} ipython3 | ||
:hide-output: false | ||
Arellano_Economy = namedtuple('Arellano_Economy', ('β', 'γ', 'r', 'ρ', 'η', 'θ', \ |
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.
Class (namedtuple
) names should follow CamelCase
Arellano_Economy = namedtuple('Arellano_Economy', ('β', 'γ', 'r', 'ρ', 'η', 'θ', \ | |
ArellanoEconomy = namedtuple('Arellano_Economy', ('β', 'γ', 'r', 'ρ', 'η', 'θ', \ |
There are some Arellano_Economy
below in the text as well, so please update them together : )
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.
Good idea! We should change the name in the original lecture too:
lectures/arellano.md
Outdated
Arellano_Economy = namedtuple('Arellano_Economy', ('β', 'γ', 'r', 'ρ', 'η', 'θ', \ | ||
'B_size', 'y_size', \ | ||
'P', 'B_grid', 'y_grid', 'def_y')) |
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.
As noted above, we can migrate the comments below to here.
(Also, we can change lines without \
when they are in the same ()
)
lectures/arellano.md
Outdated
|
||
For example, `r=0.017` matches the average quarterly rate on a 5 year US treasury over the period 1983–2001. | ||
|
||
Details on how to compute the figures are reported as solutions to the | ||
exercises. | ||
|
||
The first figure shows the bond price schedule and replicates Figure 3 of | ||
Arellano, where $ y_L $ and $ Y_H $ are particular below average and above average | ||
{cite}`Are08`, where $ y_L $ and $ Y_H $ are particular below average and above average | ||
values of output $ y $. | ||
|
||
![https://python-advanced.quantecon.org/_static/lecture_specific/arellano/arellano_bond_prices.png](https://python-advanced.quantecon.org/_static/lecture_specific/arellano/arellano_bond_prices.png) |
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 we move these images to this repo as we will migrate the advanced series to theme-specific series soon? (CC @mmcky):
![https://python-advanced.quantecon.org/_static/lecture_specific/arellano/arellano_bond_prices.png](https://python-advanced.quantecon.org/_static/lecture_specific/arellano/arellano_bond_prices.png)
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.
Thanks @HumphreyYang . I reckon @mmcky have already done that in PR #141
762521e
to
ff86e0f
Compare
@shlff do you know why you needed to use a force push. They are pretty dangerous and I encourage you to avoid using them. Would you like to update this PR from the |
Sorry @mmcky I realised the risk of force push and will not use it anymore. Yep it would be great if we can update this PR from the main. I reckon that after that some check failure should be gone. |
Thanks @HumphreyYang @jstac and @mmcky . I resolved the issues mentioned in the comments above. This PR is ready to review again and here is a preview: https://65e64dd91341d614052e79ae--incomparable-parfait-2417f8.netlify.app/ |
Many thanks @shlff
B_grid = jax.device_put(B_grid)
y_grid = jax.device_put(y_grid) |
Thanks @jstac . It seems that the commit with changes I made in the morning has not been pushed to this PR. I will make the changes suggested by your comments along with those changes. |
…n/lecture-jax into use_namedtuple_arellano
…n/lecture-jax into use_namedtuple_arellano
Thanks @jstac . The following tasks have been done:
This PR is ready to review again, and please find a preview: https://65e6b96ed004475661581086--incomparable-parfait-2417f8.netlify.app/arellano |
Hi @shlff , the first code block (ArellanoEconomy = ...) has lines more than 80 characters. Same with the next one. |
Good catch @jstac . I modified all the code cells, which should all strictly follow the max 80 characters rule except for line 601. Please find the preview here: https://65e6c6b323165e623b58b2dd--incomparable-parfait-2417f8.netlify.app/arellano |
I'm confused @shlff . In that preview there are multiple lines that exceed 80 characters, even in the first code block. |
Thanks @jstac . I set a ruler of max 80 characters in my vs code, and here is a screenshot of these two code cells: I guess the code cell length in the preview is less than 80 characters. Maybe I can further modify the code so that each line of the code can be revealed without scrolling in the preview. |
That's strange. Try counting the characters in this line, which i copy pasted from the first code block: 'P', # Markov matrix governing the income process |
Thanks @jstac . I figured out: I guess you could review it using an old preview. If you review the same line from the most recent preview below, then this line should be 80 characters: https://65e6c6b323165e623b58b2dd--incomparable-parfait-2417f8.netlify.app/arellano |
Thanks @shlff I've readjusted those lines so the reader doesn't need to scroll and the comments are aligned. |
Hi @jstac this PR gets rid of class and uses namedtuple, as mentioned in #129 .