Skip to content

Fix extend#4269

Merged
AayushSabharwal merged 3 commits intoSciML:masterfrom
isaacsas:fix_extend
Feb 6, 2026
Merged

Fix extend#4269
AayushSabharwal merged 3 commits intoSciML:masterfrom
isaacsas:fix_extend

Conversation

@isaacsas
Copy link
Member

@isaacsas isaacsas commented Feb 4, 2026

Summary

Fixes #4267

The extend function was not properly merging brownians, poissonians, and jumps fields when combining two systems. These fields were simply lost because they weren't being unioned or passed to the System constructor.

Changes

lib/ModelingToolkitBase/src/systems/abstractsystem.jl

  • Added union of brownians from both systems (passed as positional arg)
  • Added union of poissonians from both systems (passed as kwarg)
  • Added union of jumps from both systems (passed as kwarg)

Test Coverage

New test file extend_sde_jump.jl with comprehensive tests:

  • Brownians: disjoint, shared, ODE+SDE combinations
  • Poissonians: disjoint, shared, constant rate, variable rate, ODE+Poissonian
  • Jumps: ConstantRateJump, MassActionJump, ODE+Jump
  • Mixed combinations: brownians+poissonians, brownians+jumps, poissonians+jumps, all three
  • Priority semantics: verifies sys values preferred over basesys for initial conditions
  • Correctness tests: statistical validation that extended systems compile and solve correctly

isaacsas and others added 3 commits February 4, 2026 14:01
The `extend` function was not properly merging `brownians`, `poissonians`,
and `jumps` fields when combining two systems. These fields are now unioned
and passed to the System constructor.

Fixes SciML#4267

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When extending systems without an independent variable (e.g., NonlinearSystem),
the args tuple was incorrectly constructed as (eqs, sts, ps, brs) which matched
the main System constructor signature with sts being interpreted as iv.

This fix explicitly passes nothing for iv in the no-iv case to correctly match
the System(eqs, nothing, dvs, ps, brownians; ...) constructor path.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@isaacsas isaacsas changed the title WIP: Fix extend Fix extend Feb 6, 2026
@isaacsas
Copy link
Member Author

isaacsas commented Feb 6, 2026

@AayushSabharwal I think this is good too now. Thanks!

@AayushSabharwal AayushSabharwal merged commit e88b19b into SciML:master Feb 6, 2026
32 of 68 checks passed
@isaacsas isaacsas deleted the fix_extend branch February 6, 2026 14:48
@isaacsas
Copy link
Member Author

isaacsas commented Feb 6, 2026

Thanks! If we could get a release when you have a chance that would be great.

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.

extend does not handle Brownians or jumps

2 participants