Skip to content

Commit bd26c0b

Browse files
Jammy2211Jammy2211
authored andcommitted
fix: stop passing dataset=None to fit_cls when sensitivity Job is complete
Job.perform() in autofit/non_linear/grid/sensitivity/job.py used to short-circuit `dataset = None` when `is_complete` was True (commit 41095a0, Oct 2024 "skip simulation if job is complete") but still called base_fit_cls / perturb_fit_cls with that None. Consumer Analysis classes that unpack `dataset.data` / `dataset.noise_map` in __init__ — including the user-facing autofit_workspace/scripts/features/sensitivity_mapping.py tutorial — crash on re-runs with `AttributeError: 'NoneType' object has no attribute 'data'`. Always call simulate_cls. The expensive non-linear search is still skipped on re-runs via Search.fit's load-from-zip path (paths.restore() unzips, paths.is_complete returns True, result_via_completed_fit loads samples from disk). Only the typically-cheap simulator cost is no longer optimized away. The library's own `test_perform_twice` test in `test_autofit/non_linear/grid/test_sensitivity/test_functionality.py` masked the contract issue because the test conftest's `Analysis.__init__` simply stores `dataset` without unpacking — real workspace code unpacks it eagerly.
1 parent 6a86a88 commit bd26c0b

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

  • autofit/non_linear/grid/sensitivity

autofit/non_linear/grid/sensitivity/job.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,10 @@ def perform(self) -> JobResult:
156156
An object comprising the results of the two fits
157157
"""
158158

159-
if self.is_complete:
160-
dataset = None
161-
else:
162-
dataset = self.simulate_cls(
163-
instance=self.simulate_instance,
164-
simulate_path=self.paths.image_path.with_name("simulate"),
165-
)
159+
dataset = self.simulate_cls(
160+
instance=self.simulate_instance,
161+
simulate_path=self.paths.image_path.with_name("simulate"),
162+
)
166163

167164
result = self.base_fit_cls(
168165
model=self.model,

0 commit comments

Comments
 (0)