From f0a25276d095699d1684eb93f1e2e73163f12e92 Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 18 Apr 2024 16:46:50 +1000 Subject: [PATCH 1/2] [overborrowing] MAINT: collect status messages and print at the end of iteration --- lectures/overborrowing.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lectures/overborrowing.md b/lectures/overborrowing.md index b8da1d43..0ef90e13 100644 --- a/lectures/overborrowing.md +++ b/lectures/overborrowing.md @@ -634,15 +634,17 @@ def compute_equilibrium(parameters, sizes, arrays, H = generate_initial_H(parameters, sizes, arrays) error = tol + 1 i = 0 + msgs = [] while error > tol and i < max_iter: H_new, vfi_num_iter = update_H(parameters, sizes, arrays, H, α) - print(f"VFI terminated after {vfi_num_iter} iterations.") + msgs.append(f"VFI terminated after {vfi_num_iter} iterations.") error = jnp.max(jnp.abs(b_grid[H] - b_grid[H_new])) - print(f"Updated H at iteration {i} with error {error}.") + msgs.append(f"Updated H at iteration {i} with error {error}.") H = H_new i += 1 if i == max_iter: - print("Warning: Equilibrium search iteration hit upper bound.") + msgs.append("Warning: Equilibrium search iteration hit upper bound.") + print(msgs.join("\n")) return H ``` From e3086524431ea72259ef88d5b479dabc6eddc5f9 Mon Sep 17 00:00:00 2001 From: mmcky Date: Thu, 18 Apr 2024 17:14:42 +1000 Subject: [PATCH 2/2] fix syntax --- lectures/overborrowing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/overborrowing.md b/lectures/overborrowing.md index 0ef90e13..576b3f25 100644 --- a/lectures/overborrowing.md +++ b/lectures/overborrowing.md @@ -644,7 +644,7 @@ def compute_equilibrium(parameters, sizes, arrays, i += 1 if i == max_iter: msgs.append("Warning: Equilibrium search iteration hit upper bound.") - print(msgs.join("\n")) + print("\n".join(msgs)) return H ```