-
-
Couldn't load subscription status.
- Fork 233
Fix noise kwarg propagation for SDEProblem(f::SDESystem) #3985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix noise kwarg propagation for SDEProblem(f::SDESystem) #3985
Conversation
When creating an SDEProblem from an SDESystem, the noise keyword argument was being ignored. The constructor always calculated noise and noise_rate_prototype from the system, overwriting any user-provided values. This fix checks if the user has already provided noise or noise_rate_prototype in kwargs before calculating defaults from the system. This allows users to specify custom noise processes for their SDEProblems. Fixes SciML#3664 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Implementation NotesProcess
Code ChangesThe fix is minimal and surgical - only 12 lines changed in one function to add the conditional logic. No changes to function signatures or public APIs. Next Steps
|
Added test case to verify that user-provided noise keyword argument is properly propagated when creating SDEProblem from SDESystem. The test verifies: - User-provided noise is actually used (noise.curW is modified) - Using the same noise via NoiseWrapper gives deterministic results - Different seeds produce different results (default behavior still works) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
Added test case in test/sdesystem.jl to verify the fix. The test verifies three key behaviors:
This ensures the fix works correctly and prevents regressions in the future. |
Project.toml
Outdated
| SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" | ||
| SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" | ||
| StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" | ||
| StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this add StochasticDiffEq as a dependency?
Summary
Fixes #3664 by ensuring that user-provided
noiseandnoise_rate_prototypekeyword arguments are properly propagated when creating anSDEProblemfrom anSDESystem.Problem
When creating an
SDEProblemfrom anSDESystem, thenoisekeyword argument was being ignored. The constructor always calculatednoiseandnoise_rate_prototypefrom the system, overwriting any user-provided values.Solution
Modified the
SDEProblemconstructor insrc/problems/sdeproblem.jlto check if the user has already providednoiseornoise_rate_prototypein kwargs before calculating defaults from the system. This allows users to specify custom noise processes for their SDEProblems.Changes
SDEProblemconstructor to handle user-providednoiseandnoise_rate_prototypekwargsnoise_rate_prototypeprovided: calculate noise, use provided prototypenoiseprovided: use provided noise, calculate prototypeTest Results
Verified the fix works with the example from the issue:
Checklist
🤖 Generated with Claude Code