Skip to content

Add diffrax throw option to control solver error handling#20

Merged
smsharma merged 1 commit intomainfrom
feature/diffrax-throw
Jan 26, 2026
Merged

Add diffrax throw option to control solver error handling#20
smsharma merged 1 commit intomainfrom
feature/diffrax-throw

Conversation

@smsharma
Copy link
Collaborator

Summary

Closes #17

Adds a throw parameter to both BackgroundModel and AbundanceModel to control diffrax solver error behavior.

Changes

  • Add throw attribute to BackgroundModel (default True)
  • Add throw attribute to AbundanceModel (default True)
  • Pass throw to all internal diffeqsolve calls

Behavior

  • throw=True (default): Raises exception when solver fails (e.g., max_steps reached)
  • throw=False: Returns partial results, useful for parameter scans where some combinations may fail

Usage

# Default behavior (throw=True) - raises on failure
thermo_model = BackgroundModel()
abundance_model = AbundanceModel(nuclear_net)

# For parameter scans (throw=False) - returns partial results
thermo_model = BackgroundModel(throw=False)
abundance_model = AbundanceModel(nuclear_net, throw=False)

Test plan

  • Existing tests pass

🤖 Generated with Claude Code

Closes #17

- Add `throw` parameter to both BackgroundModel and AbundanceModel
- Default is True (raises exceptions on solver failure)
- Set to False for parameter scans where some combinations may fail
- Passed through to all internal diffeqsolve calls

Usage:
  # Default behavior (throw=True)
  thermo_model = BackgroundModel()
  abundance_model = AbundanceModel(nuclear_net)

  # For parameter scans (throw=False)
  thermo_model = BackgroundModel(throw=False)
  abundance_model = AbundanceModel(nuclear_net, throw=False)
  # Failures return partial results instead of raising

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Owner

@cgiovanetti cgiovanetti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thank you!

@smsharma smsharma merged commit 86e4ebc into main Jan 26, 2026
1 check passed
@cgiovanetti cgiovanetti deleted the feature/diffrax-throw branch January 28, 2026 19:59
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.

No option to set diffrax throw

2 participants