Skip to content

fix: guard interpolator and grid search against edge cases#1201

Merged
Jammy2211 merged 1 commit intomainfrom
feature/release-fixes-apr-2026
Apr 12, 2026
Merged

fix: guard interpolator and grid search against edge cases#1201
Jammy2211 merged 1 commit intomainfrom
feature/release-fixes-apr-2026

Conversation

@Jammy2211
Copy link
Copy Markdown
Collaborator

Summary

Two defensive fixes for edge cases surfaced by the Apr 10 release build:

  1. interpolator.__getitem__ — raises a clear IndexError("Cannot interpolate: no instances have been added") when the instances list is empty, instead of a cryptic IndexError: list index out of range.

  2. grid_search_result.log_evidences() — handles None log_evidence values (which occur when a nested sampler doesn't compute evidence) by returning None in the list instead of crashing with TypeError: unsupported operand type(s) for -: 'NoneType' and 'float'.

Relates to PyAutoLabs/PyAutoArray#269.

API Changes

GridSearchResult.log_evidences() now returns None entries for samples where log_evidence is None, instead of raising TypeError. Callers that iterate the result should handle None values.

See full details below.

Test Plan

  • test_autofit/ — 1205 passed
  • Release build re-run after merge
Full API Changes (for automation & release notes)

Changed Behaviour

  • GridSearchResult.log_evidences() — previously crashed if any sample had log_evidence = None. Now returns None for those entries instead of raising TypeError.
  • AbstractInterpolator.__getitem__() — previously raised bare IndexError on empty instances. Now raises IndexError with descriptive message.

Migration

No migration needed. Both changes are backwards-compatible — code that previously worked continues to work. Code that previously crashed now gets a meaningful error or a None value.

🤖 Generated with Claude Code

…ence

Two defensive fixes:
- interpolator.__getitem__ now raises a clear IndexError when instances
  list is empty instead of a cryptic index-out-of-range
- grid_search_result.log_evidences() handles None log_evidence values
  instead of crashing on NoneType - float subtraction

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Jammy2211 Jammy2211 merged commit a3e627c into main Apr 12, 2026
2 checks passed
@Jammy2211 Jammy2211 deleted the feature/release-fixes-apr-2026 branch April 12, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant