Skip to content

Commit ed2475c

Browse files
authored
Updates to sequential wealth on julia 1.8.3 update (#204)
* Updates to CI and loop vectorization for wealth_dynamics * Modernized the unpacking notation * Fix for julia 1.8.3
1 parent 26d07fe commit ed2475c

28 files changed

+417
-397
lines changed

.github/workflows/cache.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Set up Julia
3131
uses: julia-actions/setup-julia@v1
3232
with:
33-
version: 1.8
33+
version: 1.8.3
3434
- name: Install IJulia and Setup Project
3535
shell: bash
3636
run: |

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Set up Julia
2828
uses: julia-actions/setup-julia@v1
2929
with:
30-
version: 1.8
30+
version: 1.8.3
3131
- name: Install IJulia and Setup Project
3232
shell: bash
3333
run: |

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Set up Julia
3232
uses: julia-actions/setup-julia@v1
3333
with:
34-
version: 1.8
34+
version: 1.8.3
3535
- name: Install IJulia and Setup Project
3636
shell: bash
3737
run: |

lectures/Manifest.toml

Lines changed: 102 additions & 225 deletions
Large diffs are not rendered by default.

lectures/Project.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
name = "quantecon-notebooks-julia"
22
authors = ["quantecon <[email protected]>"]
3-
version = "0.8.0"
3+
version = "0.8.1"
44

55
[deps]
6-
ApproxFun = "28f2ccd6-bb30-5033-b560-165f7b14dc2f"
76
Arpack = "7d9fca2a-8960-54d3-9f78-7d1dccf2cb97"
87
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
98
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
@@ -30,6 +29,7 @@ LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
3029
LeastSquaresOptim = "0fc2ff8b-aaa3-5acd-a817-1944a5e08891"
3130
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
3231
LinearMaps = "7a12625a-238d-50fd-b39a-03d52299707e"
32+
LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890"
3333
NLopt = "76087f3c-5699-56af-9a33-bf431cd00edd"
3434
NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56"
3535
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
@@ -53,5 +53,4 @@ StatsPlots = "f3b207a7-027a-5e70-b257-86293d7955fd"
5353
StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"
5454
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
5555
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
56-
VegaLite = "112f6efa-9a02-5b7d-90c0-432ed331239a"
5756
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

lectures/continuous_time/covid_sde.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ First, construct our $F$ from {eq}`dfcvsde` and $G$ from {eq}`dG`
231231
```{code-cell} julia
232232
function F(x, p, t)
233233
s, i, r, d, R₀, δ = x
234-
@unpack γ, R̄₀, η, σ, ξ, θ, δ_bar = p
234+
(;γ, R̄₀, η, σ, ξ, θ, δ_bar) = p
235235
236236
return [-γ*R₀*s*i; # ds/dt
237237
γ*R₀*s*i - γ*i; # di/dt
@@ -244,7 +244,7 @@ end
244244
245245
function G(x, p, t)
246246
s, i, r, d, R₀, δ = x
247-
@unpack γ, R̄₀, η, σ, ξ, θ, δ_bar = p
247+
(;γ, R̄₀, η, σ, ξ, θ, δ_bar) = p
248248
249249
return [0; 0; 0; 0; σ*sqrt(R₀); ξ*sqrt(δ * (1-δ))]
250250
end
@@ -536,7 +536,7 @@ We will redo the "Ending Lockdown" simulation from above, where the only differe
536536
```{code-cell} julia
537537
function F_reinfect(x, p, t)
538538
s, i, r, d, R₀, δ = x
539-
@unpack γ, R̄₀, η, σ, ξ, θ, δ_bar, ν = p
539+
(;γ, R̄₀, η, σ, ξ, θ, δ_bar, ν) = p
540540
541541
return [-γ*R₀*s*i + ν*r; # ds/dt
542542
γ*R₀*s*i - γ*i; # di/dt

lectures/continuous_time/seir_model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ First, construct our $F$ from {eq}`dfcv`
290290
```{code-cell} julia
291291
function F(x, p, t)
292292
s, e, i, r, R₀, c, d = x
293-
@unpack σ, γ, R̄₀, η, δ = p
293+
(;σ, γ, R̄₀, η, δ) = p
294294
295295
return [-γ*R₀*s*i; # ds/dt
296296
γ*R₀*s*i - σ*e; # de/dt

lectures/dynamic_programming/coleman_policy_iter.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ end
513513
```{code-cell} julia
514514
function verify_true_policy(m, shocks, c_star)
515515
# compute (Kc_star)
516-
@unpack grid, β, ∂u∂c, f, f′ = m
516+
(;grid, β, ∂u∂c, f, f′) = m
517517
c_star_new = K(c_star, grid, β, ∂u∂c, f, f′, shocks)
518518
519519
# plot c_star and Kc_star
@@ -549,7 +549,7 @@ The initial condition we'll use is the one that eats the whole pie: $c(y) = y$
549549

550550
```{code-cell} julia
551551
function check_convergence(m, shocks, c_star, g_init; n_iter = 15)
552-
@unpack grid, β, ∂u∂c, f, f′ = m
552+
(;grid, β, ∂u∂c, f, f′) = m
553553
g = g_init;
554554
plot(m.grid, g, lw = 2, alpha = 0.6, label = L"intial condition $c(y) = y$")
555555
for i in 1:n_iter
@@ -595,7 +595,7 @@ function iterate_updating(func, arg_init; sim_length = 20)
595595
end
596596
597597
function compare_error(m, shocks, g_init, w_init; sim_length = 20)
598-
@unpack grid, β, u, ∂u∂c, f, f′ = m
598+
(;grid, β, u, ∂u∂c, f, f′) = m
599599
g, w = g_init, w_init
600600
601601
# two functions for simplification
@@ -742,7 +742,7 @@ m_ex = Model(γ = 1.5);
742742
```{code-cell} julia
743743
function exercise2(m, shocks, g_init = m.grid, w_init = m.u.(m.grid); sim_length = 20)
744744
745-
@unpack grid, β, u, ∂u∂c, f, f′ = m
745+
(;grid, β, u, ∂u∂c, f, f′) = m
746746
# initial policy and value
747747
g, w = g_init, w_init
748748
# iteration
@@ -773,12 +773,12 @@ It assumes that you've just run the code from the previous exercise
773773

774774
```{code-cell} julia
775775
function bellman(m, shocks)
776-
@unpack grid, β, u, ∂u∂c, f, f′ = m
776+
(;grid, β, u, ∂u∂c, f, f′) = m
777777
bellman_single_arg(w) = T(w, grid, β, u, f, shocks)
778778
iterate_updating(bellman_single_arg, u.(grid), sim_length = 20)
779779
end
780780
function coleman(m, shocks)
781-
@unpack grid, β, ∂u∂c, f, f′ = m
781+
(;grid, β, ∂u∂c, f, f′) = m
782782
coleman_single_arg(g) = K(g, grid, β, ∂u∂c, f, f′, shocks)
783783
iterate_updating(coleman_single_arg, grid, sim_length = 20)
784784
end

lectures/dynamic_programming/discrete_dp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ using BenchmarkTools, Plots, QuantEcon, Parameters
435435
SimpleOG = @with_kw (B = 10, M = 5, α = 0.5, β = 0.9)
436436
437437
function transition_matrices(g)
438-
@unpack B, M, α, β = g
438+
(;B, M, α, β) = g
439439
u(c) = c^α
440440
n = B + M + 1
441441
m = M + 1
@@ -468,7 +468,7 @@ In case the preceding code was too concise, we can see a more verbose form
468468
tags: [output_scroll]
469469
---
470470
function verbose_matrices(g)
471-
@unpack B, M, α, β = g
471+
(;B, M, α, β) = g
472472
u(c) = c^α
473473
474474
#Matrix dimensions. The +1 is due to the 0 state.

lectures/dynamic_programming/ifp.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ end
403403
function T!(cp, V, out; ret_policy = false)
404404
405405
# unpack input, set up arrays
406-
@unpack R, Π, β, b, asset_grid, z_vals = cp
406+
(;R, Π, β, b, asset_grid, z_vals) = cp
407407
z_idx = 1:length(z_vals)
408408
409409
# value function when the shock index is z_i
@@ -444,7 +444,7 @@ get_greedy(cp, V) =
444444
445445
function K!(cp, c, out)
446446
# simplify names, set up arrays
447-
@unpack R, Π, β, b, asset_grid, z_vals = cp
447+
(;R, Π, β, b, asset_grid, z_vals) = cp
448448
z_idx = 1:length(z_vals)
449449
gam = R * β
450450
@@ -474,7 +474,7 @@ K(cp, c) = K!(cp, c, similar(c))
474474
475475
function initialize(cp)
476476
# simplify names, set up arrays
477-
@unpack R, β, b, asset_grid, z_vals = cp
477+
(;R, β, b, asset_grid, z_vals) = cp
478478
shape = length(asset_grid), length(z_vals)
479479
V, c = zeros(shape...), zeros(shape...)
480480
@@ -743,7 +743,7 @@ end
743743

744744
```{code-cell} julia
745745
function compute_asset_series(cp, T = 500_000; verbose = false)
746-
@unpack Π, z_vals, R = cp # simplify names
746+
(;Π, z_vals, R) = cp # simplify names
747747
z_idx = 1:length(z_vals)
748748
v_init, c_init = initialize(cp)
749749
c = compute_fixed_point(x -> K(cp, x), c_init,

0 commit comments

Comments
 (0)