From b9b988ce3a9cbd2b1e284594f0df687110e14dde Mon Sep 17 00:00:00 2001 From: Xander Byrne Date: Wed, 29 Oct 2025 10:15:08 +0000 Subject: [PATCH] Fix: list comprehension scope bug --- ispec/modeling/ssf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ispec/modeling/ssf.py b/ispec/modeling/ssf.py index beb6f5b..e52b54c 100644 --- a/ispec/modeling/ssf.py +++ b/ispec/modeling/ssf.py @@ -949,7 +949,9 @@ def model_spectrum(spectrum, continuum_model, modeled_layers_pack, linelist, iso ] # Fetch the local variables by name - lengths = {name: len(locals()[name]) for name in names} + local_snapshot = dict(locals()) + # ^ Create a snapshot of the locals (list comprehensions have their own scope in Python 3) + lengths = {name: len(local_snapshot[name]) for name in names} if len(set(lengths.values())) != 1: raise ValueError(f"Inconsistent lengths among inputs: {lengths}")