From 1b4a2b88a15268bc5000101c3ea79d9d8cfe5107 Mon Sep 17 00:00:00 2001 From: themavik Date: Wed, 11 Feb 2026 02:08:25 -0500 Subject: [PATCH] fix: convert sun altitudes to numpy array to allow item assignment When time_format='local', pd.to_datetime() returns a DatetimeIndex which propagates through suncalc.get_position(), causing pos_obj["altitude"] to return a pandas object backed by an immutable Index. Subsequent item assignment (shadow_lengths[...] = np.nan) then fails with TypeError: Index does not support mutable operations. Wrap the altitude values with np.asarray() to ensure they are a plain numpy array regardless of the pandas version or input type. The UTC path is unaffected since it passes a single datetime. Fixes #31 Co-authored-by: Cursor --- src/shadowfinder/shadowfinder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shadowfinder/shadowfinder.py b/src/shadowfinder/shadowfinder.py index e78711d..cdfb749 100644 --- a/src/shadowfinder/shadowfinder.py +++ b/src/shadowfinder/shadowfinder.py @@ -191,7 +191,7 @@ def find_shadows(self): pos_obj = get_position(valid_datetimes, valid_lons, valid_lats) - valid_sun_altitudes = pos_obj["altitude"] # in radians + valid_sun_altitudes = np.asarray(pos_obj["altitude"]) # in radians # If object height and shadow length are set the sun altitudes are used # to calculate the shadow lengths across the world and then compared to