From 6909aad8697dfe0fa843db95ef2b42f5ce524634 Mon Sep 17 00:00:00 2001 From: Matt McKay Date: Thu, 28 May 2026 11:22:42 +1000 Subject: [PATCH] FIX: index fsolve result in un_insure r_error so brentq gets a scalar In `r_error`, `sp.optimize.fsolve(...)` returns a length-1 array, so the function returned a shape-(1,) array. The outer `brentq` then coerces that return value to a Python float, which raises under numpy 2.x / scipy 1.17 (the quantecon-build:latest image, numpy 2.4.4 / scipy 1.17.1): TypeError: only 0-dimensional arrays can be converted to Python scalars This is why the build (and main's scheduled builds) were failing on un_insure.md. Index `[0]` to return a scalar, matching the existing `Vu_aut = fsolve(...)[0]` call just below. Mirrors upstream fix QuantEcon/lecture-python-advanced.myst#327 (un_insure.md is sourced from there; see issue #7). Verified end-to-end inside ghcr.io/quantecon/quantecon-build:latest. Co-Authored-By: Claude Opus 4.7 (1M context) --- lectures/un_insure.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lectures/un_insure.md b/lectures/un_insure.md index ff8687e..ae0e7e2 100644 --- a/lectures/un_insure.md +++ b/lectures/un_insure.md @@ -606,7 +606,7 @@ def r_error(self,r): β = self.β Ve = self.Ve - Vu_star = sp.optimize.fsolve(Vu_error_Λ,15000,args = (r)) + Vu_star = sp.optimize.fsolve(Vu_error_Λ,15000,args = (r))[0] a_star = invp_prime(1/(β*(Ve-Vu_star)),r) # Assuming a>0 return p(a_star,r) - 0.1 ```