Skip to content

Commit 5bed173

Browse files
committed
Merge branch 'main' into maint-software
2 parents d41cca9 + 51477f3 commit 5bed173

File tree

9 files changed

+26
-24
lines changed

9 files changed

+26
-24
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
name: Build HTML [using jupyter-book]
2-
on: [push]
1+
name: CI - Build HTML [using jupyter-book]
2+
on:
3+
pull_request:
4+
workflow_dispatch:
35
jobs:
46
tests:
57
runs-on: ubuntu-latest
@@ -77,7 +79,7 @@ jobs:
7779
uses: nwtgck/actions-netlify@v3
7880
with:
7981
publish-dir: '_build/html/'
80-
production-branch: master
82+
production-branch: main
8183
github-token: ${{ secrets.GITHUB_TOKEN }}
8284
deploy-message: "Preview Deploy from GitHub Actions"
8385
env:

.github/workflows/linkcheck.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name: Link Checker [Anaconda, Linux]
22
on:
33
schedule:
4-
# UTC 23:00 is early morning in Australia (9am)
5-
- cron: '0 23 * * *'
4+
# UTC 23:00 is early morning in Australia (9am) every Sunday
5+
- cron: '0 23 * * 0'
66
workflow_dispatch:
77
jobs:
88
link-checking:
@@ -21,7 +21,7 @@ jobs:
2121
uses: lycheeverse/lychee-action@v2
2222
with:
2323
fail: false
24-
args: --accept 403,503 *.html
24+
args: --accept 403,503 **/*.html
2525
- name: Create Issue From File
2626
if: steps.lychee.outputs.exit_code != 0
2727
uses: peter-evans/create-issue-from-file@v5

lectures/BCG_complete_mkts.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ class BCG_complete_markets:
985985
weights = self.weights
986986
integ = lambda 𝜖: np.exp(𝜖) * fk * q(𝜖, k)
987987
988-
return -k + np.sum(weights * integ(self.points_integral)) / np.sqrt(np.pi)
988+
return -k + (weights @ integ(self.points_integral)) / np.sqrt(np.pi)
989989
990990
#=========== Optimal c ===========#
991991
# Function: Compute optimal consumption choices c
@@ -1007,10 +1007,10 @@ class BCG_complete_markets:
10071007
fk = self.f(k)
10081008
10091009
c1 = lambda 𝜖: (w1(𝜖) + np.exp(𝜖)*fk)*q(𝜖,k)
1010-
denom = np.sum(weights * c1(self.points_integral)) / np.sqrt(np.pi) + (w0 - k)
1010+
denom = (weights @ c1(self.points_integral)) / np.sqrt(np.pi) + (w0 - k)
10111011
10121012
w11q = lambda 𝜖: w11(𝜖)*q(𝜖,k)
1013-
num = w10 + 𝜃10 * V(k) + np.sum(weights * w11q(self.points_integral)) / np.sqrt(np.pi)
1013+
num = w10 + 𝜃10 * V(k) + (weights @ w11q(self.points_integral)) / np.sqrt(np.pi)
10141014
10151015
𝜂 = num / denom
10161016
@@ -1048,7 +1048,7 @@ def k_foc_factory(model):
10481048
10491049
@njit
10501050
def k_foc(k, 𝜒1, 𝜒2):
1051-
int_k = np.sum(weights * integrand(points_integral, 𝜒1, 𝜒2, k=k)) / np.sqrt(np.pi)
1051+
int_k = (weights @ integrand(points_integral, 𝜒1, 𝜒2, k=k)) / np.sqrt(np.pi)
10521052
10531053
mul = 𝛽 * 𝛼 * A * k ** (𝛼 - 1) / ((w0 - k) ** (-𝜓))
10541054
val = mul * int_k - 1

lectures/arellano.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ def T_d(y_idx, v_c, v_d, params, arrays):
432432
433433
current_utility = u(def_y[y_idx], γ)
434434
v = np.maximum(v_c[B0_idx, :], v_d)
435-
cont_value = np.sum((θ * v + (1 - θ) * v_d) * P[y_idx, :])
435+
cont_value = (θ * v + (1 - θ) * v_d) @ P[y_idx, :]
436436
437437
return current_utility + β * cont_value
438438
@@ -457,7 +457,7 @@ def T_c(B_idx, y_idx, v_c, v_d, q, params, arrays):
457457
c = y + B - q[Bp_idx, y_idx] * Bp
458458
if c > 0:
459459
v = np.maximum(v_c[Bp_idx, :], v_d)
460-
val = u(c, γ) + β * np.sum(v * P[y_idx, :])
460+
val = u(c, γ) + β * (v @ P[y_idx, :])
461461
if val > current_max:
462462
current_max = val
463463
Bp_star_idx = Bp_idx

lectures/calvo_abreu.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ def abreu_plan(clq, T=1000, T_A=10, μ_bar=0.1, T_Plot=20):
555555
# Calculate implied stick θ series
556556
discount = (clq.α / (1 + clq.α)) ** np.arange(T)
557557
clq.θ_A = np.array([
558-
1 / (clq.α + 1) * np.sum(clq.μ_A[t:] * discount[:T - t])
558+
1 / (clq.α + 1) * (clq.μ_A[t:] @ discount[:T - t])
559559
for t in range(T)
560560
])
561561

lectures/calvo_machine_learn.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ def compute_θ(μ, α=1):
567567
568568
# Compute the weighted sums for all t
569569
weighted_sums = jnp.array(
570-
[jnp.sum(λ_powers[:T-t] * μ[t:T]) for t in range(T)])
570+
[(λ_powers[:T-t] @ μ[t:T]) for t in range(T)])
571571
572572
# Compute θ values except for the last element
573573
θ = (1 - λ) * weighted_sums + λ**(T - jnp.arange(T)) * μbar
@@ -595,7 +595,7 @@ def compute_V(μ, β, c, α=1, u0=1, u1=0.5, u2=3):
595595
t = np.arange(T)
596596
597597
# Compute sum except for the last element
598-
V_sum = np.sum(β**t * (h0 + h1 * θ[:T] + h2 * θ[:T]**2 - 0.5 * c * μ[:T]**2))
598+
V_sum = (β**t) @ (h0 + h1 * θ[:T] + h2 * θ[:T]**2 - 0.5 * c * μ[:T]**2)
599599
600600
# Compute the final term
601601
V_final = (β**T / (1 - β)) * (h0 + h1 * μ[-1] + h2 * μ[-1]**2 - 0.5 * c * μ[-1]**2)
@@ -931,7 +931,7 @@ def compute_J(μ, β, c, α=1, u0=1, u1=0.5, u2=3):
931931
(β**T/(1-β))])
932932
933933
θ = B @ μ
934-
βθ_sum = jnp.sum((β_vec * h1) * θ)
934+
βθ_sum = (β_vec * h1) @ θ
935935
βθ_square_sum = β_vec * h2 * θ.T @ θ
936936
βμ_square_sum = 0.5 * c * β_vec * μ.T @ μ
937937

lectures/dyn_stack.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ We'll compute it two ways and get the same answer.
10431043
In addition to being a useful check on the accuracy of our coding, computing things in these two ways helps us think about the structure of the problem.
10441044
10451045
```{code-cell} python3
1046-
v_leader_forward = np.sum(βs * π_leader)
1046+
v_leader_forward = βs @ π_leader
10471047
v_leader_direct = -yt[:, 0].T @ P @ yt[:, 0]
10481048
10491049
# Display values
@@ -1380,8 +1380,8 @@ u2 = (- F2 @ z).flatten()
13801380
π_1 = p * q1 - γ * (u1) ** 2
13811381
π_2 = p * q2 - γ * (u2) ** 2
13821382
1383-
v1_forward = np.sum(βs * π_1)
1384-
v2_forward = np.sum(βs * π_2)
1383+
v1_forward = βs @ π_1
1384+
v2_forward = βs @ π_2
13851385
13861386
v1_direct = (- z[:, 0].T @ P1 @ z[:, 0])
13871387
v2_direct = (- z[:, 0].T @ P2 @ z[:, 0])

lectures/five_preferences.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def ent(π, π_hat):
100100
Compute the relative entropy of a probability vector `π_hat` with respect to `π`. JIT-compiled using Numba.
101101
102102
"""
103-
ent_val = -np.sum(π_hat * (np.log(π) - np.log(π_hat)))
103+
ent_val = -π_hat @ (np.log(π) - np.log(π_hat))
104104
105105
return ent_val
106106
@@ -115,7 +115,7 @@ def T_θ_factory(θ, π):
115115
Risk-sensitivity operator of Jacobson (1973) and Whittle (1981) taking a function `u` as argument.
116116
117117
"""
118-
return lambda c: -θ * np.log(np.sum(π * np.exp(-u(c) / θ)))
118+
return lambda c: -θ * np.log(π @ np.exp(-u(c) / θ))
119119
120120
return T_θ
121121
@@ -128,7 +128,7 @@ def compute_change_measure(u, c, θ, π):
128128
"""
129129
130130
m_unnormalized = np.exp(-u(c) / θ)
131-
m = m_unnormalized / (π * m_unnormalized).sum()
131+
m = m_unnormalized / (π @ m_unnormalized)
132132
return m
133133
134134

lectures/orth_proj.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ def gram_schmidt(X):
790790
791791
# The first col of U is just the normalized first col of X
792792
v1 = X[:,0]
793-
U[:, 0] = v1 / np.sqrt(np.sum(v1 * v1))
793+
U[:, 0] = v1 / np.sqrt(v1 @ v1)
794794
795795
for i in range(1, k):
796796
# Set up
@@ -802,7 +802,7 @@ def gram_schmidt(X):
802802
u = M @ b
803803
804804
# Normalize
805-
U[:, i] = u / np.sqrt(np.sum(u * u))
805+
U[:, i] = u / np.sqrt(u @ u)
806806
807807
return U
808808
```

0 commit comments

Comments
 (0)