You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: Joining solutions with and without sensitivities returns another solve's sensitivities #5845
main at 445ba33. Also reproduces with #5794 applied.
Python Version
3.14
Describe the bug
Joining a solution solved without sensitivities to one solved with them gives wrong or unreadable sensitivities:
first_state or last_state silently returns the other solve's sensitivities.
Reading any variable's sensitivities raises.
Solution.__add__ and Solution.from_sub_solutions only extend _all_sensitivities with segments that have sensitivities. first_state, last_state and _merge_sensitivities then assume the first sensitivity block belongs to all_ts[0] and the last to all_ts[-1].
solver.step and Simulation never build such a join: stepping with sensitivities from a solution without them raises. So this only happens when solutions are added by hand. It was raised in review of #5794 (comment).
Expected: the join raises, or the joined solution has no sensitivities. One option is for __add__ and from_sub_solutions to reject a join whose segments have different sensitivity_names, or to drop the sensitivities.
I would allow joining solutions with and without sensitivities, discarding the sensitivity information from the resulting solution, and also emitting a warning that the sensitivity data has been discarded.
Activity
Readyrel commentedon Oct 8, 2026
Hi, I'd like to work on this issue.
I would allow joining solutions with and without sensitivities, discarding the sensitivity information from the resulting solution, and also emitting a warning that the sensitivity data has been discarded.
Would this approach be acceptable?
Thanks!