Skip to content

Fix joining solutions with incompatible sensitivities - #5924

Open
Readyrel wants to merge 9 commits into
pybamm-team:mainfrom
Readyrel:fix/5845-mixed-sensitivities
Open

Readyrel wants to merge 9 commits into
pybamm-team:mainfrom
Readyrel:fix/5845-mixed-sensitivities

Conversation

@Readyrel

@Readyrel Readyrel commented Oct 17, 2026 •

Copy link
Copy Markdown

Description

Joining Solution objects with inconsistent sensitivities could cause errors or produce invalid sensitivity data.

This PR updates Solution.__add__ and Solution.from_sub_solutions to warn and drop incompatible sensitivities while preserving the numerical solution.

It also handles processed variables and time integrals, with regression tests covering mixed sensitivities, parameter mismatches, and multiple solution segments.

Fixes #5845

Type of change

Bug fix.

Added a changelog entry under Unreleased → Bug fixes in CHANGELOG.md.

Important checks:

  • Ruff lint and formatting checks pass.
  • Solver unit tests: 605 passed, 66 skipped.
  • Focused solution tests: 149 passed, 1 skipped.
  • nox -s doctests: 71 passed, 3 skipped.
  • Regression tests added for the fix.
  • nox -s pre-commit: Unrelated EOF formatting issue.
  • nox -s tests: Four Windows IDAKLU failures.

Windows testing note: Similar IDAKLU native failures were reproduced on unmodified upstream main. The tests directly covering this PR passed.

@Readyrel
Readyrel marked this pull request as ready for review October 17, 2026 19:18
@Readyrel
Readyrel requested a review from a team as a code owner October 17, 2026 19:18

This branch has not been deployed

No deployments
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.

[Bug]: Joining solutions with and without sensitivities returns another solve's sensitivities

1 participant