From 71764ef55144edbdbce32755fb3e1fbdc804cc83 Mon Sep 17 00:00:00 2001 From: Scott Staniewicz Date: Thu, 26 Feb 2026 11:34:12 -0500 Subject: [PATCH] Fix numpy >= 2.0 TypeError in polyfit chi-squared print `np.linalg.lstsq` returns `res` as a 1-element array. In numpy >= 2.0, `%f` string formatting no longer implicitly converts arrays to scalars, raising `TypeError: only 0-dimensional arrays can be converted to Python scalars`. Use `.item()` to explicitly extract the scalar value. Co-Authored-By: Claude Opus 4.6 --- src/s1reader/s1_burst_slc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s1reader/s1_burst_slc.py b/src/s1reader/s1_burst_slc.py index 90b75e7c..a88c9edc 100644 --- a/src/s1reader/s1_burst_slc.py +++ b/src/s1reader/s1_burst_slc.py @@ -94,7 +94,7 @@ class represents a polynomial function of range val, res, _, _ = np.linalg.lstsq(A, z, rcond=cond) if len(res) > 0: - print("Chi squared: %f" % (np.sqrt(res / (1.0 * len(z))))) + print("Chi squared: %f" % np.sqrt(res / (1.0 * len(z))).item()) else: print("No chi squared value....") print("Try reducing rank of polynomial.")